Animation Control in C++


#1

Hi guys… :slight_smile:

I’m new to Panda3D, was checking out the engine with its libraries recently, and currently, trying to do model animations. I’ve searched through various threads on the forum, as well as documentation provided on the web, but I cant seem to find help for starting and stopping animations, in C++. I am able to load models and single animations.

Any help will be much appreciated. Thank you. :slight_smile:


#2

Animations in C++ work different than in Python.
To load an animation, you need to load it as separate model and bind it to the model. The auto_bind function gives you an AnimControlCollection, where you can extract your AnimControls from. You can use these to control your animation.
For example, if you want fine-control of the animation in the Hello World example:

#include "auto_bind.h"
#include "animControlCollection.h"

//...

  //load our panda
NodePath pandaActor = window->load_model(framework.get_models(),"panda-model");
pandaActor.set_scale(0.005,0.005,0.005);
pandaActor.reparent_to(window->get_render());
  
  //load the walk animation
window->load_model(pandaActor,"panda-walk4");
AnimControlCollection panda_anims;
auto_bind(pandaActor.node(), panda_anims, 0);
  //now you can do with _panda_anims whatever you want, e.g.:
panda_anims.loop("panda_walk_character",true);
  //where panda_walk_character is the name of the animation.

I’m currently in the process of creating a tutorial that will explain these things some more.

Hope this helps.


#3

Hey Thanks a lot!
I’ll check up the references about AnimControls… Thanks! :slight_smile: