I've made a new Bullet Demo about it.
It's based on the library HACD ("Hierarchical approximate convex decomposition" by Khaled Mamou), which should be included in the Bullet library package (in the "Extra" section) starting from Bullet version 2.79 (at the time of writing this post, it's present in the Bullet SVN repository).
The demo can be used in three ways:
1) As a common Bullet Demo, it's similiar to the appConvexDecompositionDemo, but with a better interface.
The heart of the demo is the (header only) file (and class) "btHACDCompoundShape.h", that can be easily integrated into existing applications and that takes a btStridingMeshInterface* as an argument in its constructor together with an optional structure with some decomposition parameters.
Currently the demo is composed by four scenes; keys '[' and ']' can be used to change the current scene.
To compile the demo, a reference to HACD.lib is needed and STL is required (STL is also used in lib HACD itself).
The demo depends on lib BulletWorldImporter too, and glut (or freeglut) is needed.
IMPORTANT: Please copy the file "appHACDDemo.exe.cmdlineParams.txt" AND the folder "appHACDDemoMeshes" in the same directory of the executable "appHACDDemo.exe".
The folder "appHACDDemoMeshes" contains three simple OBJ files I've made using Wings3d, that are needed in some of the scenes (together with the "Bunny mesh" and the "Torus mesh" that were included in appGImpactTestDemo).
2) As a standalone decomposition tool that takes a Wavefront OBJ file (recommended because the loader keeps track of all the submeshes in the model), or an .OFF file as an argument (on Windows you can drag the model directly onto the appHACDDemo.exe icon in Explorer). The resulting "plain" Bullet btCompoundShape can be optionally saved to disk as a file with the ".bcs" (Bullet Collision Shape) extension. Additional decomposition paramters are not passed through the command line (too many), but can be edited directly in a text file named "appHACDDemo.exe.cmdlineParams.txt", in the same folder of appHACDDemo.exe).
".bcs" files can be loaded in plain Bullet applications with the following code:
Code: Select all
#include <BulletWorldImporter/btBulletWorldImporter.h> // In "Bullet/Extra/Serialize". Needs link to: BulletWorldImporter.lib
btCollisionShape* Load(const char* filename,bool verbose) {
btBulletWorldImporter loader(0);//don't store info into the world
loader.setVerboseMode(verbose);
if (!loader.loadFile(filename)) return NULL;
btCollisionShape* shape = NULL;
if (loader.getNumCollisionShapes()>0) shape = loader.getCollisionShapeByIndex(0);
// Hope there are no leaks.
return shape;
}
1) No need to use STL.
2) No need to link to HACD.lib
3) Only simple models can be decomposed "at runtime" with "btHACDCompoundSape.h", because the decomposition
process can take several seconds. Much better to load btCompoundShapes directly from disk.
3) As a ".bcs" (Bullet Collision Shape) file viewer, when the command line argument has a ".bcs" extension (on Windows you can drag it onto the .exe).
Screenshot:Source code + precompiled binary for Win32 (compiled with Visual C++ 2008 and /MD, Visual C++ 2008 Redistributable Package required): Hope you like it and find it useful

UPDATED: 15 Jan 2012:
-> btTriangleMeshesEx can be assigned to btCollisionShapes/btCollisionObjects and displayed with the 'r' key (Limitation: only static meshes are supported (display lists are used)).
Now it's possible to compare the decomposed collision shape to the input mesh.
-> btConvexHullComputer is used instead of btShapeHull (better visualization of the decomposed collision shape).
-> CollisionShapes with a striding mesh interface inside them can be directly decomposed (and optionally used as input meshes).
-> Some new decomposition parameters added.
-> Frustum culling added.
-> Free camera mode added ('a' key).
-> Ortho mode modified a bit ('o' key).
-> Raytrace screenshots can be shown/hidden ('R' key (uppercase)).
-> Texture support added.
-> Bug: when meshes are displayed ('r' key), the (btShapeHull based) stencil shadows may produce artifacts, color bleeding and blinking.
The 'g' key can be used to disable them.
NEW SOURCE CODE: 22 May 2013: This code is similiar to the old one, but it is:
1) Ready for "Asset Import Library" version 3 integration (see: LOAD_MESHES_FROM_ASSET_IMPORT_LIBRARY in "btTriangleMeshEx.h").
2) Ready for experimental integration with CURRENT version of the V-HACD library git repository,
available at: https://code.google.com/p/v-hacd (see: EXCLUDE_VHACD in "appHACDDemo.h").
[Edit:] The supported v-hacd version is outdated, and V-HACD2 is not supported: please use EXCLUDE_VHACD always.
If you do not need to load formats different from .obj and .off, and you don't want to play with V-HACD,
I suggest you keep on using the old code (that comes with an exe for Win32), instead of spending time
trying to compile this version.