Append skeletal animation to the loaded model

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
caffeine
Posts: 7
Joined: Sun Mar 11, 2012 12:39 pm

Append skeletal animation to the loaded model

Post by caffeine »

Hello Sorry for my English, I use a translator from Google.

I load the model with a skeleton, but without the animation from *. X file. I need to Append to loaded multiple skeletal animations and include any of them to the previously loaded model.

How can I do?

I will be grateful if you datite me links to the answers.

Thanks in advance.
CuteAlien
Admin
Posts: 10036
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Append skeletal animation to the loaded model

Post by CuteAlien »

Take a look at ISkinnedMesh: http://irrlicht.sourceforge.net/docu/cl ... _mesh.html
The function you will need is useAnimationFrom.
If you want independent animations for more than one node you also have to copy the mesh, there's some (old) thread about that, which might give you the ideas: http://irrlicht.sourceforge.net/forum/v ... 1&start=15
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
caffeine
Posts: 7
Joined: Sun Mar 11, 2012 12:39 pm

Re: Append skeletal animation to the loaded model

Post by caffeine »

Thenk you, i'm try this method today =)
caffeine
Posts: 7
Joined: Sun Mar 11, 2012 12:39 pm

Re: Append skeletal animation to the loaded model

Post by caffeine »

CuteAlien, I using your method, but i can't set change animation smooth.

Animation changing very not smooth. How i can make animation changeing smooth
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: Append skeletal animation to the loaded model

Post by ACE247 »

You could use:

Node->setTransitionTime (TimeOfBlendInSeconds);

This will blend between the current animation and the next one.
caffeine
Posts: 7
Joined: Sun Mar 11, 2012 12:39 pm

Re: Append skeletal animation to the loaded model

Post by caffeine »

I'm try use setTransitionTime, but not working.

Code: Select all

 
irr::scene::IAnimatedMeshSceneNode*node;
irr::scene::ISkinnedMesh*model;
 
model->setInterpolationMode(irr::scene::EIM_LINEAR);
node->setTransitionTime(5.5f);
node->setJointMode(irr::scene::EJUOR_READ);
node->animateJoints(true);
 
model->useAnimationFrom(a);
node->setAnimationSpeed(30.f);
node->setFrameLoop(0,60);
node->setCurrentFrame(0.f);
node->setLoopMode(true);
 
I also used the following code, but it not working:

Code: Select all

 
irr::scene::IAnimatedMeshSceneNode*node;
irr::scene::ISkinnedMesh*model;
 
node->setTransitionTime(5.5f);
node->animateJoints(true);
 
model->useAnimationFrom(a);
node->setAnimationSpeed(30.f);
node->setFrameLoop(0,60);
node->setCurrentFrame(0.f);
node->setLoopMode(true);
 
In both cases model is freezes. What is wrong?
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: Append skeletal animation to the loaded model

Post by ACE247 »

Transition time is in seconds, 5.5 seconds is maybe a bit long?
Also, do you call

Code: Select all

Node->animateJoints();
before

Code: Select all

smgr->drawAll();
?
caffeine
Posts: 7
Joined: Sun Mar 11, 2012 12:39 pm

Re: Append skeletal animation to the loaded model

Post by caffeine »

I set 0.1 instead 0.5. The result was idetntichny.

now I try call anytime before call smgr->drawAll(), and it almoust work:
loaded for some reason, the model turned inside out, ie first external parties are internal (ie, can be seen through them), and those that were formerly internal now external (through which the inside is not visible). Secondly why is the model itself has been turned upside down.
caffeine
Posts: 7
Joined: Sun Mar 11, 2012 12:39 pm

Re: Append skeletal animation to the loaded model

Post by caffeine »

I figured out what to do turned inside out by applying the first node-> setJointMode (irr :: scene :: EJUOR_CONTROL); and then drawing each frame call node-> animateJoints (true);. The model I did in Blender and exported to *. X format. Below is the entire code and screen shots

Code: Select all

GameModel::GameModel(LivingEntity*p){
        parent=p;
        model=(irr::scene::ISkinnedMesh*)CGameDevice::g()->getSmgr()->getMesh("data/models/model.x");//load model with skeletion
        
        //animation1 and animation2 is irr::scene::ISkinnedMesh* type
        
        animation1=(irr::scene::ISkinnedMesh*)smgr->getMesh("skeletal_A1.x");//load skelet animation
        animation2=(irr::scene::ISkinnedMesh*)smgr->getMesh("skeletal_A2.x");//load skelet animation
 
        node=smgr->addAnimatedMeshSceneNode(model,((irr::scene::ISceneNode*)parent->getBody()));//create animation node
        node->setJointMode(irr::scene::EJUOR_CONTROL);//[b]!!! set join mode EJUOR_CONTROL !!![/b]
        setAnim(animation1);//setting the animation for the model
}
 
void GameModel::setAnim(irr::scene::ISkinnedMesh*a){
 
        model->useAnimationFrom(a);//set animation
 
        node->setAnimationSpeed(30.f);
        node->setFrameLoop(0,60);
        node->setCurrentFrame(0.f);
        node->setLoopMode(true);
}
 
void GameModel::onBeforeRendering(){
        node->animateJoints(true);//[b]!!! animate join on frame !!![/b]
}
/*
GameModel call on create model
setAnim call wen need set new animation
onBefireRendering call befire render frame
*/
yet I do not use light, so that the model is black.
Both screen shot taken at about the same frame of animation.

That's how it should look like. There does not use node-> setJointMode (irr :: scene :: EJUOR_CONTROL); and node-> animateJoints (true);
Image

There used and the picture looks twisted. If you look from another angle, we see that the walls of the model inverted if its normal appearance.
Image

What should I do to avoid such problems?
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Append skeletal animation to the loaded model

Post by christianclavet »

I don't see the pics, but I could at least give you some hint for your models.

Using useAnimationFrom has some restrictions that you must be aware of:
- All models need to have the SAME skeleton. Not using the same skeleton, will result in distortions and rendering errors.
- This is using the animation from another model, you CAN'T append animations. So if you have multiple animations, they need to be inside the same file.
- This will affect ALL INSTANCES of the mesh you are changing the animation, so if you have 10 monsters (using the same mesh), all their animations will be changed.

My current use of this function is to use this to create more variety of a monster/NPC, but reusing the same skeleton, but changing the shape details (Farmers, Citizens), and using the animations from the reference model, so I don't have to redo the animations for all thoses models.
Post Reply