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.
Multiple Animation problem on .X file
This problem rises up again
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:
2. In file CXFileReader.cpp we make a definition of this function:
3. In file CXAnimationPlayer.cpp we must calculate number of frames for current selected animation:
4. In file CAnimatedMeshSceneNode.cpp we use right frame number for current selected animation of the XMesh:
That is all. Now multiple animations must work.
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.yocc wrote: But IAnimatedMeshX::getFrameCount() returns framecount of "walk", not "jump".
I think IAnimatedMeshX must have framecount property each animationset.
I just taked a look n sources and found that multiple animations are upported in CXAnimationPlayer, but something is mising.niko wrote:Yep, sorry, multiple animations are not supported currently in .x files.
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);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;
}Code: Select all
//! animates the skeleton based on the animation data
void CXAnimationPlayer::animateSkeleton()
....
....
LastAnimationTime = Reader->getFramesNumber(CurrentAnimationSet) -1; //by etcaptor
}
// update all joints
...
Code: Select all
//! renders the node.
void CAnimatedMeshSceneNode::render()
...
...
s32 frame = getFrameNr();
//! by etcaptor
if (Mesh->getMeshType() == EAMT_X)
{
EndFrame = ((IAnimatedMeshX*)Mesh)->getFrameCount();
}
...

