|
MD2 interpolation
Hi there!
I have an MD2Player class which has the following members:
Render();
Update(DWORD milliseconds);
inside the render function there is:
where mInterpolation should be between 0 and 1.
How do get the correct mInterpolation value in Update(milliseconds), where milliseconds is the time passed is the time taken to do one frame??? I can''t get my head round it at the moment!
Hi,
The key factor here is knowing what rate your model has been animated at... I think md2's are at 15fps or sumfin (check it out somewhere).
You use this to determine how much time will elapse between each frame:
timePerFrame = 1000 / animFPS;
So, based on 15fps animation, there is 66.66666... milliseconds between frames. In order to get your interpolation value (0 to 1), you simply divide the time passed by the time per frame:
mInterpolation = milliseconds / timePerFrame;
One thing to note is that if this yields > 1.0 (ie, you have a very shit frame rate
), then you need to step the current frame on for the number of times you can subtract 1 (eg 2.34... step on 2 frames, and interpolate with 0.34)
Now, simplifying (and massively speeding up) this calculation just requires some substitution:
mInterpolation = milliseconds / (1000 / animFPS);
mInterpolation = milliseconds * (animFPS / 1000);
... and of course the time per frame (animFPS / 1000) can be pre-calculated when you load your model (it won't be changing during execution... i expect).
Well, hope that was helpful
(damn... now I really know I'm avoiding work
)
Edited by - Bad Monkey on July 12, 2001 9:35:30 PM
The key factor here is knowing what rate your model has been animated at... I think md2's are at 15fps or sumfin (check it out somewhere).
You use this to determine how much time will elapse between each frame:
timePerFrame = 1000 / animFPS;
So, based on 15fps animation, there is 66.66666... milliseconds between frames. In order to get your interpolation value (0 to 1), you simply divide the time passed by the time per frame:
mInterpolation = milliseconds / timePerFrame;
One thing to note is that if this yields > 1.0 (ie, you have a very shit frame rate

Now, simplifying (and massively speeding up) this calculation just requires some substitution:
mInterpolation = milliseconds / (1000 / animFPS);
mInterpolation = milliseconds * (animFPS / 1000);
... and of course the time per frame (animFPS / 1000) can be pre-calculated when you load your model (it won't be changing during execution... i expect).
Well, hope that was helpful

(damn... now I really know I'm avoiding work

Edited by - Bad Monkey on July 12, 2001 9:35:30 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement