Loading Actors and Animations¶
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(window->get_render(), "acron-model");
Load the Animation¶
window->load_model(actor, "acron-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("acron_soft", true);
// loop all animations
anim_collection.loop_all(true);
// play an animation once:
anim_collection.play("acron_soft");
// pose
anim_collection.pose("acron_soft", 5);
to display names of loaded animations you could use:
for (int n = 0; n < anim_controls.get_num_anims(); ++n) {
std::cerr << anim_controls.get_anim_name(n) << std::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.