I'm sure this is me being and idiot but was hoping somebody could help out... I'm dropping a couple of cubes, offset from each other, and they're landing in an impossible position. It could be rendering code but as you can see below it's pretty simple so I'm a bit confused as to what's going on. Any ideas?
Setup code:
Code: Select all
pWorld->setGravity(btVector3(0, - GRABBITY, 0));
// shapes needed (floor + cubes)
tShapes[SHAPE_GROUND_PLANE].pShape = new btStaticPlaneShape(btVector3(0, 1, 0), 0);
tShapes[SHAPE_CUBE_10].pShape = new btBoxShape(btVector3(BOX_SIZE_BY_2, BOX_SIZE_BY_2, BOX_SIZE_BY_2));
// world static body - quaternion + origin
tPhysicsBodies[0].pMS = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 0, 0)));
tPhysicsBodies[0].pBody = new btRigidBody(btRigidBody::btRigidBodyConstructionInfo(0, tPhysicsBodies[0].pMS, tShapes[SHAPE_GROUND_PLANE].pShape, btVector3(0, 0, 0)));
tPhysicsBodies[0].pBody->setRestitution(0.2);
tPhysicsBodies[0].pBody->setFriction(0.25);
pWorld->addRigidBody(tPhysicsBodies[0].pBody);
// add our cube to the world...
btVector3 vInertia;
tShapes[SHAPE_CUBE_10].pShape->calculateLocalInertia(BOX_MASS, vInertia);
tPhysicsBodies[1].pMS = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 30, 0)));
tPhysicsBodies[1].pBody = new btRigidBody(btRigidBody::btRigidBodyConstructionInfo(1, tPhysicsBodies[1].pMS, tShapes[SHAPE_CUBE_10].pShape, vInertia));
tPhysicsBodies[1].pBody->setAngularVelocity(btVector3(0, 0, 0));
tPhysicsBodies[1].pBody->setDamping(0, 0);
tPhysicsBodies[1].pBody->setRestitution(0.5f);
tPhysicsBodies[1].pBody->setFriction(0.25f);
tPhysicsBodies[1].pBody->setDeactivationTime(10.0f);
pWorld->addRigidBody(tPhysicsBodies[1].pBody);
Code: Select all
btTransform transform;
float fMat[16];
pCam->UseView(false);
glEnable(GL_DEPTH_TEST);
tPhysicsBodies[1].pBody->getMotionState()->getWorldTransform(transform);
transform.getOpenGLMatrix(fMat);
GFX_DrawBox(Vec3(-100, -10, -100), Vec3(100, 0, 100));
glPushMatrix();
// glLoadMatrixf(fMat);
glMultMatrixf(fMat);
GFX_DrawBox(Vec3(- BOX_SIZE_BY_2, - BOX_SIZE_BY_2, - BOX_SIZE_BY_2), Vec3(BOX_SIZE_BY_2, BOX_SIZE_BY_2, BOX_SIZE_BY_2), false);
glPopMatrix();
tPhysicsBodies[2].pBody->getMotionState()->getWorldTransform(transform);
transform.getOpenGLMatrix(fMat);
glPushMatrix();
glMultMatrixf(fMat);
GFX_DrawBox(Vec3(- BOX_SIZE_BY_2, - BOX_SIZE_BY_2, - BOX_SIZE_BY_2), Vec3(BOX_SIZE_BY_2, BOX_SIZE_BY_2, BOX_SIZE_BY_2), false);
glPopMatrix();
glDisable(GL_DEPTH_TEST);

So I ask you, wtf am I doing wrong?
