I'm trying to create a compound shape with two boxes which will be used as the players rigid body so it will move around. But when I create it the shape moves by itself. Here is the code:
Code: Select all
btBoxShape *legsBoxShape = new btBoxShape(btVector3(0.1, 0.2, 0.05));
compoundShape->addChildShape(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 0.2, 0)), legsBoxShape);
btBoxShape *bodyBoxShape = new btBoxShape(btVector3(0.4, 0.2, 0.4));
compoundShape->addChildShape(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 0.6, 0)), bodyBoxShape);
btDefaultMotionState* compoundBoxMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(2, 0.4, 0)));
btScalar compoundMass = 1;
btVector3 compoundFallInertia(0, 0, 0);
compoundShape->calculateLocalInertia(compoundMass, compoundFallInertia);
btRigidBody::btRigidBodyConstructionInfo compoundRigidBodyCI(compoundMass, compoundBoxMotionState, compoundShape, compoundFallInertia);
btRigidBody* compoundRigidBody = new btRigidBody(compoundRigidBodyCI);
dynamicsWorld->addRigidBody(compoundRigidBody);