testTrackPos->interpolate(animationLocalTime, resultPos);
CQuat resultQuat;
testTrackQuat->interpolate(animationLocalTime, resultQuat);
* Build a matrix:
CMatrix mt;
mt.identity();
mt.setRot (resultQuat);
mt.setPos (resultPos);
* Transform the local animation matrix in the world with the world matrix
"where the animation cycle started".
CMatrix mtWhereAnimationStarted;
CMatrix finalCharacterMt = mtWhereAnimationStarted * mt;
* Set the skeleton's world matrix
skeleton->setMatrix (finalCharacterMt);
* When the animation cycle ends, reset the mtWhereAnimationStarted matrix
and start a new animation cycle.
if (animationLocalTime >= animationLength)
{
mtWhereAnimationStarted = finalCharacterMt
animationLocalTime = 0;
}
else
{
animationLocalTime += elapsedTime;
}
This code should move your character in world space with a local
space animation.
2) Now, you have to setup the "detailed animations" system. The "detailed
animations" are evaluated automatically by the NeL engine if the instance is
visible. "Detailed animations" are bones animations, material
animations...
First, create an animation set. (UScene::createAnimationSet()).
Then, add all your animations you need for your character into it.
(UAnimationSet::addAnimation()).
Once it is done, build the animation set (UAnimationSet::build()).
You have an animation set ready to use with a play list.
Create a playlist manager (UScene::createPlayListManager()).
Create a playlist for your character (UPlayListManager::createPlayList(),
use one playlist by character).
Get your animation id (uint walkId =
UAnimationSet::getAnimationIdByName("walk")).
At the begin of each animation cycle, setup your playlist:
PlayList->setAnimation (0, walkId);
PlayList->setTimeOrigin (0, currentTime);
At each frame, animate the playlists
PlayListMngr->animate
(currentTime);