OBJ (3D Format) -> BULLET (3D Physics) -> OF

Continuing the work trying to get Collada files into Bullet and then into OF, I have decided upon a new route.

ConvexDecompositionDemo.cpp in the Bullet source distribution shows how to use Convex Decomposition to take a complicated OBJ 3D object, and simplify it into a series of Convex Shapes for more efficient simulation.

I have got the first step of loading an OBJ in, decomposing it, and displaying it’s verticies in amongst some video cubes, courtesy of Theo’s work on top of Memo’s. Not drawing correctly, but I can see the Convex object affecting other objects in the world.

Now I need to be able to add Concave shapes to the simulation as well, in order to be able to draw their correct Meshes “over” the physics world’s view of them - based on their Convex Decompostion into multiple Convex shapes.

I.e. (from the Bulllet Docs)

http://bulletphysics.com/Bullet/BulletP-…-c223854839
"Convex Decomposition

Ideally, concave meshes should only be used for static artwork. Otherwise its convex hull should be used by passing the mesh to btConvexHullShape. If a single convex shape is not detailed enough, multiple convex parts can be combined into a composite object called btCompoundShape. Convex decomposition can be used to decompose the concave mesh into several convex parts. See the Demos/ConvexDecompositionDemo for an automatic way of doing convex decomposition."

That part of the code is dealt with at the end of:

  
void ConvexDecompositionDemo::initPhysics(const char* filename)  

in ConvexDecompositionDemo.cpp

http://code.google.com/p/bullet/source/-…-onDemo.cpp

Starting at:

  
ConvexDecomposition::DecompDesc desc;  

Ending at:

  
convexDecompositionObjectOffset.setZ(-6);  
trans.setOrigin(-convexDecompositionObjectOffset);  
localCreateRigidBody( mass, trans,compound);  

I am currently stuck at understanding of the callback that the ConvexDecomposition code seems to use to compute the various new ConvexShapes, and the creation of a Compoud object in the Bullet World.

You can see where I am here:

http://files.getdropbox.com/u/370155/00-…-eryone.zip

Which is basically me pulling apart ConvexDecompositionDemo.cpp into Theo’s project.

Cheers,

JGL

I am currently looking at this page:

http://www.partow.net/programming/templ-…-index.html

To try to understand more about the structure of the code.

BTW, all the lovely Convex Decomposition code comes from this site:

http://codesuppository.blogspot.com/

Lots of interesting snippets - including a promising looking loader for 3D content.

JGL

Success! I now understand Callbacks.

I’ve got a new version running successfully:

http://files.getdropbox.com/u/370155/00-…-llback.zip

You can’t see any new drawing occurring, but I now have three clones of the Decomposed object happily interacting with a bunch of cubes. You can see the cubes bouncing off invisible shapes as they fall.

My next step is to get everything drawing correctly, for which I am going to initially use the drawing loop from Bullet itself, and eventually use GLM - which lets me load TGA textured OBJ’s.

http://devernay.free.fr/hacks/glm/

Cheers,

JGL