Multiple Animation problem on .X file

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
yocc

Multiple Animation problem on .X file

Post by yocc »

I made .x file that contains two animations.
They are "walk" and "jump". "walk" has more frames than "jump".

I loaded that AnimatedMesh, and tried to play these animations.

then.. "walk" animation was right. But "jump" animation was incorrect.
Probably "walk" animation was played after "jump" animation.


And I set current animation to "jump" with IAnimatedMeshX::setCurrentAnimation("jump"),
and read framecount with IAnimatedMeshX::getFrameCount().

But IAnimatedMeshX::getFrameCount() returns framecount of "walk", not "jump".


I think IAnimatedMeshX must have framecount property each animationset.


P.S.: Sorry for my broken English cos I am Japanese.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Yep, sorry, multiple animations are not supported currently in .x files.
Cristian

Post by Cristian »

Here's a workaround:
Use a base frame and develop all your motions around it.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

This problem rises up again :P
yocc wrote: But IAnimatedMeshX::getFrameCount() returns framecount of "walk", not "jump".

I think IAnimatedMeshX must have framecount property each animationset.
That is because in CAnimatedMeshSceneNode.cpp framecount is calculated by mesh->getFramecount(); But this does not work properly for .X files with multyple animations. So, you will get frame count for you first AnimationSet.
niko wrote:Yep, sorry, multiple animations are not supported currently in .x files.
I just taked a look n sources and found that multiple animations are upported in CXAnimationPlayer, but something is mising.

So, these classes are involved:
- IAnimatedMeshX
- CXAnimationPlayer /Implementation of IAnimatedMeshX/
- CAnimatedMeshSceneNode
- CXFileReader

As I wrote CXAnimationPlayer supports multiple animations. CAnimatedMeshSceneNode::render() function takes a mesh from CXAnimationPlayer class by its
getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop)function,
but gives it wrong endFrameLoop parameter. This parameter must be different for different animation sets.

I wrote one solution:
1. In file CXFileReader.h define an function for get number of frames of any frameset:

Code: Select all

    //! returns number of frames in an AnimationSet by etcaptor
    s32 getFramesNumber(s32 animationSet, s32 animation=0, s32 key=0);
2. In file CXFileReader.cpp we make a definition of this function:

Code: Select all

//! returns number of frames in an AnimationSet by etcaptor
s32 CXFileReader::getFramesNumber(s32 animationSet, s32 animation, s32 key )
{
    return  AnimationSets[animationSet].Animations[animation].Keys[key].numberOfKeys;
}
3. In file CXAnimationPlayer.cpp we must calculate number of frames for current selected animation:

Code: Select all

//! animates the skeleton based on the animation data
void CXAnimationPlayer::animateSkeleton()
....
....
        LastAnimationTime = Reader->getFramesNumber(CurrentAnimationSet) -1; //by etcaptor

	}


	// update all joints
...
4. In file CAnimatedMeshSceneNode.cpp we use right frame number for current selected animation of the XMesh:

Code: Select all

//! renders the node.
void CAnimatedMeshSceneNode::render()
...
...
	s32 frame = getFrameNr();

    //! by etcaptor
    if (Mesh->getMeshType() == EAMT_X)
    {
        EndFrame = ((IAnimatedMeshX*)Mesh)->getFrameCount();
    }
...
That is all. Now multiple animations must work.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
drac_gd
Posts: 132
Joined: Sun Apr 09, 2006 8:43 pm

Post by drac_gd »

many thanks ecaptor.. Just what I needed. :)
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Well, but still another problem stays open:
If you apply animation to any X mesh, this animation will be applied to all nodes sharing this mesh by mesh cashe :?
I saw that this dissadventage does not affects md2 nodes, so will try to find any issue.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
Post Reply