It seems i just can't get it right.
Here is a snippet:
Code: Select all
btConvexHullShape *shape = new btConvexHullShape(&vertex->x, vertexCount, 12); //doesn't work
//btBoxShape *shape = new btBoxShape(btVector3(5.0f, 5.0f, 5.0f)); //works as expected
btVector3 localInertia(0.0f, 0.0f, 0.0f);
shape->calculateLocalInertia(1.0f, localInertia);
btRigidBody *body = new btRigidBody(1.0f, new btDefaultMotionState(), shape, localInertia);
btTransform transform;
transform.setFromOpenGLMatrix(bufNode->GetNodeTransform().Get());
body->setWorldTransform(transform);
TheBulletMgr->GetWorld()->addRigidBody(body);
btStaticPlaneShape *groundShape = new btStaticPlaneShape(btVector3(0.0f, 0.0f, 1.0f), 1.0f);
btCollisionObject *groundBody = new btCollisionObject();
groundBody->setCollisionShape(groundShape);
TheBulletMgr->GetWorld()->addCollisionObject(groundBody);
And this is what happens when using a btBoxShape: http://www.youtube.com/watch?v=G4Wg_lTQ-QY
The first one falls incorrectly. And by just replacing the shape to box it starts to work as it should. All rendering is done using debug drawing. I also noticed, that there is no red-green-blue cross in the convex hull version. The one that shows the center (of mass?). Box shape has it thought.
What did i forget to add?