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

    HandsClosed

    HandsRelaxed

    IdleBase

    IdleTop

    JumpEnd

    JumpLoop

    JumpStart

    RunBase

    RunTop

    SliceHorizontal

    SliceVertical

What just happened?

We asked the entity to give us a set containing all of the animation it has. We then iterated over this set and printed the name of the animation. We see that there are a lot of animations we didn't use and also some we have already used.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.40.189