The first change that was made to the graphics system to accomodate 3D operations was the addition of
3D transformation functions. The following transforms are now supported:
All of these transforms have been adapted to work in the hierarchical modeling environment created in
the last lab.
3D Perspective Viewing Pipeline
Two main changed were made to accomodate a 3D perspective viewing pipeline. First, a new structure
was created to hold all of the parameters that describe a 3D view. These parameters are:
d -- Projection Distance
The second change involved creating a function to perform the appropriate transformations for a
perspective projection. The steps are as follows (taken from Bruce Maxwell's lab 6 homepage):
1. Translate the VRP to the origin: VTM = T(- vrp.x, - vrp.y, - vrp.z).
2. Align the coordinate axes:
o
3. Translate the COP (represented by the projection distance) to the origin: VTM = T(0, 0, d) * VTM.
4. Scale to the canonical view volume [CVV]:
o
Let B = B + d.
Let d = d / B.
6. Scale to the image size: VTM = Scale( - screenX / (2 * d), - screenY / (2 * d), 1.0) * VTM.
7. Translate the lower left corner to the origin: VTM = T(screenX/2, screenY/2) * VTM.
Required Images
There were two required images for this lab. Both contain a cube with opposite corners at (0, 0, 0) and
(1, 1, 1). The first image is 100x100. The COP is located at (0.5, 0.5, -4), the VRP is located at (0.5, 0.5, -2),
and the view window size is (du, dv) = (1, 1). This image can be seen below.
The second required image is of the same cube, but this time it is viewed with 3-point perspective.
Extensions
Several extensions were implemented. First, three animated gifs were created to demonstrate the new
3D perspective viewing pipeline. The first of these images performs a "drive-by" by moving in the x
direction across the world.
The next image is an animated gif as the view moves around the cube in an elliptical orbit. The VPN is
always pointed at the center of the cube.
Finally, the third image alters the value of d linearly and then sets du = dv = 2d/(d+2). This is similar to
changing from a wide angle to a telephoto lens on a camera. Casey insists that I use the word "nontrivial" to describe this transformation.
The second extension that we performed was to make all of our code operational within our hierarchical
modeling system. Now, all of the 3D transforms and 3D perspective viewing can be using within
modules. All of our extensions worked properly.