I am using the following to update RigidBody translation: body->activate(true); btTransform trans; body->getMotionState()->getWorldTransform(trans); body->translate(btVector3(newX - trans.getOrigin().getX(), newY - trans.getOrigin().getY(), newZ - trans.getOrigin().getZ()));
I want to update the rotation as well, I have Pitch, Yaw, Roll values, how do I update the rotation in Bullet Physics?
I tried to use the following, but it doesn't work: body->activate(true); btTransform trans; body->getMotionState()->getWorldTransform(trans); btQuaternion quat; quat.setEuler(x, y, z); trans.setRotation(quat); body->setCenterOfMassTransform(trans);
I am also looking for a way to update Pitch, Yaw, Roll when Bullet Physics change it, something similar to the following (but for rotation): // The following works for translation model->X = float(trans.getOrigin().getX()); model->Y = float(trans.getOrigin().getY()); model->Z = float(trans.getOrigin().getZ());
I am using the following to update RigidBody translation: body->activate(true); btTransform trans; body->getMotionState()->getWorldTransform(trans); body->translate(btVector3(newX - trans.getOrigin().getX(), newY - trans.getOrigin().getY(), newZ - trans.getOrigin().getZ()));
I want to update the rotation as well, I have Pitch, Yaw, Roll values, how do I update the rotation in Bullet Physics?
I think you would apply the translation and rotation to your trans object and then pass it back to body through the setCenterOfMassTransform function.
I found out how to get the rotation from Bullet Physics, I used the following: btQuaternion quat = trans.getRotation(); D3DXQUATERNION *dxQuat = new D3DXQUATERNION(quat.getX(), quat.getY(), quat.getZ(), quat.getW()); D3DXVECTOR3 rotVector3 = QuaternionToEuler(*dxQuat); model[j]->rotationX = rotVector3.x; model[j]->rotationX = rotVector3.y; model[j]->rotationX = rotVector3.z;
Now, How can I change the rotation if I only have the values Pitch, Yaw, Roll?
The following doesn't work as expected: body->activate(true); btTransform tr; body->getMotionState()->getWorldTransform(tr); btQuaternion quat; quat.setEuler(yaw, pitch, roll); tr.setRotation(quat); body->setCenterOfMassTransform(tr);
The following doesn't work as expected: body->activate(true); btTransform tr; body->getMotionState()->getWorldTransform(tr); btQuaternion quat; quat.setEuler(yaw, pitch, roll); tr.setRotation(quat); body->setCenterOfMassTransform(tr);
It isn't? What numbers are you putting in and what numbers are you getting out?