Convert Blender physics to Bullet API calls

Post Reply
Oaf
Posts: 7
Joined: Sun Jun 10, 2007 7:40 pm

Convert Blender physics to Bullet API calls

Post by Oaf »

Hi,

As this is my first post, let me first say how fantastic both the Bullet library is and its integration into Blender. I've spent the last few months trying to work out which set of tools and libraries to use for my next (hopefully console) game - and this is definitely it!

What I'm trying to do at the moment is use Blender to create a set of standard physics objects for my game, which I can then hand over to the artists to a) make pretty and b) make game levels.

While they're busy doing that stuff I'm going to be building a cross platform engine (starting with XNA, then moving across to Java for PC/Mac and C++ for DS/Wii etc).

So, I can easily export all the objects in a scene as a .X file, I have a nice Python script to export all the object info as a text file (which I'm about to extend to include all the Sensors and stuff), but how do I map all the physics information onto Bullet API calls?

For example - I have an object with a Near sensor (it's a Fan). If something comes near it, it gets blown away from the fan. Is there a 1:1 mapping between the Near sensor and something in the Bullet API...?

I suppose I could go through the Blender source and see how it all works, but I'm hoping someone will say "yes, it's dead easy - here's a page on how to do it" :lol:

Many thanks,

Oaf
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Convert Blender physics to Bullet API calls

Post by Erwin Coumans »

Oaf wrote: So, I can easily export all the objects in a scene as a .X file, I have a nice Python script to export all the object info as a text file (which I'm about to extend to include all the Sensors and stuff), but how do I map all the physics information onto Bullet API calls?
Blender and Bullet both support COLLADA Physics, so most properties are exported from Blender COLLADA 1.4 exporter, and imported using Bullet COLLADA Importer (see Bullet/Demos/ColladaDemo).
For example - I have an object with a Near sensor (it's a Fan). If something comes near it, it gets blown away from the fan. Is there a 1:1 mapping between the Near sensor and something in the Bullet API...?
There is a wrapper to provide sensors on top of the regular Bullet API. Please check out blender\source\gameengine\Physics\Bullet\CcdPhysicsEnvironment.cpp

Hope this helps,
Erwin
Oaf
Posts: 7
Joined: Sun Jun 10, 2007 7:40 pm

Post by Oaf »

Trying to play with my .blend and the collada demo.

The demo complains that in my file Z is up - is there an easy way to change Z in Blender, or is there another way round the problem?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Post by Erwin Coumans »

My todo list is too long, and I've postponed all my Blender efforts for a while to catch up on core Bullet development.

It might take a longer while before I can get back to this.
Sorry about this,
Erwin
Oaf
Posts: 7
Joined: Sun Jun 10, 2007 7:40 pm

Post by Oaf »

Hey no probs - if I find a solution or modify the demo code I'll get in touch so you can check it in....
Oaf
Posts: 7
Joined: Sun Jun 10, 2007 7:40 pm

Post by Oaf »

Playing with the Collada exporter further, it seems it doesn't record half the data anyway; I've just loaded my .DAE back into Blender and all the sensors, etc aren't there.

No worries, I'll just have to write a Python script to export the physics info, then map the settings to Bullet calls myself. At least I know it'll work properly that way ;)

I'll probably post up the script and XNA import code somewhere once I'm done.
Post Reply