Time for action — printing all animations

We will use the previous code as base to print all animations that our entity has.

  1. At the end of the createScene() function, get all the animations that the model has as a set:
    Ogre::AnimationStateSet* set = _SinbadEnt->getAllAnimationStates();
    
  2. Then define an iterator and init it with the iterator of the set:
    Ogre::AnimationStateIterator iter = set->getAnimationStateIterator();
    
  3. And, finally, iterate over all animations and print their names:
    while(iter.hasMoreElements())
    {
    std::cout << iter.getNext()->getAnimationName() << std::endl;
    }
    
  4. Compile and run the application. After starting the application and loading the scene, you should see the following text in the console of the application:

    Dance

    DrawSwords

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.