PDA

View Full Version : Basic Animation



02-28-2001, 05:25 AM
Hi,

I'm using Glut and....

I'm trying to do some basic animation:
I have a cube and I would like it to
move smoothly upwards,
then once there move right;
then move back down to the original height;
finally it should move back to it's starting position.


X----------X
| |
| |
X----------X

I must be really thick as I cannot see how to use the idlefunction to do
this, all I manage is to get it to move upwards slowly to a certain point
then I cannot get to to come down again, as I'm fighting against the
idlefunction.....

ideas??


thanks

Greg

chennes
02-28-2001, 05:59 AM
The idea that immediately comes to mind is a case statement:



switch(direction){
case up: translate up some more; break;
case left: translate left some more; break;
case down: translate down some more; break;
case right: translate right some more; break;
}


Put it in your idle function, and have a counter that switches your direction at the correct points.

Chris

Bob
02-28-2001, 06:23 AM
... and after that, in the idle-function, you place glutPostRedisplay() to tell GLUT that you want to redraw the screen.