How To Use The New Animation System

This tutorial will show you how to use the new animation system in Irrlicht 1.4+

Note: this only applies with bone based formats i.e. a mesh of type EAMT_SKINNED. At the time of writing this is: B3D, ms3d, and X.

Transitions

Transitions are for blending from one animation into another. E.g. when a characters stops running, instead of just jumping to an idle animation, if you use a transition it will blend the animations together and make it look natural.

To use it, call:

Node->setTransitionTime (TimeOfBlendInSeconds);

Joint control will automatically be enabled (the blending needs it), so you must also call:

Node->animateJoints();

Before the drawAll

Joint control

Joint control lets you move bones around in the mesh in realtime.

First call:

Node->setJointMode(irr::core::EJUOR_CONTROL); // To write positions to the mesh on render

just after loading your mesh.

(irr::scene::EJUOR_CONTROL for later releases)

To get bones by name:

IBoneSceneNode* Head = Node->getJointNode("Head");

or to get them by number, call Node->getJointCount() to find out how many there are, then call Node->getJointNode(X) to get each numbered bone.

Now if you also want your mesh to animate using any built-in animation in the model, call:

Node->animateJoints();

In your game loop, before drawAll().

Then move the bones after optionally calling animateJoints() (so that's it's not overwritten by the built-in animation). You move them like any other scene node, eg:

Head->setPosition(core::vector3df(1,2,3));
Head->setRotation(core::vector3df(3,2,1));

Ragdolls

Setup the node:

node->setJointMode(irr::core::EJUOR_CONTROL); // EJUOR_CONTROL is 2 in 1.4
node->setRenderFromIdentity(true); // This causes the meshes transformation to be ignored in drawing

You should have your ragdoll setup in your physics engine, now for each joint that you want to be connected with a physics object, call:

joint->setSkinningSpace(irr::scene::EBSS_GLOBAL);

on them, so you can just set them to the same position and rotation of your physics object in global space. (I would have like a better nicer method for this, but I couldn't see a way without forcing the meshes to animate every frame.)

(TODO: Please add a sample here)