Our model can move but it isn't animated yet, let's change this.
The
FrameListener
needs two animation states:Ogre::AnimationState* _aniState; Ogre::AnimationState* _aniStateTop;
To get the animation states in the constructor, we need a pointer to the entity:
MyFrameListener(Ogre::RenderWindow* win,Ogre::Camera* cam,Ogre::Viewport* viewport,Ogre::SceneNode* node,Ogre::Entity* ent)
With this pointer we can retrieve the
AnimationState
and save them for later use:_aniState = ent->getAnimationState("RunBase"); _aniState->setLoop(false); _aniStateTop = ent->getAnimationState(«RunTop»); _aniStateTop->setLoop(false);
Now that we have the
AnimationState
, we need to have a flag in theframeStarted
function, which tells us whether or not the entity walked this frame. We add this flag into theif
conditions that query the keyboard state:bool walked = false; if(_Keyboard->isKeyDown(OIS::KC_UP)) { SinbadTranslate += Ogre::Vector3(0,0,-1); _rotation =...