I’ve been a bit slack lately with blog updates, mainly because I’ve spent the last few days relaxing/recovering from my wisdom tooth surgery. The resulting discomfort made it surprisingly hard to stay focused long enough to do any programming. I’m almost back to normal now though and was finally able to concentrate on getting some work done today. I haven’t started on my UI system yet as there’s still some planning I’d like to do, so I decided to play around with the Bullet Physics library to see how it would work with the iPhone.
I’m quite fond of game physics, as my first large programming project was writing a complete PhysX implementation for Torque Game Engine Advanced. Unfortunately PhysX is closed-source, and since nVidia doesn’t offer an iPhone version it’s not an option. There are a few other good libraries out there, e.g. Newton and ODE, but I went with Bullet for no real compelling reason. I’m still not completely sold on it being the best solution though, as the API is quite complex and there’s a ton of stuff I won’t need. Something lightweight like Tokamak or True Axis might be better,especially for mobile development. But I digress, back to Bullet!
I wanted to compile Bullet as a Framework to make it easy to include in the Xcode project. Unfortunately Bullet is only setup to compile with MS Visual Studio by default, so I had to do some fiddling/learning CMake to generate myself an Xcode project to compile the Frameworks. Of course, once they were compiled I discovered that the target CPU architecture was wrong and the Frameworks wouldn’t work with the iPhone. I’ve actually yet to figure out how to compile a Framework targeted for the iPhone, so for the time being I’ve just dumped the necessary Bullet source files right into my GL Engine project. It’s not the solution I’d hoped for, but it did allow me to finally get going and actually use the damn thing. 😛
I haven’t done anything overly fancy yet, but Bullet did integrate into my engine without a lot of trouble. I wrote a simple singleton Physics class, which is essentially an implementation of the Bullet HelloWorld program. SceneObjects can then plug into that class and add/manage a Bullet rigid body. Right now I’ve only used it to create a ground plane and a few spheres though.
I intend to work with physics quite a bit more in the future, and possibly even use a physics library to handle collision detection in the engine. That’s all for now though.