Time Difference

Hi,
I have a problem regarding the glutTimerFunc().

I have two different object a sphere and a cube. All I want is to animate those two objects in different scale.

I am moving Sphere from top-left of the screen to bottom-right of the screen and spinning it’s coordinates too. Now there is another object that is cube which only spins on the center of the coordinate in the origin of the window.

I want to spin that cube at an interval of 500ms., and move the sphere every 1 sec for 4 times from top to bottom and bottom to top.

My question is: How do i implement this with two glutTimerFunc()? I am using glutTimerFunc(500, SpinCube, 1) and glutTimerFunc(250, MoveSphere, 1). Is it valid to use to different Timer Function? If not how to implement it?

More over I want to generate 2 random number of the coordinates to display another sphere at a random location with every 2000ms. I am calling this function too and i guess i need another timer function to generate random number and displaying the sphere.

My code is something like:

void main(void)
{


glutTimerFunc(10, SpinCube, 1);
glutTimerFunc(10, MoveSphere, 1);
glutTimerFunc(10, RandomSphere, 1);



}

SpinCube(int value)
{
…Manipulation


glutPostRedisplay();
glutTimerFunc(500, SpinCube, 1);
}

MoveSphere(int value)
{
…Manipulation


glutPostRedisplay();
glutTimerFunc(250, MoveSphere, 1);
}

RandomSphere(int value)
{
…Manipulation


glutPostRedisplay();
glutTimerFunc(2000, RandomSphere, 1);
}

void Display(void)
{

glutSwapBuffers();
}

So how to call each and every timer in different point of time? more over what is the value of the 3 argument in glutTimerFunc() implies?

Please help me out, I am doing a small project and I need to implement that.

thanx
regards

I have never used it for multiple timers but here is an exampe of how it works

glutTimerFunc( 10, My_timer_call , 1)
glutTimerFunc( 20, My_timer_call , 2)
glutTimerFunc( 30, My_timer_call , 3)
glutTimerFunc( 40, My_timer_call , 4)

void My_timer_call( int timer )
{

if ( timer == 1)
{
// Timer 1 done do something
glutTimerFunc( 10, My_timer_call, 1);
}

if ( timer == 2) // Timer 2 done do something

if ( timer == 3) // Timer 3 done do something

if ( timer == 4) // Timer 4 done do something

}

Now here is how I do timing for diffrent objects with glutTimerFunc

void My_timer_func( int timer )
{
// I have assigned a varaible for each object
// Each timer call I reduce the variable.

my_object[x].time–;
if (my_object[x].time == 0 )
{
update_object( x );
my_object[x].time = my_object[x].speed; // Speed is the update value to subtact from each pass of the timer.
}

glutTimerFunc( 10, My_timer_func, 1);
}

You could use 1 timer function and check for each object, if the required amount of time has passes. If so then update the locations.

Or you could do away with timers altogether.
In the idle function check the amount of time passed and move the objects the correct amount based on their velocity.

This method is called Euler (or something) and is the preferred method for moving forward with your programs.

It’s possible I’m talking cr4p.

[This message has been edited by Pops (edited 03-20-2003).]