CMSC 435/634: Computer Graphics

Lab 5: 3D Perspective Viewing

Due November 15, 2000



Purpose:

To implement 3D perspective viewing transformations. This project involves implementation of 3D clipping, viewing transformations, and back face removal.

The Assignment

This lab will extend your previous work  to 3D perspective viewing.

Your program should follow these specifications: When started, the program displays a window with menu buttons displayed on the bottom, looking something like the example in the figure, except that you need a "TRANSLATE XYZ button" and your buttons will be at the bottom.

When the user clicks the left mouse button on one of the menu buttons the following action will take place:

Input
The program asks the user for a file name and then reads the data from the file. The scene is transformed via 3D viewing transformation matrices into viewing coordinates, clipped to the viewing volume, and displayed to the screen in perspective view.
BackFaces On/Off
Turns the display of backfaces on or off.
Rotation Increment
prompts the user to enter an integer in [-360 ...0..360] to serve as rotational increment called RotInc..
Rotate
every time the mouse is clicked on X, calculate the rotation about X by RotInc degrees (and the same for Y and Z).
Scale
every time the mouse is clicked on X, calculate the scale 1.25 in X, similarly for Y, and Z.
TRANSLATE
every time the mouse is clicked on X, calculate the translation in X by 2.0, similarly for Y, and Z.
Reset
Clear all, reset RotInc to its default value and redraw the object in its original orientation.
Write PPM
Writes a PPM file of the image.
Exit
Exit the program.



 

 

The format of the data file is a gemoetry file name followed  by  the specification of the viewing parameters:

VRP VPN VUP COP hither yon window light

Where VRP VPN VUP COP and light are triplets of real numbers, window is a quadruple of real numbers corresponding towu_min, wu_max, wv_min, wv_max, and hither and yon are one real number each. The light parameters will be used for extra credit. VPN and VUP are vectors and VRP and COP are points. ALL OF THEM ARE DEFINED IN TERMS OF THE XYZ COORDINATES, in which the object is defined. hither and yon are defined in terms of uvn coordinates (remember that hither and yon are offsets from the view plane in the n axis.) VPN corresponds to n axis and v is the projection of VUP onto the view plane. uvn forms a right-handed system. window is also defined in terms of the uvn coordinate and it lies in the view plane. window is defined relative to COP. Remember to normalize VPN for uvn computation.

An example input file is easy.dat:
 

/afs.umbc.edu/users/e/b/ebert/home/cs435/435_data/easy.det
0 0 0    0.0 0.0 1.0  0.0 1.0 0.0  0 0 50    0  -10    -2 2 -1 1        100.0 100.0 100.0
|-VRP-| |--VPN------| |--VUP----| |---COP-|  hith yon  |- window--|    |------Light----|

The geometry file name has the following format:

               DET_CODE         (4 bytes)
               num_pnts (n)        (2 bytes short)
               num_polys (m)      (2 bytes short)

               p1x p1y p1z          (4 4 4 bytes float)
                 .....

               pnx pny pnz         (4 4 4 bytes float)

               poly1-num_pnts (k)  (2 bytes short)
               poly1-pnt1          (2 bytes short - array index begins at 1, i.e. pnts:  1  4  2)
               ...
               poly1-pntk          (2 bytes short)
                 .....

               polym-num_pnts (j)  (2 bytes short)
               polym-pnt1          (2 bytes short)
                 ....
               polym-pntj          (2 bytes short)

An example for a cube is the following:

data 8 6
        -0.5          0.5          0.5
         0.5          0.5          0.5
         0.5         -0.5          0.5
        -0.5         -0.5          0.5
        -0.5          0.5         -0.5
         0.5          0.5         -0.5
         0.5         -0.5         -0.5
        -0.5         -0.5         -0.5
4            1     2     3     4
4            5     6     2     1
4            8     7     6     5
4            4     3     7     8
4            2     6     7     3
4            5     1     4     8
 


The program  ~ebert/asc -a will print out a ".det" data file for viewing as ascii
 

Sample input files are located in ~ebert/cs435/435_data/*.dat
A large number of binary data files, ".det", are located in /usr/local/edge/data

Comments


Submit your assignment as 'lab5'. Your comments should include the environment (hardware and software) that you used to develop your program. To facilitate grading, your program should run properly on irix.gl, regardless of the system used for development. Include all necessary files and makefiles.


Main Page | Syllabus | Class Calendar

Course Assignments & Handouts | Links | Reading List