Animation Redisplaying

Hi,
I am running some sort of simulation. in which i am generated some spheres in random co-ordinates. later i am doing some transformation with that sphere by adjusting the radius and translating to different place.
When then time moves by i am generating another sphere in new location. The location is found using some random number generation of the coordinates.

I’m calling a TimerFunc() of every 33ms. When the number of frames increases the number of spheres also increased and the animation of particular sphere is done in every frame.

I am calling RenderScene() callback function to display this.

When i use the glutSwapBuffers() r glutPostRedisplay(), I’m losing the previous sphere which was already displayed and animated.

PROBLEM:
How to retain those spheres with respect to frame rate, Lets say 30fps. If i am running this simulation the sphere has to appear with respect to time and the animation of eat frame has to take place subsequently, i.e., any animation on the sphere.

Please help me how to solve this situation.

regards
Riaz.

Originally posted by ajmrm:

How to retain those spheres with respect to frame rate, Lets say 30fps. If i am running this simulation the sphere has to appear with respect to time and the animation of eat frame has to take place subsequently, i.e., any animation on the sphere.

Hi

its quite simple. Just use the time difference between 2 frames as the base for your movement.
If you for example want to move a sphere you should do following:

newpos = oldpos+ velocity*deltatime

So your objects will move frame rate independent. If the framerate is low, object will make large jumps, whithe a nice framerate they will me smooth animated.
Perhaps you’ll need a more precise time counter , on Win32 its QueryPerformanceCounter.

Bye
ScottManDeath