Howto: Use the Bullet 3D Physics Engine in Xcode
Its been a while since I added a Howto on here. Hope you find it useful.
The Bullet 3D Physics engine is shipped with the Oolong 3D Engine for iPhone. However, if you just want to use the physics engine in your iPhone app, the following steps should help you to integrate it into your project:
- Download Bullet. I got it as part of the Oolong Engine source from Google Code.
- Open Xcode Preferences, select Source Trees and add one with Setting Name “BULLET_ROOT” and Display Name “Bullet”. Give it the full path to your Bullet folder.
- In your Xcode project, CTRL+Click on Classes folder and select Add Group. Give it the name “Bullet”. Then CTRL+Click the Bullet group and select Get Info. Set the Path Type combo box to ”Relative to Bullet”. The Full Path should show the full directory path for the Bullet folder.
- Select Project/Edit Project Settings from the Xcode menu. Search for “header search paths” in the Build tab and add the full path to your Bullet src. Make sure to check the Recursive checkbox. You will need to do this for Debug and Release build configurations.
- In your source code, include the relevant bullet header e.g.
#include "btBulletDynamicsCommon.h"
will include everything you need for rigid body dynamics. - Check out the Oolong samples to see how to use the physics engine or head over to the Bullet website for more resources.
Hopefully, I haven’t missed anything out but let me know if you spot something incorrect or can’t get it to work.
Update: 21/07/09: One step I forgot to mention was that Bullet is written in C++. You iPhone application class files will default to Objective-C and so won’t be able to compile. You need to CTRL+Click the class file referrencing the btBulletDynamicsCommon.h header file, select Get Info and change its file type to be Objective-C++. That should allow it to compile properly.
