在 OGRE 中获取对象的方向

鉴客 发布于 2012/02/11 11:12
阅读 377
收藏 0

我有一个小人包含身体和脑袋,脑袋和身体通过骨头连接,并且我已经知道了骨头的名称,现在我想获取脑袋的方向,可能吗?

我写了下面这样的代码,但是无法用:

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;

I thought I should multiply by other than the unit x vector, so I tried all the combinations. In this case (i.e. Smith entity), I got the correct answer using -Vector3::UNIT_X, so I thought this is the correct solution. I tried with other entities, but I failed to get the correct answer.

Any idea?

加载中
0
鉴客
鉴客

Multiplying a quaternion by negative Z should correctly return the direction as a vector:

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

详情请看 this post on the Ogre forums.

返回顶部
顶部