RANDOM USER PROJECTS
An advanced rendering pipeline for Panda3D
Disney Pinball: real physics and cool settings
Super Duper Mario Bros: a cool variant of an old classic

Panda3D Manual: Loading Actors and Animations

Contents

Actor Basics

The python class Actor is designed to hold an animatable model and a set of animations. Since the Actor class inherits from the NodePath class, all NodePath functions are applicable to actors.

Note, however, that Actor is a Python class that extends the C++ NodePath class. For the most part, you don't have to think about this: Actor inherits sensibly from NodePath and generally does what you expect. There are a few subtle oddities, though. When you attach an Actor into a scene graph, the low-level C++ Panda constructs only records the NodePath part of the Actor in the scene graph, which is fine as long as you also keep a pointer to the Actor instance in your Python objects. If you let the Actor destruct, however, its visible geometry will remain, but it will cease animating (because it is no longer an Actor). Also, even if you keep the Actor object around, if you retrieve a new pointer to the Actor from the scene graph (for instance, as returned by the collision system), you will get back just an ordinary NodePath, not an Actor.

The Actor interface provides a high-level interface on the low-level Panda constructs. In Panda, the low-level node that performs the animation is called Character. You can see the Character node in the scene graph when you call actor.ls().

Do not confuse the Actor class with the ActorNode class, which is used for physics. They are completely unrelated classes with similar names.

Using Actors

The Actor class must be imported before any loading or manipulation of actors.

from direct.actor.Actor import Actor

Once the model is loaded, the actor object must be constructed, and the model and animations must be loaded:

Loading each animation requires a tuple: the name one is giving the animation and the path to the animation. This entire process can be shortened to a single command:

nodePath = Actor('Model Path', {
  'Animation Name 1':'Animation Path 1',
  'Animation Name 2':'Animation Path 2',
})

Note that it is also possible to store the animations and model in the same file. In that case, just create the Actor with just the model as parameter.

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.