O'Reilly logo

Ogre 3D 1.7 by Felix Kerger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required