Here I have a problem with object rotation in Bullet. What I want to implement is to rotate an object around global x,y,z axis at the same time. (here global means the axis x,y,z will not be changed during rotation) I have the code below
btQuaternion m_lastRot;
btTransform tranf = _obj[idx]->mp_btRidObj->getCenterOfMassTransform();
tranf.getBasis().getRotation(m_lastRot);
btQuaternion qx(btVector3(1,0,0),angX);
btQuaternion qy(btVector3(0,1,0),angY);
btQuaternion qz(btVector3(0,0,1),angZ);
tranf.setRotation(qz * qy * qx * m_lastRot);
_obj[idx]->mp_btRidObj->setCenterOfMassTransform(tranf);
But it does not work as I expected. By the way, the code below which rotateing a object around one of x,y,z axis each time works well.
btQuaternion m_lastRot;
btTransform tranf = _obj[idx]->mp_btRidObj->getCenterOfMassTransform();
tranf.getBasis().getRotation(_obj[idx]->m_lastRot);
btQuaternion qx(btVector3(1,0,0),angX);
btQuaternion qy(btVector3(0,1,0),angY);
btQuaternion qz(btVector3(0,0,1),angZ);
if(x)
tranf.setRotation(qx * m_lastRot);
else if(y)
tranf.setRotation(qy * m_lastRot);
else if(z)
tranf.setRotation(qz * m_lastRot);
_obj[idx]->mp_btRidObj->setCenterOfMassTransform(tranf);
Is there anyone can tell me how to solve this problem?