1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-13 21:40:11 +00:00

Add a quick hack to let "playgroup all" work on creatures and NPCs

This commit is contained in:
Chris Robinson 2012-07-19 22:34:26 -07:00
parent 4210880c06
commit 8b5b74f9ee
2 changed files with 60 additions and 24 deletions

View File

@ -52,6 +52,18 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O
} }
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
} }
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setEnabled(true);
state->setLoop(false);
}
}
} }
} }
@ -59,20 +71,26 @@ void CreatureAnimation::runAnimation(float timepassed)
{ {
if(mAnimate > 0) if(mAnimate > 0)
{ {
//Add the amount of time passed to time
//Handle the animation transforms dependent on time
//Handle the shapes dependent on animation transforms
mTime += timepassed; mTime += timepassed;
if(mTime >= mStopTime)
if(mEntityList.mSkelBase)
{ {
mAnimate--; Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
//std::cout << "Stopping the animation\n"; Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
if(mAnimate == 0) while(as.hasMoreElements())
mTime = mStopTime; {
else Ogre::AnimationState *state = as.getNext();
mTime = mStartTime + (mTime - mStopTime); 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();
}
}
} }
handleAnimationTransforms(); handleAnimationTransforms();

View File

@ -117,6 +117,18 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRendere
//stay in the same place when we skipanim, or open a gui window //stay in the same place when we skipanim, or open a gui window
} }
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setEnabled(true);
state->setLoop(false);
}
}
if(isFemale) if(isFemale)
mInsert->scale(race->data.height.female, race->data.height.female, race->data.height.female); mInsert->scale(race->data.height.female, race->data.height.female, race->data.height.female);
else else
@ -361,24 +373,30 @@ void NpcAnimation::runAnimation(float timepassed)
timeToChange = 0; timeToChange = 0;
updateParts(); updateParts();
} }
timeToChange += timepassed; timeToChange += timepassed;
//1. Add the amount of time passed to time
//2. Handle the animation transforms dependent on time
//3. Handle the shapes dependent on animation transforms
if(mAnimate > 0) if(mAnimate > 0)
{ {
mTime += timepassed; mTime += timepassed;
if(mTime > mStopTime)
if(mEntityList.mSkelBase)
{ {
mAnimate--; Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
if(mAnimate == 0) Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
mTime = mStopTime; while(as.hasMoreElements())
else {
mTime = mStartTime + (mTime - mStopTime); 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();
}
}
} }
handleAnimationTransforms(); handleAnimationTransforms();