CSC 240: Computer Graphics

Homework 4: Clipping and OpenGL animations

Due: Thursday, Oct. 15, 11:59pm on Moodle

The goal of this homework is to practice line clipping and become familiar with how transformations work in OpenGL to create animations.

Part I: Line Clipping (5 pts)

Instructions here: hw4.pdf. You can hand this part in on paper or on Moodle.

Part II: OpenGL 2D Animations (10 pts)

For this part, we will be building upon Lab 6 to create a shape and make it move in a figure eight.

  1. Download hw4.py (minor changes from Lab 6). Replace the current white square in the "my_shape()" method with a shape of your choice, but it must use either GL_QUAD_STRIP, GL_TRIANGLE_STRIP, or GL_TRIANGLE_FAN.
  2. Use glColor to make some of the vertices different colors to achieve the color-blending we saw in Lab 6.

  3. Add transformation matrices to the matrix stack to make your shape move in a figure eight. We'll use the same transformations as in Homework 3, but now we don't need to define matrices! Use at least 2 of the following transformations:

    • Rotate
       glRotate(angle,x,y,z) 
      where the angle is in degrees and (x,y,z) denotes the vector around which to rotate.
    • Translate
       glTranslate(tx,ty,tz) 
      where tx, ty, and tz are the amount to move in each direction.
    • Scale
       glScale(ax,ay,az) 
      were ax ,ay, and az are the scaling factors in each dimension.
  4. Save your code and submit it online on Moodle. If there is anything special I need to do to run your animation (commandline options, etc), put notes about it that will show up if I run:
     python hw4.py 

COLLABORATION:

For this assignment, you are welcome to work together, but everyone should turn in their own math/code that they have written and understood. Please cite anyone you worked with at the top of your assignment.

EXTRA CREDIT OPTIONS:

  • Give your shape some static (i.e. not moving) context. Example: a bee flying around a flower. (+1)
  • Make a second shape that is moving in a different way as the first shape. (+2)