[SOLVED] vertex animations work, but rot & trans don't?

marc_antoine

03-12-2008 16:30:46

i exported 2 boxes from max

Box01 has a rotation and translation animation

Box02 has a manual vertex animation (no modifiers, no morpher no nothing)


the .OSM file was generated just fine if i open the .OSM in notepad i can see only the rotation and translation keyframes of Box01 but nothing for Box02, which i think it's weird but thought maybe that vertex aniamtion info is binary coded in the .mesh file so i moved on.

Loaded the model and i did this:

AnimationState *as=mSceneManager()->getEntity("Box02")->getAnimationState("expandir");
as->setEnabled(true);
as->setLoop(false);

then every FrameEvent
as->addTime(evt.timeSinceLastFrame+0.25);



well that animated the vertex animated Box so i tryed to do the same with the Box01 (the one with rotation & translation animation) but i get an error saying entity is not animable


so the question is how should i play oFusion animations?
how can i trigger different animationstates with the keyboard?
animation states that has rotation & translation animation and that have an animation name can be retrieved by name?.

... thanks in advance..

Lioric

05-12-2008 03:05:41

Node animation (as the animation of the Box01) is used via the scene manager, not via the entity (only skeletal, morph and pose animations via the entity)

Use the sceneMgr->getAnimation methods

Search this forums for more details on using node or rigid animations, or see the oSceneLoader demo application for more details, or use this to animation all scene node animations each frame


SceneManager::AnimationIterator animationIt = mSceneMgr->getAnimationIterator();

while(animationIt.hasMoreElements()) {
Animation* animation = animationIt.getNext();

const Animation::NodeTrackList& trackList = animation->_getNodeTrackList();

Animation::NodeTrackList::const_iterator it = trackList.begin();
Animation::NodeTrackList::const_iterator iend = trackList.end();

for(; it != iend; ++it) {
const Ogre::NodeAnimationTrack* track = it->second;
track->getAssociatedNode()->resetToInitialState();
}

currentTime += evt.timeSinceLastFrame;
animation->apply(currentTime);
}

marc_antoine

06-12-2008 06:38:13

indeed, tanks Lioric,i have been playing with the code and i see that i can get the animation with an animation name too, but different to and AnimatinoState, a node aimation doesn't have a method that rturns when an animation has finshed, it is imoprtant becouse i don't want the animation to be looped so i tryed his:



if(currentTime<=animation->getLength())
{
Animation::NodeTrackList::const_iterator it = trackList.begin();
Animation::NodeTrackList::const_iterator iend = trackList.end();
for(; it != iend; ++it)
{
const Ogre::NodeAnimationTrack* track = it->second;
track->getAssociatedNode()->resetToInitialState();
}
currentTime += timeOffset_;
animation->apply(currentTime);
}


what this code does is to do a node animation that goe from frame 0 -> frame 80 in 3dsMax, so then when i press another key, first i change the animation name and load an animation that goes from frame 80-> frame 160; what i notice is that the animtion does a little jump like if the secon animation is running from from 85->160 is ther a more ccurate way to stop applying a nwe time in order to avoid looping and the animation jumpig from imation1 to animtion 2?

Lioric

10-12-2008 23:50:20

There is no need to manually control an animation if you dont want to, use the "SceneManager::createAnimationState" method to create an animation state object that will be automatically handled by the system


AnimationState* nodeAnimationState = mSceneMgr->createAnimationState("theNameOfAnExistingNodeAnimation");

nodeAnimationState->setEnabled(true);
nodeAnimationState->setLoop(false);


// In your frame update method (frame listener):
nodeAnimationState->addTime(evt.timeSinceLastFrame);



That is all you need to automatically update animations as needed in your application, create as many animation state objects, and enable or disable them as needed in your application

marc_antoine

12-12-2008 04:00:07

Lioric, you are at the top of my list for christmas presents, :)thank you .. now i will update the subject with a [SOLVED] label :D :!: