How Is btConvexHullShape Used

NotEinstein
Posts: 1
Joined: Sat May 21, 2011 8:38 pm

How Is btConvexHullShape Used

Post by NotEinstein »

I am new to Bullet Physics and in the very early learning stage. I have successfully used ths sphere, box, and cylinder shapes but am having problems using btConvexHullShape.

I want to use the convex hull shape for a simple mesh I have created. All of my boxes, spheres, and cylinders go straight through my mesh as if it isn't there.

Here is some significant part of my code:

btConvexHullShape * shape = new btConvexHullShape();

// add the points to the shape
for ( int ii=0; ii<numPoints; ++ii )
shape->addPoint( verts[ii] );

// approximate absolute mass using bounding box
btVector3 aabbMin(0,0,0), aabbMax(0,0,0);
shape->getAabb( btTransform::getIdentity(), aabbMin, aabbMax );

btVector3 aabbExtents = aabbMax - aabbMin;

float volume = aabbExtents.x() * aabbExtents.y() * aabbExtents.z();
btScalar mass = volume * object->specificGravity;

btVector3 localInertia(0.f,0.f,0.f);
shape->calculateLocalInertia(mass, localInertia );

MyMotionState* myMotionState = new MyMotionState( object->GetTransform() );

btRigidBody::btRigidBodyConstructionInfo rbInfo( mass, myMotionState, shape, localInertia );

// set up the materal properties
rbInfo.m_restitution = object->m_restitution;
rbInfo.m_friction = object->m_friction;

btRigidBody* body = NULL;
body = new btRigidBody(rbInfo);

m_dynamicsWorld->addRigidBody( body );

I would appreciate any help I can get.