Timing Animated Models

Blitz3D Forums/Blitz3D Programming/Timing Animated Models

Makepool(Posted 2004) [#1]
Okay, I’m trying to figure out a method of keeping a model animated at a constant speed despite varying frame rates. The ‘Animate’ command seems to move the animation onto the very next frame regardless of the time since the last frame. This means that the animation will play through slower if the frame rate drops.

What I really want to be able to do is have the model animate according to delta time and I’ve come up with the idea of using ‘SetAnimTime’ to do this, however this has a huge drawback. I also need to be able to smoothly transition between two animations as is possible with the ‘Animate’ command but know no other way of achieving this without using ‘Animate’

Has anybody else encountered this and come up with a solution?


TomToad(Posted 2004) [#2]
i haven't dealt with animations in 3D yet, but I've done it with 2D. Basically, I decide how many milliseconds per frame there are in the animation. So 30 frames/sec would equal 33.3333 millisec/frame, round off to 33. Then I set a time for animation start before the main loop.

anim_start_time = millisecs()

Then in the main loop I can calculate which frame the animation should be on.

anim_time = millisecs() - anim_start_time
frame = (anim_time/33) mod num_frames


You could use the same method for 3D, but looking through the Blitz3D help, I can't find any reference on how to have Blitz display a particular frame of an animation. Only for stopping and starting automatic animation.


jhocking(Posted 2004) [#3]
Use the optional anim_speed parameter of UpdateWorld. This parameter controls how much to change the animation since the last time UpdateWorld was called.


jfk EO-11110(Posted 2004) [#4]
Like jhocking said, use UpdateWorld(t#)

t# is a value that is calculated from the current framerate:

ms#=millisecs()
fps#=1000.0/(ms-ms2)
ms2=ms
t#=60.0/fps
updateworld(t#)

now you can set the speed with the animate command, and it will be adjusted for any framerate.


Makepool(Posted 2004) [#5]
Thanks people, I was completely unaware that you could pass a parameter into UpdateWorld to affect model's framerate. Now that I know that I should be able to do something with it.