Asg 2: Rotate the camera in 3D perspective

Objectives

Set up a Camera object (class) that contains the camera's pos (position), ref (refernce point), and vup (vertical tilt), where each of these three are 3D vectors (a numpy.array). Provide GLUT callbacks to rotate the camera.

Assignment

  1. Use the gldraw.py program as the starting point, which allows reading in of Alias Wavefront .obj files.
  2. Create a Camera object that contains the following data objects:
  3. Set up keyboard callbacks that adjust the camera position and reference to rotate the camera
  4. Suggested key bindings (if you use different ones, provide a USAGE file):

Details

  1. Your OpenGL code should set up a projection matrix with gluPerspective(90,1.0,1.0,1000.0)
  2. Your OpenGL code should just use an identity matrix for the modelview matrix, i.e., glLoadIdentity()
  3. Initialize the camera position, reference point, and tilt vector and use them as arguments to gluLookAt(), starting with:
  4. Set up keyboard callbacks so that, depending on the key pressed, e.g., j to pitch down, the camera object is called so that "the camera rotates itself", e.g., the_camera.pitch(-10.0);.
  5. The camera object can be made global, e.g., declared as global the_camera at the top of gldraw.py just like global points.
  6. For camera rotations, take a look at these basic rotations expressed in matrix form. You will probably need to write these out in long form to change to position of the camera's reference point with respect to the camera's position or to use numpy.array matrices (easier).

Requirements

  1. When you rotate the camera (e.g., pitch), it should eventually make a full 360 degree rotation.
  2. Test your rotation code with the camera in place, e.g., don't translate the camera before testing rotation.

Turn in

Turn in all of your code, in one tar.gz archive of your asg##/ directory, including:
  1. A README file containing
    1. Course id--section no
    2. Name
    3. Brief solution description (e.g., program design, description of algorithm, etc., however appropriate).
    4. Lessons learned, identified interesting features of your program
    5. Any special usage instructions
  2. source code (.py source)

How to hand in

See handin web page

Grading scheme