since I feel owing you guys a lot (about five answers on five critical questions), I decided to pay off a little.
This is a complete ODE-implementing guide. It's meant for beginners as well as for troubled advanced users and is mostly compilation of posts from Antiarc and people from the ODE mailing list. I only fixed some incongruities and things that didn't work on my system.
It's intended for MSVC 6.0, Service Pack 5, but it should work for any later version with only minor changes.
ODE stands for Open Dynamics Engine. It gives you the ability to introduce high quality and stable physics into your engine. For many games (like racing) this means a radical difference between playable and unplayable. For most others it can be at least a major feature.
ODE shares it's position with OgreTok here on Ogre3D Forums. OgreTok is an implementation of Tokamak dynamics engine. It's said to be easier to use, but less powerful and less stable. I can't really tell if that's truth, I never played with this engine. Anyway, if you'd first like to try OgreTok, just download that from Ogre3D.org's download page and good luck. (It's part of Ogre Add-Ons CVS Snapshot archive under Source Releases / Unstable CVS Snapshots category. Here.)
Now, here start's the guide:
1) Get the ODE source from http://q12.org/ode/. Get the GNU make.exe from here and copy it to the ODE directory.
2) In a console (DOS-prompt), run your vcvars32.bat file to set your path variables for making source under Windows. If this doesn't work (the windows don't have enough spare variables memory), add vcvars32.bat to your autoexec.bat and restart.
Let the prompt running.
3) Edit the ode/config/user-settings file. Change PLATFORM to msvc, so you have this:
Code: Select all
PLATFORM=msvc
Code: Select all
OPCODE_DIRECTORY=OPCODE
5) Return to command prompt, go to the ODE directory and run make.exe. Hold your breath and ignore any non-critical errors. Try the ODE tests in (ode_directory)/ode/test. If everything works just fine, then congratulations -- you lucky bastard!
Anyway, you may notice that the mesh collision doesn't work (run test_moving_trimesh.exe and see if the balls and boxes do actually rebound from the two rabbits). This was my case, so here's the solution:
You may skip this, if everything worked fine for you.
What you have to do now is to build ODE with MSVC. Go to this page (ODE Wiki Area) to get full description of how to do that.
There is a major change thought, since you need a LIB, not an EXE. I recommend first following the instructions on the page and seeing if you can get the test_moving_trimesh.exe working. You'll have to additionally include OPCODE directory and opcode.lib. And you'll have to add dTRIMESH_ENABLED preprocessor definition in the Project Settings C/C++ Tab.
After that you see it works, make a new project - not a console application, but a static library. There's no option for including LIBs when making other LIB, but don't worry. MSVC will do that for you, just don't forget to include to OPCODE directory and define dTRIMESH_ENABLED again (I'm not sure if this is really necessary, but who knows...).
Ignore any warnings in the process of compiling - there will be many of them.
Hmpf, I hope this worked, 'cause I really wouldn't know what to advice you then.
6) Copy ode/ode.lib to ogremain/lib/debug and the ode/include/ode directory to ogremain/include.
7) Add ode.lib to your additional libraries under the Linker portion of your project properties. Add opcode.lib too, in case you want to use the mesh collision.
Include ODE libraries in your program like this:
Code: Select all
#include "Ogre.h"
#include "OgreNoMemoryMacros.h"
#include "ode/ode.h"
#include "OgreMemoryMacros.h"
10) Get your API reference and read through the very useful ODE FAQ. There you'll also find answer for the question How can I implement my collision callback as a C++ member function?. Important!Antiarc wrote:ODE is now installed! To use it, you'll simply create Body objects and logically tie those to SceneNodes by mirroring a Body object's position with the SceneNode's position. You will apply forces to a Body, then get the body's position and change your "sibling" SceneNode's position to match. Hope you enjoy!
Another very useful source of information is Antiarc's Using ODE in your projects! topic here on Ogre Forums including geekd's codes to translate between ODE Bodies and Ogre SceneNodes.
I hope you got the thing running. You're gonna love it!
Bye
- Filip