여기에서 Bullet의 개체 회전에 문제가 있습니다. 구현하고자하는 것은 동시에 글로벌 x, y, z 축을 중심으로 객체를 회전시키는 것입니다. (여기서는 글로벌 수단을 X 축, Y, Z가 회전하는 동안 변경되지 않는다) I 예상대로 I는Bullet Physics에서 개체를 회전하는 방법
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);
아래 코드가 있지만 작동하지 않는 . 그건 그렇고, 아래의 코드는 x, y, z 축 중 하나를 돌릴 때마다 개체가 잘 작동합니다.
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);
이 문제를 해결하는 방법을 알려주는 사람이 있습니까?
관련 답변 http://stackoverflow.com/questions/8196634/how-to-apply-rotation-to-a-body-in-bullet-physics-engine –