Raf*_*fid 2 3d quaternions direction ogre
我有一个有身体和头部的角色。头部作为骨骼与身体相连,我已经知道骨骼的名称。现在我想得到头部的方向?那可能吗?我试过这个,但它似乎不起作用:
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;
Run Code Online (Sandbox Code Playgroud)
我认为我应该乘以单位 x 以外的向量,所以我尝试了所有组合。在这种情况下(即 Smith 实体),我使用 得到了正确答案-Vector3::UNIT_X,所以我认为这是正确的解决方案。我尝试了其他实体,但未能得到正确答案。
任何的想法?
小智 5
用负 Z 乘以四元数应该正确地将方向作为向量返回:
Vector3 direction = head->_getDerivedOrientation() * Vector3::NEGATIVE_UNIT_Z;
Run Code Online (Sandbox Code Playgroud)