Panda3D Manual: Loading Actors and Animations

Contents

Actor Basics

The Actor class which is available to python users is not available to C++ users. If you need such a class you have to create your own class which at least should do the following:

  • load the Actor Model
  • load the animations
  • bind the model and the animations using AnimControl or AnimControlCollection
Required Includes
#include "auto_bind.h"
#include "AnimControlCollection.h"
Load the Actor Model
NodePath Actor = window->load_model(windo->get_render(), "panda-model");
Load the Animation
window->load_model(Actor, "panda-walk");
Bind the Model and the Animation
// don't use PT or CPT with AnimControlCollection
AnimControlCollection anim_collection;
 
//bind the animations to the model
auto_bind(Actor.node(), anim_collection);
Control the Animations
// the name of an animation is preceded in the .egg file with <Bundle>:
// loop a specific animation
anim_collection.loop("panda_soft", true);
 
// loop all animations
anim_collection.loop_all(true);
 
// play an animation once:
anim_collection.play("panda_soft");
 
// pose
anim_collection.pose("panda_soft", 5);


to display names of loaded animations you could use:
for(int n = 0; n < anim_controls.get_num_anims(); ++n)
cout << anim_controls.get_anim_name(n) << endl;

If you add more animations to some node after calling: auto_bind(...) they will not be controllable until auto_bind(...) is called again with proper arguments.

Note that it is possible to store the animations and the model in the same file.

Although this is a rarely-used technique, it is possible to assemble a character model out of several separate pieces (separate models). This is further explained in the section Multi-Part Actors.

Panda3D supports both skeletal animation and morph animations.

It is also possible to load animations asynchronously, if your build of Panda has Threading enabled (which is the case in version 1.6.1 and above).

Panda Filename Syntax

The filenames used in the Actor constructor must follow Panda's filename conventions. See Loading Models for more information. Loading actors and animations utilizes the panda model path, the same as for static models.