Prepare for supporting controller objects

actorid
Chris Robinson 12 years ago
parent af2a38db38
commit 0631b28646

@ -45,6 +45,7 @@ Animation::~Animation()
for(size_t i = 0;i < mEntityList.mEntities.size();i++) for(size_t i = 0;i < mEntityList.mEntities.size();i++)
sceneMgr->destroyEntity(mEntityList.mEntities[i]); sceneMgr->destroyEntity(mEntityList.mEntities[i]);
} }
mEntityList.mControllers.clear();
mEntityList.mParticles.clear(); mEntityList.mParticles.clear();
mEntityList.mEntities.clear(); mEntityList.mEntities.clear();
mEntityList.mSkelBase = NULL; mEntityList.mSkelBase = NULL;
@ -129,6 +130,10 @@ void Animation::createEntityList(Ogre::SceneNode *node, const std::string &model
while(boneiter.hasMoreElements()) while(boneiter.hasMoreElements())
boneiter.getNext()->setManuallyControlled(true); boneiter.getNext()->setManuallyControlled(true);
} }
Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > ctrlval(OGRE_NEW AnimationValue(this));
for(size_t i = 0;i < mEntityList.mControllers.size();i++)
mEntityList.mControllers[i].setSource(ctrlval);
} }
@ -457,6 +462,8 @@ Ogre::Vector3 Animation::runAnimation(float timepassed)
if(!handleEvent(time, evt)) if(!handleEvent(time, evt))
break; break;
} }
for(size_t i = 0;i < mEntityList.mControllers.size();i++)
mEntityList.mControllers[i].update();
return movement; return movement;
} }

@ -16,6 +16,26 @@ namespace MWRender
class Animation class Animation
{ {
protected: protected:
class AnimationValue : public Ogre::ControllerValue<Ogre::Real>
{
private:
Animation *mAnimation;
public:
AnimationValue(Animation *anim) : mAnimation(anim)
{ }
virtual Ogre::Real getValue() const
{
return mAnimation->mCurrentTime;
}
virtual void setValue(Ogre::Real value)
{
mAnimation->mCurrentTime = value;
}
};
MWWorld::Ptr mPtr; MWWorld::Ptr mPtr;
MWMechanics::CharacterController *mController; MWMechanics::CharacterController *mController;

@ -367,6 +367,7 @@ void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
sceneMgr->destroyParticleSystem(entities.mParticles[i]); sceneMgr->destroyParticleSystem(entities.mParticles[i]);
for(size_t i = 0;i < entities.mEntities.size();i++) for(size_t i = 0;i < entities.mEntities.size();i++)
sceneMgr->destroyEntity(entities.mEntities[i]); sceneMgr->destroyEntity(entities.mEntities[i]);
entities.mControllers.clear();
entities.mParticles.clear(); entities.mParticles.clear();
entities.mEntities.clear(); entities.mEntities.clear();
entities.mSkelBase = NULL; entities.mSkelBase = NULL;

@ -45,6 +45,8 @@ struct EntityList {
std::vector<Ogre::ParticleSystem*> mParticles; std::vector<Ogre::ParticleSystem*> mParticles;
std::vector<Ogre::Controller<Ogre::Real> > mControllers;
EntityList() : mSkelBase(0) EntityList() : mSkelBase(0)
{ } { }
}; };

Loading…
Cancel
Save