This guide will show how to incorpore the GIMPACt functionality on the Bullet Engine:

Registering the Algorithm

For register this algorithm in Bullet, proceed as following:
btCollisionDispatcher * dispatcher = static_cast<btCollisionDispatcher *>(m_dynamicsWorld ->getDispatcher());
With the instructon above, btGImpactCollisionAlgorithm will handle:

Creating Shapes.

Creating trimeshes.

For creating trimeshes you must provide an interface for your model data. You could use btTriangleIndexVertexArray class for providing the indices and the vertices from your triangle models.

For example, you could create a trimesh from memory as following:

btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(NUM_TRIANGLES,
                NUM_VERTICES,(REAL*) &gVertices[0],sizeof(REAL)*3);

Where gIndices is an array of integers and gVertices is an array of float with 3 components. Then you must create the Trimesh shape as following:

btGImpactMeshShape * trimesh = new btGImpactMeshShape(indexVertexArrays);
The next step is configuring the trimesh, for example changing the scale:
At end, you must call btGImpactMeshShape.updateBound for ensure that the shape will build its internal Box set structure:
trimesh->updateBound();// Call this method once before doing collisions
Also you must call btGImpactMeshShape.postUpdate() each time when changing the trimesh data ( For deformable meshes), this will enable a flag to the trimesh shape which tells that the trimesh data has been changed and btGImpactMeshShape.updateBound will be called in collision routines. <

Compound Shapes.

For compound shapes, you must create btGImpactCompoundShape objects. Then you could add sub shapes as following;
btGImpactCompoundShape * mycompound = new btGImpactCompoundShape();

btTransform localtransform;
 .... Setting transformation

//add shapes with transformation
btCollisionShape * subshape = creatingShape(0);
.... Setting transformation
btCollisionShape * subshape2 = creatingShape(1);
.... add more shapes
At end, you must call btGImpactCompoundShape.updateBound for ensure that the shape will build its internal Box set structure:
Generated on Wed Jun 13 16:58:21 2007 for GIMPACT by  doxygen 1.5.2