MD2 Animation bug

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
MessiaH
Posts: 55
Joined: Tue Jul 06, 2004 6:37 pm
Location: RUSSIA

MD2 Animation bug

Post by MessiaH »

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?!
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Seems to be a bug. :)
MessiaH
Posts: 55
Joined: Tue Jul 06, 2004 6:37 pm
Location: RUSSIA

MD2 Animation bug

Post by MessiaH »

Another question.
:roll: Have You ever tried to use "->setFrameLoop(stFr,enFr);" with MD2's?!
I have tried->again not the thing i expected!!! :x :x :x
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

HMMMM...

Code: Select all

//! sets the current frame. from now on the animation is played from this frame.
void CAnimatedMeshSceneNode::setCurrentFrame(s32 frame)
{
}
Maybe it's just me, but something looks suspicious. :wink:


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;
}
Hopefully, that'll at least get my point across even if the code isn't right. :wink: Of course, the desired frame has to be within StartFrame and EndFrame.
Post Reply