This page was last updated: September 6, 2023
This project is about performing a keytime animation. You will be the Senior Animator and will choose key values to use in your animation. The computer will be the Grunt Animator and will fill in interpolated values in between your key values.
When you are done with this assignment, you will understand how to get your scene's objects to move in ways that you get to control, without having to write any equations or do any physics.
Make the animation last 10 seconds. At time=10 seconds, bring each quantity back to its original time=0. value
The smooth interpolation technique that you will be using employs the Coons cubic curve (end points and end slopes). But, rather than you having to specify all of the slopes, the technique makes a reasonable approximation of them based on the surrounding keytime information.
The methods for the Keytimes class are:
void AddTimeValue( float time, float value );
float GetFirstTime( );
float GetLastTime( );
int GetNumKeytimes( );
float GetValue( float time );
void Init( );
void PrintTimeValues( );
Set the values like this:
// a defined value:
const int MSEC = 10000; // 10000 milliseconds = 10 seconds
// a global:
Keytimes Xpos1;
// in InitGraphics( ):
Xpos1.Init( );
Xpos1.AddTimeValue( 0.0, 0.000 );
Xpos1.AddTimeValue( 0.5, 2.718 );
Xpos1.AddTimeValue( 2.0, 0.333 );
Xpos1.AddTimeValue( 5.0, 3.142 );
Xpos1.AddTimeValue( 8.0, 2.718 );
Xpos1.AddTimeValue( 10.0, 0.000 );
// in Animate( ):
glutSetWindow( MainWindow );
glutPostRedisplay( );
// in Display( ):
// turn # msec into the cycle ( 0 - MSEC-1 ):
int msec = glutGet( GLUT_ELAPSED_TIME ) % MSEC;
// turn that into a time in seconds:
float nowTime = (float)msec / 1000.;
glPushMatrix( );
glTranslatef( Xpos1.GetValue( nowTime ), 0., 0. );
glRotatef( 0., 1., 0., 0. );
glRotatef( 0., 0., 1., 0. );
glRotatef( 0., 0., 0., 1. );
<< draw object #1 >>
glPopMatrix( );
bool Frozen;Set Frozen to false in Reset( ). Then, freezing the animation is just a matter is setting the Idle Function to NULL. To un-freeze it, set the Idle Function back to Animate( ). So, in the Keyboard( ) callback, you could say something like:
case 'f': case 'F': Frozen = ! Frozen; if( Frozen ) glutIdleFunc( NULL ); else glutIdleFunc( Animate ); break;
Do the same keytime process (8 quantities, 6 keytimes each) with a second object. Make it look like it is somehow "involved" with the first object.
Use the Teach system to turn in:
Item | Points |
Animation lasted 10 seconds | 10 |
Scene used OpenGL lighting | 10 |
Light source-related animation quantity | 10 |
View-related animation quantity | 10 |
Position/orientation/scale animation quantity | 20 |
Color-related animation quantity | 20 |
The four own-choice animation quantities | 20 |
Extra Credit | 10 |
Potential Total | 110 |
If you do the Extra Credit, be sure you sufficiently document what you did in your PDF report and make it obvious what you did in your video!