Animations are not being loaded

Hello,

I am trying to extend the tutorial with a small model created in blender. The model get loaded and rendered, but there are no animations to play. If I call pview from command line it shows no animations but if called from the chicken exporter (inside blender) plays animations nicely.

(I used the tag code on the console output as it does not change the identation)

I did the following in c++

NodePath dummy = window->load_model(framework.get_models(), "./Models/Dummy/Dummy");
dummy.reparent_to(window->get_render());
dummy.ls(std::cout, 4);

This gave the console output:

    ModelRoot Dummy.egg T:(pos 0 10 0 scale 0.2)
      PandaNode 
        Character Armature
          GeomNode  (1 geoms: S:(MaterialAttrib TextureAttrib TransparencyAttrib))
        AnimBundleNode Kick
        AnimBundleNode Punch

So I think that the animations are exported correctly, but the code continues:

AnimControlCollection dummy_anims;
int ret;
auto_bind(dummy.node(), dummy_anims, 0);
ret=dummy_anims.get_num_anims();
std::cout << "Loaded " << ret << " animations!" << std::endl;

printing the following to stdout:

Loaded 0 animations!

and the final lines does not animate the model:

dummy_anims.loop("Punch",true);
window->loop_animations(0);
// Run the engine.
framework.main_loop();
// Shut down the engine when done.
framework.close_framework();
return (0);

I am expecting that the call to auto_bind would populate the AnimControlCollection, but found put that no animation was bind to the model. Am I doing something wrong?

Thank you.

I was able to bind the animations with

auto_bind(dummy.node(), dummy_anims, ~0);

Can someone clarify me what is that flag passed as final argument to auto_bind. The default value would be zero from the auto_bind.h header, but there are posts with the ~0 as argument and it did the job.

At last I found out that to get individual animations to work as I select I need to do:

int animnum=2; //Select a valid animation index
dummy_animation = dummy_anims.get_anim(animnum);
mystring = dummy_anims.get_anim_name(animnum);
std::cout << "Got anim named >" << mystring << "<" <<std::endl;
if (dummy_animation->has_anim()){
  std::cout << "Animation Node is OK!!!" << std::endl;
}
else{
  std::cout << "Animation Node is BAD!!!" << std::endl;
}
dummy_anims.loop(mystring.c_str(),true);

I was even able to add a few more animations and got they working very well. Panda3d seens pretty easy and fun to work, although there are some things not clear to me.

Thank you.

The third parameter to auto_bind() controls how forgiving the matching of animation to model should be. With 0, the default, it is important that all of your joint names (and the character name) be the same between animation and model. With ~0, as forgiving as possible, it will work even if some of your names do not match.

David

Thank you, I was able to get a single animation working also in pview. It took me some time to figure it out, maybe I got the wrong thinking paradigm for it.
So, lets say, if I want to create a model with many animations in a single .egg (or .bam) file and let my C++ code load the model and pick a animation, by its name, to play, then do I always have to pass ~0 as flag value?

You should assign the same character name to the model and all of its intended animations. The purpose of the character name is to indicate which skeleton the animation is intended to be used with.

This is not the same name as the animation name, which can be different for each animation, without requiring ~0.

David