CS 4204: Computer Graphics

 

Announcements & syllabus

Schedule

Programming assignments

Homework

Exams

Courseware

Programming Assignment 1: Simple 2D Animation

Summary

You will write an openGL / GLUT program that will allow the user to interactively specify and play back a simple key framed animation in 2D. In a key framed animation, the user specifies several "snapshots" (or key frames), and the system smoothly interpolates between them. This program will allow you to demonstrate you skill in using 2D drawing, transformation, and user interface features of openGL and GLUT.

Due Date

The assignment is due on Wednesday Feb. 20 at 11:59 PM. The standard late policy for programs is in effect.

Required Features

  • The program should open a single window of at least 500x500 pixels with a plain white background to start.
  • At the bottom of the window, create a subwindow of at least 50 pixels in height, where you will display text information. This text should initially be:
    • Mode display: "Editing objects"
    • Total time display: "Total animation time: 5 seconds"
    • Elapsed time display: "Elapsed time: 0 seconds"
  • In the main (upper) subwindow:
    • The user may left click on an object to select it.
    • When an object is selected, draw a gray border around it.
    • When an object is selected, the user may drag it to a new location while holding down the left mouse button.
  • In a pop-up menu activated with the right mouse button, provide the following menu items:
    • New object (creates a 20x20 pixel black square centered at the position of the click – this option is only available when in editing objects mode)
    • Delete (deletes selected object - this option is only available when in objects mode)
    • Change edit mode (cycles between modes: "Editing objects," "Editing key frame #1," ... "Editing key frame #5")
    • Play animation (plays the animation using the initial state specified in the editing objects mode and the 5 key frames specified by the user, over the total time specified by the user)
    • Total time (submenu with the following items)
      • Increase (increases the total time by 1 second)
      • Decrease (decreases the total time by 1 second)
    • Transform (submenu with the following items)
      • Rotate + (rotate the selected object by +5 degrees)
      • Rotate – (rotate the selected object by -5 degrees)
      • XScale + (scale the selected object by +10% in the x direction)
      • XScale – (scale the selected object by -10% in the x direction)
      • YScale + (scale the selected object by +10% in the y direction)
      • YScale – (scale the selected object by -10% in the y direction)
    • Color (submenu with the following items - these options are only available when in editing objects mode)
      • Red (change color of selected object to red)
      • Blue (change color of selected object to blue)
      • Green (change color of selected object to green)
      • Black (change color of selected object to black)
  • When animation playback is done, return to editing objects mode.
  • Update the total time display when the user chooses the increase or decrease menu items.
  • Update the elapsed time display when the user switches to a different key frame (display the starting time of that key frame; e.g., if the total time is 10 seconds and the user switches to key frame #3, the elapsed time would be 6 seconds), or when the user plays the animation (update the elapsed time continuously until playback is done.
  • Think of the editing objects mode as key frame #0. That is, in this mode you set the initial positions/orientations/scales/colors of each object. The elapsed time is 0 seconds in editing objects mode. Think of key frame #5 as the final state of the animation.
  • When the user switches to a new key frame for the first time, set the position/orientation/scale of each object to its position/orientation/scale in the previous key frame.
  • During animation playback, interpolate object positions, orientations, and sizes smoothly from one key frame to the next. You may use a fixed frame rate; i.e., update the display every tenth of a second, so that there are 10 frames in each second of animation.

Optional Features (for bonus points)

  • Allow direct manipulation of object rotation and scale via handles on the selected object.
  • Allow an unlimited number of key frames, instead of only five.
  • Allow users to create/delete objects in any key frame, and make these objects appear/disappear as appropriate during the animation.
  • Allow users to change object color in any key frame, and interpolate the color of the objects appropriately during the animation.

Submission

Turn in your program via email to the TA. You may either submit a single source file or a ZIP archive of several source/header files. You may also optionally include a plain text README file if you wish.