Controlling Animations

:blush: I feel like such a programming newbie needing to ask for help in the forum again so soon but…

I’ve successfully made it through the ‘Hello World’ tutorial and I’m trying to play with different parts of the engine to get a better grasp of exactly how things work and I’ve run into a bit of a snag.

I need to know how to control animations in a NodePath. Unfortunately, in C++ there doesn’t appear to be a distinction in type between actor/model and the Actor portion of the manual is one of those things that people haven’t had a chance to translate to C++ yet.

I’ve done some digging in the reference and I found the AnimControlCollection class which seems to have the methods I need (pose, play, loop, and stop) but I honestly have no idea how to use the thing, especially seeing as just loading the animation and parenting it to the model (window->load_model(Actor, “anim”)) doesn’t load it into the AnimControlCollection.

So my question is: How does one go about managing actor animations in C++? WindowFramework::loop_animations is great for starting them but not much else.

Operating System: Microsoft Windows Vista x64
Panda Version: 1.7.0
IDE/Compiler: MSVC++ 2008 Express

If you examine the source code for windowFramework.cxx, you will see that loop_animations() consists of this definition:

////////////////////////////////////////////////////////////////////
//     Function: WindowFramework::loop_animations
//       Access: Public
//  Description: Looks for characters and their matching animation
//               files in the scene graph; binds and loops any
//               matching animations found.
////////////////////////////////////////////////////////////////////
void WindowFramework::
loop_animations(int hierarchy_match_flags) {
  // If we happened to load up both a character file and its matching
  // animation file, attempt to bind them together now and start the
  // animations looping.
  auto_bind(get_render().node(), _anim_controls, hierarchy_match_flags);
  _anim_controls.loop_all(true);
}

That is to say, it is a call to auto_bind(), which is the function that binds the animations to the models and stores the result in an AnimControlCollection (named _anim_controls in this case), followed by a call to AnimControlCollection::loop_all().

So, now you know how to do the same thing. :slight_smile:

David

Thanks! Funny thing is I actually did download the source and start picking through the code and I know for a fact I looked at the function and I guess it never clicked.

I’ll look a little harder next time.