I'm not sure how to approach this... my naive approach is to get the objects rotation, update it, and set it. But I'd rather apply torque, I think?
Here's where the boxes are created:
Code: Select all
btCollisionShape* boxShape = new btBoxShape(btVector3(1, 1, 1));
btTransform boxTransform;
btScalar boxMass(1.0);
btVector3 boxInertia(0, 0, 0);
for (int i = 0; i < 4; ++i) {
boxTransform.setIdentity();
boxTransform.setOrigin(btVector3(0, 12*i, 0));
btDefaultMotionState* boxMotionState = new btDefaultMotionState(boxTransform);
btRigidBody::btRigidBodyConstructionInfo boxInfo(boxMass, boxMotionState, boxShape, boxInertia);
btRigidBody* box = new btRigidBody(boxInfo);
m_dynamicsWorld->addRigidBody(box);
}
Code: Select all
// ground is 0, first box is 1
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[1];
btRigidBody* body = btRigidBody::upcast(obj);
body->applyTorque(btVector3(0, 1, 0));
body->activate(true);
Thanks.