Hi all,
I’m doing a test where I’m trying to load and play animations on an actor from a c++ function that is called in python as a module. While everything appears to be loaded properly, the animation does not play or loop when prompted. Here’s the c++:
class mainGameLoopA{
PUBLISHED:
void test_loading_model_and_actor(NodePath sent_render)
{
Loader* loader = Loader::get_global_ptr();
// Load a model synchronously
PT(PandaNode) model_node = loader->load_sync("./samples/roaming-ralph/models/ralph");
NodePath actor(model_node);
actor.reparent_to(sent_render);
PT(PandaNode) anim_node = loader->load_sync("./samples/roaming-ralph/models/ralph-walk");
NodePath anim_np(anim_node);
anim_np.reparent_to(actor);
AnimControlCollection anim_controls;
auto_bind(model_node, anim_controls);
string loaded_anim;
cout<<"anims: "<<anim_controls.get_num_anims()<<"\n";
loaded_anim=anim_controls.get_anim_name(0);
//actor.play(loaded_anim);
cout<<"ANIM-NAME?: "<<loaded_anim<<"\n";
anim_controls.loop(loaded_anim, true);
if(actor.find("**/+Character").is_empty())
cout<<"EMPTY, NO JOINTS??\n";
else
cout<<"NOT EMPTY, HAS JOINTS??\n";
}
}
And on the python side:
testGMLP=genModule.mainGameLoopA()
testGMLP.test_loading_model_and_actor(render)
What could the problem be? After loading and binding animations, how would I ensure they play when prompted from the python side?
EDIT:
It turns out, I can’t even pose the actor at a certain frame like so:
anim_controls.pose(loaded_anim, sent_frame_pos);
Yet calling this shows that frames indeed have been loaded:
int num_frames=anim_controls.get_num_frames(loaded_anim);
cout<<"nf?: "<<num_frames<<"\n";//Output is 25...
So it’s rather confusing. Why isn’t the model being animated or updated at all? Did I bind things incorrectly? Is there something else missing?
Thanks in advance.