entity animations

DeFT 2K6

20-08-2006 09:20:14

Hi, I'm having a little trouble with animating my character. I've set up my character in a class that contains an entity. and I initialize my animation class with that entity, but when I play the animation the character only animates for about 1 or 2 frames of the animation and then stops. When I try to switch into another animation the same thing happens. Has anyone had this happen or knows if i am approaching this wrong?

Thx, ciao.

M@gg!

20-08-2006 09:41:13

You'll have to continiusly increase the animation state like this:

Call of the method in a frame listener (in our case in the keyboard frame listener):

mPlayer->getAnim()->animate(evt.timeSinceLastFrame * mAnimSpeed, 1);

Our animation Class:

Anim::Anim(Ogre::String name, Ogre::SceneManager* SceneManager)
{
mName = name;
mSceneManager = SceneManager;
mStates = mSceneManager->getEntity(mName)->getAllAnimationStates();
if (mSceneManager->getEntity(mName)->getMesh()->getName()== "robot.mesh")
{
mStates->getAnimationState("Walk")->setLoop(true);
mStates->getAnimationState("Walk")->setEnabled(true);
mStates->getAnimationState("Shoot")->setLoop(true);
mStates->getAnimationState("Shoot")->setEnabled(true);
mStates->getAnimationState("Slump")->setLoop(true);
mStates->getAnimationState("Slump")->setEnabled(true);
mStates->getAnimationState("Idle")->setLoop(true);
mStates->getAnimationState("Idle")->setEnabled(true);
mStates->getAnimationState("Die")->setEnabled(true);
}
}

void Anim::animate(Ogre::Real offset, int button)
{
if (mSceneManager->getEntity(mName)->getMesh()->getName() == "robot.mesh")
{
switch (button)
{
case (1):
mStates->getAnimationState("Walk")->addTime(offset);
break;
case (2):
mStates->getAnimationState("Walk")->addTime(-offset);
break;
case (3):
mStates->getAnimationState("Shoot")->addTime(offset);
break;
case (4):
mStates->getAnimationState("Idle")->addTime(offset);
break;
case (5):
mStates->getAnimationState("Slump")->addTime(offset);
break;
case (6):
mStates->getAnimationState("Die")->addTime((mStates->getAnimationState("Die")->getLength())- 0.1f);
break;
}
}
}


(This code is not written by my self and far from ready)

DeFT 2K6

20-08-2006 19:21:37


You'll have to continiusly increase the animation state like this:

Call of the method in a frame listener (in our case in the keyboard frame listener):


Thx M@gg! - I created a function to add time to my animations and then put it in the frame listener and it worked perfectly. My animation class is pretty different from yours as I'm also managing (well trying anyway) seamless transitions between animations.

Ciao.

GraphicalGuy

29-08-2006 19:19:54

hey,

I was browsing the forums and trying to find if there was any topics on how to blend (as seamlessly as possible) between different animationStates for an entity. I could not find any documentation regarding this. Any help would be appreciated.
-GraphicalGuy

M@gg!

29-08-2006 20:39:31

Sry, I have just a very litle of knowledge about it.

Have you search in the Ogre Main Forum?

Try to search for:

Animation States

GraphicalGuy

07-09-2006 00:44:19

Thanks !!! That was very useful.