Combine animation handling into the base class

actorid
Chris Robinson 13 years ago
parent fcaa8aae06
commit 81ce8dbe12

@ -42,4 +42,33 @@ void Animation::skipAnim()
mAnimate = 0;
}
void Animation::runAnimation(float timepassed)
{
if(mAnimate != 0)
{
mTime += timepassed;
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setTimePosition(mTime);
if(mTime >= state->getLength())
{
if(mAnimate != -1)
mAnimate--;
//std::cout << "Stopping the animation\n";
if(mAnimate == 0)
mTime = state->getLength();
else
mTime = mTime - state->getLength();
}
}
}
}
}
}

@ -36,7 +36,7 @@ public:
void playGroup(std::string groupname, int mode, int loops);
void skipAnim();
virtual void runAnimation(float timepassed) = 0;
virtual void runAnimation(float timepassed);
};
}

@ -69,30 +69,9 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O
void CreatureAnimation::runAnimation(float timepassed)
{
if(mAnimate > 0)
{
mTime += timepassed;
// Placeholder
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setTimePosition(mTime);
if(state->getTimePosition() >= state->getLength())
{
mAnimate--;
//std::cout << "Stopping the animation\n";
if(mAnimate == 0)
mTime = state->getLength();
else
mTime = mTime - state->getLength();
}
}
}
}
Animation::runAnimation(timepassed);
}
}

@ -373,30 +373,7 @@ void NpcAnimation::runAnimation(float timepassed)
}
timeToChange += timepassed;
if(mAnimate > 0)
{
mTime += timepassed;
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setTimePosition(mTime);
if(state->getTimePosition() >= state->getLength())
{
mAnimate--;
//std::cout << "Stopping the animation\n";
if(mAnimate == 0)
mTime = state->getLength();
else
mTime = mTime - state->getLength();
}
}
}
}
Animation::runAnimation(timepassed);
}
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)

Loading…
Cancel
Save