CSC 240: Computer Graphics

Lab 11: Robotic Arm (Hierarchical Models in OpenGL)

The goal of this lab is to practice using hierarchical models (using push and pop matrix) in OpenGL.

Note: this lab will not be graded, but it will help us get ready for the solar system homework.

  1. Download lab11.py and make sure you can run
    python lab11.py 
    You should see a box that looks something like this:

    robot1

    This will become the upper part of the robot arm. To make it look more like an arm, add a scaling transform to the

     wireBox(width, height, depth) 
    method to make it look like the figure below:

    robot2
  2. Use rotate and translate transformations to make this upper arm look like it's rotating from the shoulder (shoulder should be at the origin). The rotations should occur when the up and down arrow are pressed (already implemented). Using these keys, you should be able to rotate the upper arm 90 deg, as shown below:

    robot3

  3. Now we are ready for the lower arm! Uncomment the second wirebox call. What happens? Maybe you get a picture like this:

    robot4
  4. Why does it look like it's scaled again? Use push and pop to fix this problem, and translate to move the lower arm to the correct position:

    robot5

  5. Finally, rotate the lower arm using the elbowAngle variable, so that when the left and right keys are pressed, the lower arm rotates:

    robot6
BONUS: comment out the push and pop commands at the start and end of display. How does that change things? Why are they necessary?