3d 在食人魔中获取对象方向

3d 在食人魔中获取对象方向,3d,quaternions,direction,ogre,3d,Quaternions,Direction,Ogre,我有一个有身体和头的角色。头部作为骨头与身体相连,我已经知道骨头的名字了。现在我想知道头部的方向?可能吗?我试过这个,但似乎不起作用: Entity *smith = m_sceneManager->getEntity("Smith"); Bone *head = smith->getSkeleton()->getBone("Bip01 Head"); Vector3 direction = head->_getDerivedOrientation() * Vector3

我有一个有身体和头的角色。头部作为骨头与身体相连,我已经知道骨头的名字了。现在我想知道头部的方向?可能吗?我试过这个,但似乎不起作用:

Entity *smith = m_sceneManager->getEntity("Smith");
Bone *head = smith->getSkeleton()->getBone("Bip01 Head");
Vector3 direction = head->_getDerivedOrientation() * Vector3::UNIT_X;
std::cout << StringConverter::toString(direction) << std::endl;
Entity*smith=m_sceneManager->getEntity(“smith”);
Bone*head=smith->getSkeleton()->getBone(“Bip01头”);
Vector3方向=头部->\u getDerivedOrientation()*Vector3::UNIT\u X;
标准::cout
我怀疑以下方法也会奏效

// get orientation as a quaternion
const Ogre::Quaternion q = head->_getDerivedOrientation();

// use pitch, yaw, and roll as values for direction vector
const Ogre::Vector3 direction( q.getPitch(), q.getYaw(), q.getRoll() );

将四元数乘以负Z应正确返回向量方向:

Vector3 direction = head->_getDerivedOrientation() * Vector3::NEGATIVE_UNIT_Z;

Vector3 direction = head->_getDerivedOrientation() * Vector3::NEGATIVE_UNIT_Z;