I've been able to make static geometry with btBvhTriangleMeshShape(shape,false,true); but now I would like to make non-static objects using the same principle but am having troubles getting it to work.
I try to follow the tutorials closely and this is what I've managed to get set up for adding a dynamic object of any mesh:
Code: Select all
btCollisionShape *WorldColShape = new btBvhTriangleMeshShape(groundShape,false,true);
m_collisionShapes.push_back(WorldColShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,0,0));
btScalar mass(6.f);
btVector3 localInertia(0,0,0);
WorldColShape->calculateLocalInertia(mass,localInertia);
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(offset.x,
offset.y,
offset.z));
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,WorldColShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
m_dynamicsWorld->addRigidBody(body);
What I've been able to look up is that there is a problem when trying to use calculateLocalInteria with a potential concave mesh? (Setting inertia to 0 just makes the object fall through everything and ignore collisions). I'm curious, do I have to essentially constrain boxes (or some other convex shapes) together to form an object I want? Or is there something relatively obvious that I am missing that allows using the Triangle Mesh to be created and used as an actual physical object? It's 3 AM so I'm not at my sharpest
