本文整理汇总了C++中ogre::Skeleton::getNumAnimations方法的典型用法代码示例。如果您正苦于以下问题:C++ Skeleton::getNumAnimations方法的具体用法?C++ Skeleton::getNumAnimations怎么用?C++ Skeleton::getNumAnimations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Skeleton
的用法示例。
在下文中一共展示了Skeleton::getNumAnimations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _actionLook
void NPCCharacter::_actionLook(const Ogre::Vector3& target)
{
Ogre::Bone* headBone;
std::string n = _node->getName();
Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton();
headBone = skel->getBone("Bip01_Head");
headBone->setManuallyControlled(true);
headBone->setInheritOrientation(true);
int nAnim = skel->getNumAnimations();
//have to do this to allow the head to turn properly.
for(int i = 0; i < nAnim; ++i)
{
skel->getAnimation(i)->destroyNodeTrack(headBone->getHandle());
}
Ogre::Vector3 test = headBone->_getDerivedPosition() * CHARACTER_SCALE_FACTOR + _node->getPosition();
Ogre::Vector3 dir = target - test;
Ogre::Quaternion nodeRot,boneRot;
Ogre::Euler boneEuler; boneEuler.setDirection(dir,true,false);
/*boneRot = _node->convertLocalToWorldOrientation(_node->getOrientation()) * headBone->_getDerivedOrientation();
Ogre::Vector3 boneTest = boneRot * Ogre::Vector3::UNIT_Z;*/
//Ogre::Vector3 boneTest = headBone->getOrientation() * Ogre::Vector3::UNIT_Z;
//turns the direction vector into a 2D normalized vector on the X/Z axis.
dir.y = 0;
dir.normalise();
//All of this ray query stuff is to make sure that the AI can "see" the target before attempting to look at it.
Ogre::SceneManager* scene = _node->getCreator();
Ogre::Ray ray(headBone->_getDerivedPosition() * CHARACTER_SCALE_FACTOR + _node->getPosition(),dir);
Ogre::RaySceneQuery* query = scene->createRayQuery(ray);
query->setSortByDistance(true);
query->setQueryMask(CHARACTER_MASK | SCENERY_MASK);
Ogre::RaySceneQueryResult results = query->execute();
bool withinView = false;
if(results.size() == 0)
{
withinView = true;
}
else
{
if(results.begin()->movable->getParentNode()->getName() == getName())
{
if(results.size() == 1)
{
withinView = true;
}
}
if(!withinView && results.size() > 1 && std::next(results.begin())->distance > test.distance(target))
{
withinView = true;
}
}
scene->destroyQuery(query);
if(withinView)
{
Ogre::Euler node;
Ogre::Euler t = headOrientation.getRotationTo(dir);
t.limitYaw(Ogre::Radian(3.0));
t.limitPitch(Ogre::Radian(0.0));
headOrientation = headOrientation + t;
headOrientation.limitYaw(Ogre::Degree(100));
headOrientation.limitPitch(Ogre::Degree(60));
headBone->setOrientation(headOrientation);
/*headBone->rotate(boneTest.getRotationTo(dir),Ogre::Node::TS_WORLD);
Ogre::Quaternion boneRotation = _node->convertLocalToWorldOrientation(_node->getOrientation()) * headBone->_getDerivedOrientation() * (Ogre::Quaternion(Ogre::Degree(180),Ogre::Vector3::UNIT_Y));
Ogre::Quaternion nodeRotation = _node->_getDerivedOrientation();
Ogre::Quaternion diff = nodeRotation.Inverse() * boneRotation;*/
}
_isActFinished = true;
}