multiple meshes with same animation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
happyer
Posts: 17
Joined: Wed Aug 15, 2007 2:07 pm

multiple meshes with same animation

Post by happyer »

I have meshes, say
mesh1 = (irr::scene::IAnimatedMeshX*) smgr->getMesh("monster.x");
mesh2 = (irr::scene::IAnimatedMeshX*) smgr->getMesh("monster.x");

but when i set only one of them to have animation,
mesh1->setCurrentAnimation("jump");

both of them will do the same animation.

I have searched the forum, the only solution that I can find is making two separate copies of .x file.

However, if I am going to make 100 monsters, I have to make 100 copies? Or if I am not sure about the number of monsters that I really want make, how do I know I need to make how many copies?

I don't know is there any other method to solve the problem, or just my program problem? Could anyone help me please?
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Hi. Not sure, but the .X file format don't have the "named" thing for animations. If your .X animated mesh have animation, you would have to define a range of frame with setFrameLoop(). Otherwise, if you only have 1 animation per .X file, you would have to load them individually and replace the mesh for each animated sequence.

You would have to check those function from the SDK under the:
irr::scene::IAnimatedMeshSceneNode Class Reference

Code: Select all

virtual s32  getEndFrame () const =0 
                   Returns the current end frame number. 
virtual f32  getFrameNr () const =0 
              Returns the current displayed frame number. 
virtual void  setAnimationEndCallback (IAnimationEndCallBack *callback=0)=0 
virtual void  setCurrentFrame (f32 frame)=0 
virtual void  setAnimationSpeed (f32 framesPerSecond)=0 
virtual bool  setFrameLoop (s32 begin, s32 end)=0 
virtual void  setLoopMode (bool playAnimationLooped)=0 
virtual void  setTransitionTime (f32 Time)=0 
happyer
Posts: 17
Joined: Wed Aug 15, 2007 2:07 pm

Post by happyer »

My mesh contain multiple animation, namely walk, jump, hit.....

and I usually use
mesh1->setCurrentAnimation("jump");
mesh2->setCurrentAnimation("hit");

I have tested the frame number by using
sceneNode1 = smgr->addAnimatedMeshSceneNode(mesh1);
while (true)
printf("%i\n",sceneNode1->getFrameNr());

Seems that for every type of animation, their frame number are same,
ie. for jump, I may get from 0 to 600
for hit, I may get from 0 to 400

Therefore, I think setting of mesh->setCurrentAnimation() will control the type of animation, and setting of scenenode->setFrameLoop() will control the animation from when to when.
I don't know is this the problem of the .x file format. Since I have seen other people post, and they said that the animation is look like, from 0 to 600 is jump, and 601 to 1000 is hit....
Post Reply