Homework 3

 

Write a program that allows interactive manipulation of the position and orientation of a camera.
Draw a teapot at the global origin 0,0,0.
You can find a shaded teapot model and source code teapot_glut.c.

Initially, the camera is at 0,0,10 looking down the -z axis (looking at the origin 0,0,0).

 

The main objective of  this homework is to manipulate the position and orientation of the camera. The position of the camera is restricted to be on the surface of  a virtual sphere with the radius of 10. So you can imagine a teapot at the origin, and a camera on a surrounding sphere pointing at the teapot.

There are two camera manipulation instruction, elevation and swing. In elevation mode, the camera should be elevated on the surface of the sphere while maintaining  the look-at point at the origin. The range of elevation on the surface of a sphere is between -90 and 90 degree.  Use mouse motion function to implement the user interaction. Users should be able to elevate the camera by dragging mouse upward. 

In swing mode, the camera should be moved sideways on the surface of the sphere while maintaining  the look-at point at the origin. Use mouse motion function to implement the user interaction. Users should be able to swing the camera by dragging mouse sideways. Note that during the swing operation, the elevation level should be preserved and the camera should not tilt sideways.   

Using a pull-down menu, a user should be able to toggle between grid view on and off.
Quit menu will terminate the program.

For the menu opertation using GLUT, refer to the sample code menu.c

Here's the working binary files in windows format. You have to have glut library installed to used this program.