Time for action — adding animations

As always, we are going to use the code from the previous chapter, and for once we don't need to delete anything:

  1. For our animation, we need to add new member variables in the FrameListener. Add a pointer holding the entity we want to animate and a pointer to the used animation state:
    Ogre::Entity* _ent;
    Ogre::AnimationState* _aniState;
  2. Then change the constructor of the FrameListener to get the entity pointer as a new parameter:
    Example34FrameListener(Ogre::SceneNode* node,Ogre::Entity* ent,RenderWindow* win,Ogre::Camera* cam)
  3. In the function body of the constructor, assign the given entity pointer to the new member variable:
    _ent = ent;
  4. After this, retrieve the animation state called Dance from the entity and ...

Get Ogre 3D 1.7 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.