I'm currently in the building process of a 3D OpenGL engine with Bullet Physics.
I've implemented bullet correctly (I believe).
Anyways. Box shapes work and are not problem. But when I use a btTriangleMesh with a btBvhTriangleMeshShape and apply an angular velocity to that object. It bounces right the first time. Than it sort of digs itself in the ground en starts rotating further and eventually falls through it.
my code for making the triangle mesh is:
Code: Select all
btTriangleMesh* mTriMesh = new btTriangleMesh();
while(node->getMesh()->triangle != NULL)
{
btVector3 v0(node->getMesh()->triangle->data.x[0], node->getMesh()->triangle->data.y[0], node->getMesh()->triangle->data.z[0]);
btVector3 v1(node->getMesh()->triangle->data.x[1], node->getMesh()->triangle->data.y[1], node->getMesh()->triangle->data.z[1]);
btVector3 v2(node->getMesh()->triangle->data.x[2], node->getMesh()->triangle->data.y[2], node->getMesh()->triangle->data.z[2]);
mTriMesh->addTriangle(v0, v1, v2);
node->getMesh()->triangle = node->getMesh()->triangle->next;
}
this->shape = new btBvhTriangleMeshShape(mTriMesh, true);
Code: Select all
oge::getConvexShapes().push_back(this->shape);
bool isDynamic = (mass != 0.0);
btVector3 localInertia = btVector3(0,0,0);
if(isDynamic)
{
this->shape->calculateLocalInertia(mass, localInertia);
}
btDefaultMotionState* motionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), btVector3(node->getPosition().x, node->getPosition().y, node->getPosition().z)));
btRigidBody::btRigidBodyConstructionInfo ci(mass, motionState, this->shape, localInertia);
ci.m_restitution = 1;
body = new btRigidBody(ci);
body->setActivationState(DISABLE_DEACTIVATION);
body->setAngularVelocity(btVector3(0.7f,0.0f,0.0f));
body->setDamping(0.1, 0.1);
oge::getDynamicsWorld()->addRigidBody(body);
But I get the same result whatever I try.
Does someone have a solution?
Thanks in advance.