Homework 3
22C:151 Introduction to Computer Graphics
PART I due Thursday, September 25, 2003
PART II (the full program) due Thursday, October 2, 2003
35 points
PART I REQUIREMENTS: (1) do questions 1 and 2, and (2)
get the viewing control part of the programming assignment
working properly.
You don't have to draw any objects (but you can if you want).
I only require that you draw the global coordinate frame and
have your viewing control commands working. I.e. I should
be able to swing, elevate, and zoom the camera to
look at the global coordinate frame from different places.
- An object is to be translated 7 units in direction (0,0,1)
and then rotated by 60 degrees about the (global/world) X
axis. Show the 4-by-4 transformation matrix that can be used to accomplish
this.
- Assume an object is defined with a local coordinate frame that initially
coincides with the global coordinate frame.
The object is to be rotated 30 degrees about Y axis, and then translated
(-5, 0, 0) in the direction of the object's local X axis.
- a.
- Show the 4-by-4 transformation matrix that can be used to accomplish
this.
- b.
- Show a two-line OpenGL sequence that produces the matrix
using a glRotate followed by a glTranslate.
- c.
- Show a two-line OpenGL sequence that produces the matrix
using a glTranslate followed by a glRotate.
Write an OpenGL program that allows interactive creation and movement
of lighted shaded objects, camera movement, and both orthographic and
perspective viewing projections.
As before, I won't give a detailed specification of the program,
but it must satisfy several requirements:
- it must allow creation of cubes, spheres, cones, and one
additional shape of your own choice. When created, the
objects should initially be placed at the world origin, with their
local frames coinciding with the world frame.
- it must draw a representation of a global/world frame (which is
located at the position the camera "looks at"). It should also be
able to draw representation for the local frames associated with each
object. You should make it possible to toggle frame drawing on and
off so that you can view the scene without the frames. It is easy to
draw representations for frames using lines or long thin boxes.
(Note: the frame axes should not be affected by lighting).
- it must be possible for users to translate, rotate, and scale objects.
You do not have to implement mouse-based "picking" or object selection
(which was required in Homework 2). You may simply use menus to
select the object you wish to move (or allow cycling through the
objects via a keyboard key). For translation, it should be
possible to select between translation relative to the directions of
the global axes and also relative to the current local axes. (Note
that for local translation, the local frame should remain fixed to
the object. Translation with respect to the local frame simply means
that the translation direction is defined with respect to the local frame
axes.) For rotation, you
only need to provide rotation with respect to the objects' local
frames. Additional notes: 1) you only need to provide the major
axis (x, y, andz) rotations. That is, you don't need to provide
means for rotating about a user-defined axis.
- it must be possible to move the camera to obtain different
views. At any instant, imagine that the camera is attached to the
surface of a sphere and is aimed at the world origin. Your program
must allow users to (1) "swing" the camera horizontally along
latitudinal lines of the current sphere (you could, e.g., use left and
right arrow keys for this), (2) "elevate" the camera vertically along
longitudinal lines, and (3) "zoom" the camera toward and away from the
world origin (thereby changing the radius of the sphere we imagine the
camera to be on). To implement viewpoint changes you simply need to
determine how to create the appropriate viewing transformation.
There are several possible ways, including:
1) store, at all times, a world-to-camera transformation, update
it as appropriate based on movement operations,
and load the resulting matrix onto the GL modelview stack, or 2)
use gluLookAt, if you can figure out the appropriate parameters,
or 3) store current values for swing, elevate, and zoom,
and use an appropriate combination of glRotates and glTranslates to
create the correct view. (HINT: 1 is perhaps the most interesting, 2 is perhaps
the most difficult, 3 is probably the easiest.)
- it must be possible to switch between parallel and perspective
projections.
- lighting and smooth shading and depth buffering
must be enabled so that hidden surface elimination is done and a nice
looking image will be rendered.
Submitting your program
Submit your assignment according to the guidelines on the class WWW home page. For the
on-line part of the submission, respond 'hw3part1' or 'hw3part2' to the ``Location:''
request.