在 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;
我认为我应该乘以除单位 x 向量之外的其他值,所以我尝试了所有组合。在这种情况下(即史密斯实体),我使用 -Vector3::UNIT_X
得到了正确的答案,所以我认为这是正确的解决方案。我尝试与其他实体联系,但未能得到正确答案。
有什么想法吗?
I have a character with a body and head. The head is connected to the body as a bone and I already know the name of the bone. Now I want to get the direction of the head? Is that possible? I tried this but it doesn't seem to work:
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将四元数乘以负 Z 应该正确返回方向作为向量:
请参阅 this在 Ogre 论坛上发帖。
Multiplying a quaternion by negative Z should correctly return the direction as a vector:
See this post on the Ogre forums.
我怀疑以下内容也将起作用。
I suspect the following will also work.