In my naive fantasies, the following would create a pyramid-shaped rigid body:
Code: Select all
btTriangleMesh tetraMesh;
tetraMesh.addTriangle(btVector3(-1, 0, -1), btVector3(-1, 0, 1), btVector3( 1, 0, -1), false);
tetraMesh.addTriangle(btVector3( 1, 0, -1), btVector3(-1, 0, 1), btVector3( 1, 0, 1), false);
tetraMesh.addTriangle(btVector3(-1, 0, -1), btVector3(0, 1, 0), btVector3(-1, 0, 1), false);
tetraMesh.addTriangle(btVector3(-1, 0, -1), btVector3(0, 1, 0), btVector3( 1, 0,-1), false);
tetraMesh.addTriangle(btVector3( 1, 0, -1), btVector3(0, 1, 0), btVector3( 1, 0, 1), false);
tetraMesh.addTriangle(btVector3( 1, 0, 1), btVector3(0, 1, 0), btVector3(-1, 0, 1), false);
tetraShape = new btBvhTriangleMeshShape(&tetraMesh, false);
btVector3 localInertia(0, 0, 0);
tetraShape->calculateLocalInertia(1, localInertia);
btTransform trans;
trans.setIdentity();
trans.setOrigin(btVector3(0, 7, 0));
btDefaultMotionState* motionState = new btDefaultMotionState(trans);
btRigidBody* body = new btRigidBody(1, motionState, tetraShape, localInertia);
body->setContactProcessingThreshold(BT_LARGE_FLOAT);
body->setCcdMotionThreshold(.5);
body->setCcdSweptSphereRadius(0);
m_dynamicsWorld->addRigidBody(body);