So to start with I need to select a physics engine and compile it for my computer running Ubuntu Jaunty 9.04 64-bit. I have chosen to use the Physics Abstraction Layer (PAL) since it looks relatively easy to use and includes some buoyancy functionality (which I intend to improve). It requires an actual physics engine back end, there are many to choose from such as ODE, Tomahawk, Box2D, .... I have chosen the BULLET physics engine.
Now to set up the programming environment. How to compile and build PAL physics abstraction layer with the BULLET physics engine on Linux. The lines starting with a $ are to be executed on the command line.
Get the Subversion source control client (svn):
$ sudo apt-get install subversionCheckout read-only copies of PAL and BULLET from svn:
$ svn co https://pal.svn.sourceforge.net/svnroot/pal/pal palGet some of their dependencies:
$ svn checkout http://bullet.googlecode.com/svn/trunk/ bullet-read-only
$ sudo apt-get install freeglut3 freeglut3-dev cmake g++ cmake cmake-gui libsdl1.2-devCompile BULLET.
$ cd bullet-read-onlyEdit install.sh, replacing all Window's line endings (\r\n) with UNIX line endings (\n)
$ gedit install.sh &
Menu->Search->Replace, Search for \r\n, Replace with \n, click Find. Save, Quit.
$ ./autogenIf you have a multicore CPU then include the --enable-multithreaded option. It may give you better real-time performance.
$ ./configure --enable-multithreadedCompile using make.
$ make -j 2The -j 2 option tells make to do two jobs at once, i.e., use two CPU cores.
Install the Bullet libraries to /usr/local/lib/ and the Header files to /usr/local/include/bullet/
$ sudo make installI had to manually copy the btActionInterface.h file to get PAL to compile, it appears it was left out of the install script.
$ sudo cp src/BulletDynamics/Dynamics/btActionInterface.h /usr/local/include/bullet/BulletDynamics/Dynamics/Compile PAL.
Do not use the premake instructions for building PAL. I believe they are old. Use the Cmake system instead.
$ cd ../pal/Open the Cmake GUI
$ cmake-gui &Enter the source and build directories at the top to the current directory (pal). The window below will list a bunch of variables. Select the tick box for PAL_BUILD_BULLET. Click "Configure". A window will show up. Select the default Unix make file option.
Some more variables will be shown in the main window.
- Set the BULLET_SINGLE_THREADED if you didn't build the multi-threaded version before.
- Fix the BULLET_INCLUDE_DIR -> /usr/local/include/bullet and the
- BULLET_LIBRARY_??? variables -> /usr/local/lib/lib???.so if they haven't been found.
- Change from simple view to advanced view and find the CMAKE_CXX_FLAGS variable and add -fPIC to it.
Click Generate. This will setup the project for you.
Now make a few quick edits to get the demo to work. In pal/Config.h change the default engine from "BULLET" to "Bullet". In pal/example/begin.cpp change line 7 from PF->LoadPALfromDLL(); to PF->LoadPALfromDLL("/usr/local/lib/"); so it know's where to find the Bullet physics libraries.
Now compile it.
$ make -j 2And install it.
$ sudo make installTell the operating system about the new libraries.
$ sudo ldconfigNow we should be able to test the demo/test program. It has been compiled into the bin/ directory. Run it.
$ bin/palbeginnerShould get output like:
Found dll 'liblibpal_bullet.so'Fin.
Found dll 'libbulletmultithreaded.so'
Found dll 'libbulletcollision.so'
Found dll 'libbulletdynamics.so'
Found dll 'libbulletmath.so'
Found dll 'libbulletsoftbody.so'
Physics:0x16e0840
Current box position is 1.49902 at time 0.01
Current box position is 1.49706 at time 0.02
Current box position is 1.49412 at time 0.03
3 comments:
Thank you! I've been trying to get this to work for about a day now and your instructions helped a HEAP! (aren't search engines great?)
Hey, that's nice. I wanted to try PhysX, PAL and Delta3D. Just tested PAL now with Bullet using your directions. Changing the all CAPITALS version from "NOVODEX" to "Novodex" in pal/Config.h worked. For the PhysX files I had to change some macros on Ubuntu, for example in the NxSimpleTypes.h file they forgot to add "defined" as in #elif defined LINUX. Oh yeah, and contrary to what is stated in the cmake-gui, there is SDL on Linux (sudo aptitude install libsdl-dev).
The only big BUT, the ball stays at position 1.5:
/opt/pal$ bin/palbeginner
Found dll 'libpal_novodex.so'
Found dll 'libbulletmath.so'
Found dll 'libpal.so'
Found dll 'libpal_bullet.so'
Found dll 'libbulletcollision.so'
Found dll 'libbulletdynamics.so'
Found dll 'libbulletsoftbody.so'
Physics:0x87b8818
Current box position is 1.50000 at time 0.02
Current box position is 1.50000 at time 0.04
Current box position is 1.50000 at time 0.06
Current box position is 1.50000 at time 0.08
Thanks for the tutorial. I think it worked great for installing bulletphysics, but I've had trouble getting the PAL part to work too.
Does this still work when you try to install? I tried, but I get all sorts of errors which I listed here (Since I want to use Bullet and PAL with irrlicht): http://irrlicht.sourceforge.net/forum/viewtopic.php?f=1&t=46752
If you encountered this and have any advice, suggestions, etc. I would really appreciate any help. Thanks!
Post a Comment