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)

"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


Starting at:

ConvexDecomposition::DecompDesc desc;  

Ending at:

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:


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



I am currently looking at this page:


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

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


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


Success! I now understand Callbacks.

I’ve got a new version running successfully:


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.