Append skeletal animation to the loaded model
Append skeletal animation to the loaded model
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.
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.
Re: Append skeletal animation to the loaded model
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
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Append skeletal animation to the loaded model
Thenk you, i'm try this method today =)
Re: Append skeletal animation to the loaded model
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
Animation changing very not smooth. How i can make animation changeing smooth
Re: Append skeletal animation to the loaded model
You could use:
Node->setTransitionTime (TimeOfBlendInSeconds);
This will blend between the current animation and the next one.
Node->setTransitionTime (TimeOfBlendInSeconds);
This will blend between the current animation and the next one.
Re: Append skeletal animation to the loaded model
I'm try use setTransitionTime, but not working.
I also used the following code, but it not working:
In both cases model is freezes. What is wrong?
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);
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);
Re: Append skeletal animation to the loaded model
Transition time is in seconds, 5.5 seconds is maybe a bit long?
Also, do you call before ?
Also, do you call
Code: Select all
Node->animateJoints();Code: Select all
smgr->drawAll();Re: Append skeletal animation to the loaded model
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.
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.
Re: Append skeletal animation to the loaded model
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
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);

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.

What should I do to avoid such problems?
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
*/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);

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.

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
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.
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.
