CS 450/550 -- Fall Quarter 2024

Project #2

100 Points

Due: October 15

Animate a Helicopter!


This page was last updated: October 11, 2024


Introduction

This project is to animate a helicopter and look at it in two different 3D views.

Requirements:

  1. Draw a helicopter. (Don't worry -- this won't be as hard as it sounds.)

  2. The helicopter's 2 blades must be scaled properly.
    The helicopter's 2 blades must be oriented properly.
    The helicopter's 2 blades must be rotating properly.

  3. Allow two views: an "Outside" view of the entire scene and an "Inside" view from the helicopter cockpit. Toggle between them with a pop-up menu. (You can also use keyboard hits, but in-addition-to, not instead-of.) For each view, use a different call to gluLookAt( ) to position the eye. A good eye poition for your Inside View is (-0.4, 1.8, -4.9) . A good look-at position for your Inside View is (-0.4, 1.8, -10.) .

    Note: you need to call gluLookAt( ) once and only once.

  4. Keep the same Xrot, Yrot, and Scale features as we've used before, but only in the Outside View. Do not use Xrot, Yrot, and Scale in the Inside View, just in the Outside View.

  5. Use the graphics programming strategy where the Display( ) function looks at a collection of global variables and draws the scene correctly. The other parts of the program simply set the global variables and post a redisplay. So, for example, you probably want to create a variable called something like NowView to decide which version of gluLookAt( ) gets called.

  6. Use gluPerspective( ), not glOrtho( ).

  7. Put some sort of 3D scene for your Inside Eye to see while looking outside the helicopter (off in the -Z direction). One or more GLUT wireframe objects might work well. Or, whatever you did in the first project. Or some sort of colored grid. Or, all of these things.

  8. The code for creating the helicopter geometry is shown below in the Geometry section. The helicopter body extends along the Z axis. The heicopter cockpit points in -Z.

  9. There must be two blades drawn on the helicopter body: a large blade on the roof, oriented in the X-Z plane, and a small one on the tail, oriented in the Y-Z plane. Create a single blade display list and then transform and instance it twice to get the two blades in the scene. The code for creating the single blade geometry is shown below in the Geometry section. The single blade is in the X-Y plane, centered at (0.,0.,0.), with a radius of 1.0.

  10. The top helicopter blade is to have a final radius of 5.0 and be attached at: (0.,2.9,-2.).
    The rear helicopter blade is to have a final radius of 3.0 and be attached at: (.5,2.5,9.).

  11. Both blades need to rotate. The rotation rate is up to you, but the smaller one must rotate twice as fast as the larger one. That is, for whatever amount you advance the rotation the large blade's rotation angle, advance the small blade's rotation angle 2X that amount.

  12. Pay close attention to the overall transformation sequence. You can re-use some of the transformations that you have already created by using glPushMatrix( ) and glPopMatrix( ).

  13. Parameterize your scene as much as you can with #define's or const's, It makes it easier to make changes later.

Positioning Everything:

Supplying the Geometry

Getting Started:

Not sure where to start? Read on!

  1. Draw the helicopter at the origin.

  2. Draw at least one other scene element somewhere out along -Z. This is where the Inside View will be looking.

  3. Start by using the stationary Outside View to view the scene. Give gluLookAt( ) some good values.

    Play with these so that when your program starts up, your are seeing the helicopter and your whole scene from a good angle.

  4. Pay careful attention to:

  5. After that works, designate Animate( ) as the Idle Function in InitGraphics( ). Have a global variable, say BladeAngle, that gets incremented in Animate( ). Use that variable in glRotatef( ) calls in Display( ) to rotate the blades. Be sure that Animate( ) posts a re-display.

  6. An even better way to do the animation is to put these two lines up in the global variables:
    float Time;
    #define MS_IN_THE_ANIMATION_CYCLE	10000
    
    and put this code in Animate( ):
    int ms = glutGet( GLUT_ELAPSED_TIME );	// milliseconds
    ms  %=  MS_IN_THE_ANIMATION_CYCLE;
    Time = (float)ms  /  (float)MS_IN_THE_ANIMATION_CYCLE;        // [ 0., 1. )
    

    where MS_IN_THE_ANIMATION_CYCLE is how many milliseconds are in the animation cycle. (10000 ms = 10 seconds, in this case.) This sets Time to be between 0. and 1., which you can then use to set animation parameters in the Display( ) function. For example:
    glRotatef( 360.*Time,   . . . );
    
    The advantage of this is that you will get the same number of milliseconds in the animation cycle regardless of how fast or slow the CPU you run this on is.

  7. After that works, add the Inside View by testing what view mode you are in and then using a different call to gluLookAt( ). Don't use Xrot, Yrot, and Scale if you are in the Inside Mode. (You can control this with an if-statement.)

Those Vector-Manipulation Functions

The lighting of the helicopter surfaces use two functions, Cross( ) and Unit( ). They are in your sample code already.

A Debugging Suggestion:

Turn-in:

Use Canvas to turn in:

  1. Your .cpp file
  2. A short PDF report containing:

  3. To see how to turn these files in to Canvas, go to our Project Notes noteset, and go the the slide labeled How to Turn In a Project on Canvas.

  4. Be sure that your video's permissions are set to unlisted.. The best place to set this is on the OSU Media Server.

  5. A good way to test your video's permissions is to ask a friend to try to open the same video link that you are giving us.

  6. The video doesn't have to be made with Kaltura. Any similar tool will do.

Grading:

FeaturePoints
Correctly draw the helicopter body15
Correctly scale the blades20
Correctly position the blades20
Correctly rotate the blades20
Recognizable Inside View25
Potential Total100