|
From: | Cyril 'Hulud' Corvazier |
Subject: | Re: [Nel] animation problem |
Date: | Tue, 2 Mar 2004 17:40:30 +0100 |
Hi Andi,
>NL3D::UAnimation *testAnimation =
CAnimationManager::instance().AnimationSet->getAnimation(0);
>NL3D::UTrack *testTrack = testAnimation->getTrackByName("pos"); 1) At each frame, you must provide final instance positions to NeL. So you
have to know where your characters are placed. In Ryzom,
the character loop looks like that :
* First look at the animation tracks for the root node. Evaluate the
position / rotation tracks :
NL3D::UTrack *testTrackPos = testAnimation->getTrackByName("pos");
NL3D::UTrack *testTrackQuat =
testAnimation->getTrackByName("rotquat");
CVector resultPos;
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); Your character should be animated.
Happy hacking,
Hld.
----- Original Message -----
|
[Prev in Thread] | Current Thread | [Next in Thread] |