[SOLVED] Multiple animations for one model issue

I’m trying to load three animations for one model but since the bundle name within the egg file is the same for the three of them (it corresponds with the model name) and Panda3D seems to load them in a different [and random] order each time I can’t seem to identify them in runtime.

I’m using Panda3D 1.72 and Chicken Exporter R91. I’m loading the anims this way:

window->load_model(mc_actor, "mc_test_02-walk");
window->load_model(mc_actor, "mc_test_02-run");
window->load_model(mc_actor, "mc_test_02-jump");
auto_bind(mc_actor.node(), anim_collection);

where mc_actor is a NodePath.

Within the egg file, my test model is called Armature and the animations (which are stored in different files) get named Armature, Armature.1 and Armature.2 after I auto_bind them to my character. The problem is Armature.1, for instance, does not necessarily represent the same animation each time I run the game.

As far as I can tell from the date of other similar posts this is an old issue but nobody has ever given a clear solution.

I would really REALLY appreaciate any kind of help. Thanx in advance!

A possible solution is to auto_bind() each of your animation into an empty AnimControlCollection and to move them into your definitive AnimControlCollection with the name you want:

   AnimControlCollection tempCollection;
   NodePath animNp1 = window->load_model(mc_actor, "mc_test_02-walk");
   auto_bind(mc_actor.node(), tempCollection);
   PT(AnimControl) animPtr = tempCollection.get_anim(0);
   anim_collection.store_anim(animPtr, "Armature");
   string animName = tempCollection.get_anim_name(0);

   NodePath animNp2 = window->load_model(mc_actor, "mc_test_02-run");
   auto_bind(mc_actor.node(), tempCollection);
   animPtr = tempCollection.get_anim(0);
   anim_collection.store_anim(animPtr, "Armature.1");
   animName = tempCollection.get_anim_name(0);

   NodePath animNp3 = window->load_model(mc_actor, "mc_test_02-jump");
   auto_bind(mc_actor.node(), tempCollection);
   animPtr = tempCollection.get_anim(0);
   anim_collection.store_anim(animPtr, "Armature.2");


Unless mc_actor had any animations attached to it before to the first call to load_model(), you should get what you want.

I’ve written a tentative implementation for the general case here, filed under `p3util/cActor.cpp’:
While this implementation works in the tutorials, I never bothered to test it fully so you can assume it is bugged :blush:
Caveat emptor!

dri, I can’t tell you how grateful I am. IT WORKS!

One thing I don’t understand is the purpose of reparenting animNp1 and 1 to mc_actor.


What could you need them for after loading the animations?

Thank you so so much. I can finally move on.

I guess I just wanted to respect the original code behavior. I found that workaround by trials and errors; I haven’t looked under the hood of auto_bind() yet :wink: But you are right, the animations seem ok even if I remove_node() animNp1 and 2. At least in the Boxing Robots tutorial.

Yes, it seems to work just the same without the reparenting.

Thanks again, dri. I’m back on track! :smiley: