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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.