Make the getHeadNode method more general

This commit is contained in:
Chris Robinson 2013-04-08 05:48:52 -07:00
parent c6c67a1bb4
commit 08d43fe217
5 changed files with 15 additions and 8 deletions

View File

@ -180,6 +180,18 @@ void Animation::createObjectList(Ogre::SceneNode *node, const std::string &model
} }
Ogre::Node *Animation::getNode(const std::string &name)
{
if(mObjectList.mSkelBase)
{
Ogre::SkeletonInstance *skel = mObjectList.mSkelBase->getSkeleton();
if(skel->hasBone(name))
return skel->getBone(name);
}
return NULL;
}
bool Animation::hasAnimation(const std::string &anim) bool Animation::hasAnimation(const std::string &anim)
{ {
for(std::vector<NifOgre::ObjectList>::const_iterator iter(mAnimationSources.begin());iter != mAnimationSources.end();iter++) for(std::vector<NifOgre::ObjectList>::const_iterator iter(mAnimationSources.begin());iter != mAnimationSources.end();iter++)

View File

@ -113,6 +113,8 @@ public:
void play(const std::string &groupname, const std::string &start, const std::string &stop, bool loop); void play(const std::string &groupname, const std::string &start, const std::string &stop, bool loop);
virtual Ogre::Vector3 runAnimation(float timepassed); virtual Ogre::Vector3 runAnimation(float timepassed);
Ogre::Node *getNode(const std::string &name);
}; };
} }

View File

@ -201,7 +201,7 @@ namespace MWRender
void RaceSelectionPreview::updateCamera() void RaceSelectionPreview::updateCamera()
{ {
Ogre::Vector3 scale = mNode->getScale(); Ogre::Vector3 scale = mNode->getScale();
Ogre::Vector3 headOffset = mAnimation->getHeadNode()->_getDerivedPosition(); Ogre::Vector3 headOffset = mAnimation->getNode("Bip01 Head")->_getDerivedPosition();
headOffset = mNode->convertLocalToWorldPosition(headOffset); headOffset = mNode->convertLocalToWorldPosition(headOffset);
mCamera->setPosition(headOffset + mPosition * scale); mCamera->setPosition(headOffset + mPosition * scale);

View File

@ -451,9 +451,4 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::
} }
} }
Ogre::Node* NpcAnimation::getHeadNode()
{
return mObjectList.mSkelBase->getSkeleton()->getBone("Bip01 Head");
}
} }

View File

@ -78,8 +78,6 @@ public:
virtual Ogre::Vector3 runAnimation(float timepassed); virtual Ogre::Vector3 runAnimation(float timepassed);
Ogre::Node* getHeadNode();
void forceUpdate() void forceUpdate()
{ updateParts(true); } { updateParts(true); }
}; };