Thanks for the response, but I meant having it rotate when it collides with something, like when a box is tumbling down a slope. It should happen normally without me doing anything, so it must be something with how I retrieve the angles. Right now, if a box falls on the ground at an angle, it will just stay at that angle, no matter what. I set up the body like this:
Code:
m_pCollisionShape = new btBoxShape(bt(m_pModel->GetAABB().GetHalfDims()));
m_pMotionState = new btDefaultMotionState(btTransform(btQuaternion(0.2f, 0.6f, 0.1f, 1.0f).normalized(), bt(m_aabb.GetCenter())));
const float mass = 1.0f;
m_pCollisionShape->calculateLocalInertia(mass, btVector3(0.0f, 0.0f, 0.0f));
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(mass, m_pMotionState, m_pCollisionShape, btVector3(0.0f, 0.0f, 0.0f));
m_pRigidBody = new btRigidBody(rigidBodyCI);
m_pPhysicsWorld->m_pDynamicsWorld->addRigidBody(m_pRigidBody);
m_pRigidBody->setAngularVelocity(btVector3(0.2f, 0.5f, 0.2f));
And here is how I retrieve the angles:
Code:
btTransform transform;
m_pMotionState->getWorldTransform(transform);
// Update box model
m_pModel->SetPosition(cons(transform.getOrigin()));
m_pModel->SetRotation(cons(transform.getRotation()));
When I print transform.getRotation(), the values are always just what I initialized it to, it never changes over time when the boxes tumble around. transform.getOrigin() updates just fine.
EDIT: Actually, it seems that it is not how I am retrieving the rotations, but the simulation just doesn't have any! All rigid bodies have infinite angular momentum or something, since I can do ridiculous stuff like this:
