This is rather strange.
When at then beginnig I write
node->setMD2AnimationType(scene::EMAT_STAND);
and then
node->setAnimationSpeed(0);
node->setCurrentFrame(197);
the animation is stopped(OK),but frame number is changed to 1,while it should be 197!
What is the problem?!
MD2 Animation bug
MD2 Animation bug
Another question.
Have You ever tried to use "->setFrameLoop(stFr,enFr);" with MD2's?!
I have tried->again not the thing i expected!!!
Have You ever tried to use "->setFrameLoop(stFr,enFr);" with MD2's?!
I have tried->again not the thing i expected!!!
HMMMM...
Maybe it's just me, but something looks suspicious.
It seems like the concept of setCurrentFrame() is sort of tricky here. Since these animations are time-dependent, what does it mean to set the current frame? Maybe this is why it's not currently implemented?
I can see two options for setCurrentFrame():
In one option, this would just override the time based animation, probably just forcing getFrameNr() to always return the set frame number.
The other option would have setCurrentFrame() essentially add an offset to getFrameNr() (in a new member variable). This would let you skip to other positions in the animation while maintaining the proper loop start position. If the animation is stopped, it'd have the effect of just switching to the desired frame. Without having tested it or even thinking about it that hard, I think something like this:
Hopefully, that'll at least get my point across even if the code isn't right. Of course, the desired frame has to be within StartFrame and EndFrame.
Code: Select all
//! sets the current frame. from now on the animation is played from this frame.
void CAnimatedMeshSceneNode::setCurrentFrame(s32 frame)
{
}
It seems like the concept of setCurrentFrame() is sort of tricky here. Since these animations are time-dependent, what does it mean to set the current frame? Maybe this is why it's not currently implemented?
I can see two options for setCurrentFrame():
In one option, this would just override the time based animation, probably just forcing getFrameNr() to always return the set frame number.
The other option would have setCurrentFrame() essentially add an offset to getFrameNr() (in a new member variable). This would let you skip to other positions in the animation while maintaining the proper loop start position. If the animation is stopped, it'd have the effect of just switching to the desired frame. Without having tested it or even thinking about it that hard, I think something like this:
Code: Select all
void CAnimatedMeshSceneNode::setCurrentFrame(s32 frame)
{
OffsetFrame = 0;
OffsetFrame = frame - getFrameNr();
}
inline s32 CAnimatedMeshSceneNode::getFrameNr()
{
s32 frame = 0;
if (EndFrame - StartFrame)
frame = StartFrame + (OffsetFrame + s32((os::Timer::getTime() - BeginFrameTime) * (FramesPerSecond/1000.0f))) % (EndFrame - StartFrame);
else
frame = StartFrame + OffsetFrame;
return frame;
}