Hmm. It seems it isn’t such a good idea after all.
Check this dump I produced using
string AddAnimation(WindowFramework *window,NodePath parent,AnimControlCollection &anims,string AnimationFilename)
{
window->load_model(parent,AnimationFilename);
auto_bind(parent.node(), anims,PartGroup::HMF_ok_part_extra | PartGroup::HMF_ok_anim_extra | PartGroup::HMF_ok_wrong_root_name);
int CurrentAnim=anims.get_num_anims()-1; // subtract 1; zero based index
int AmountOfFrames=anims.get_anim(CurrentAnim)->get_num_frames();
string AnimName=anims.get_anim_name(CurrentAnim);
printf("Added animation [%s],wich contains %d frames.\n",AnimName.c_str(),AmountOfFrames);
printf("The amount of animations in the AnimControlCollection is now %d.\n",CurrentAnim);
return(anims.get_anim_name(CurrentAnim) ); // return generated anim name ( character.x )
}
and
map <int,string> Animation;
int CurrentAnimation=0;
#define HEADING_N 0
#define HEADING_NE 1
#define HEADING_E 2
#define HEADING_SE 3
#define HEADING_S 4
#define HEADING_SW 5
#define HEADING_W 6
#define HEADING_NW 7
Animation[CurrentAnimation++]=AddAnimation(win_ptr,ralph,ralph_anims,"players/Animations/Walking/WalkEasy_N.egg");
Animation[CurrentAnimation++]=AddAnimation(win_ptr,ralph,ralph_anims,"players/Animations/Walking/WalkEasy_NE.egg");
Animation[CurrentAnimation++]=AddAnimation(win_ptr,ralph,ralph_anims,"players/Animations/Walking/WalkEasy_E.egg");
Animation[CurrentAnimation++]=AddAnimation(win_ptr,ralph,ralph_anims,"players/Animations/Walking/WalkEasy_SE.egg");
Animation[CurrentAnimation++]=AddAnimation(win_ptr,ralph,ralph_anims,"players/Animations/Walking/WalkEasy_S.egg");
Animation[CurrentAnimation++]=AddAnimation(win_ptr,ralph,ralph_anims,"players/Animations/Walking/WalkEasy_SW.egg");
Animation[CurrentAnimation++]=AddAnimation(win_ptr,ralph,ralph_anims,"players/Animations/Walking/WalkEasy_W.egg");
Animation[CurrentAnimation++]=AddAnimation(win_ptr,ralph,ralph_anims,"players/Animations/Walking/WalkEasy_NW.egg");
Dump:
Added animation [character],wich contains 32 frames.
The amount of animations in the AnimControlCollection is now 0.
Added animation [character.2],wich contains 32 frames.
The amount of animations in the AnimControlCollection is now 2.
Added animation [character.5],wich contains 32 frames.
The amount of animations in the AnimControlCollection is now 5.
Added animation [character.9],wich contains 29 frames.
The amount of animations in the AnimControlCollection is now 9.
Added animation [character.14],wich contains 29 frames.
The amount of animations in the AnimControlCollection is now 14.
Added animation [character.20],wich contains 29 frames.
The amount of animations in the AnimControlCollection is now 20.
Added animation [character.27],wich contains 29 frames.
The amount of animations in the AnimControlCollection is now 27.
Added animation [character.35],wich contains 29 frames.
The amount of animations in the AnimControlCollection is now 35.
Press any key to continue . . .
So, instead of adding only the new animation, it adds the previous ones PLUS the new one.
Nice way to grow a list, I must say
This needs more investigation. To be continued. 