How to apply rotation to a body in Bullet Physics Engine?

10,355

The most straightforward way would be to directly set the world transform for a rigid body, either through a motion state or by direct setting. To get a transform from roll, pitch, and yaw, you could use:

btRigidBody * rigidBody = //...
btTransform tr;
tr.setIdentity();
btQuaternion quat;
quat.setEuler(yaw,pitch,roll); //or quat.setEulerZYX depending on the ordering you want
tr.setRotation(quat);

rigidBody->setCenterOfMassTransform(tr);
Share:
10,355
Ricardo Sanchez
Author by

Ricardo Sanchez

Former Adobe Flash & Actionscript Developer

Updated on June 04, 2022

Comments

  • Ricardo Sanchez
    Ricardo Sanchez about 2 years

    I have rotation values (roll, pitch, yaw). I would like to apply that rotation to a body, but I have no idea how to do that.