Computer Graphics Lab 6: 3-D Viewing Pipeline

Ben Mitchell and Zach Pezzementi

Lab Description

In this lab, we extended our transformation library to be fully 3-D and implemented a viewing transformation function, and integrated it with our hierarchical modeling system.

In order to do a perspective projection, one must first define the viewpoint. The location where the virtual camera is placed is called the view reference point (VRP). The direction the camera is pointing is the view projection normal (VPN). Then a vector perpendicular to the VPN defines which direction will be considered "up" (VUP). Finally, the center of projection (COP) is the point through which all rays are projected in order to generate the perspective. To be physically meaningful, the COP should be place along the VPN in the negative direction.

Once the viewpoint is defined, the actual projection is just a series of matrix multiplications. First, the origin is translated to the VRP, and an orthonormal basis u, v is generated from VUP and VPN. Next, the origin is rotated to this basis, and then translated to the COP. If the COP is not along the VPN, a shear in z is done here to align them. Then the field of view (between the front and back planes) is scaled to the canonical view volume (CVV), which is defined as x = [-1, 1], y = [-1, 1], z = [0, 1]. Finally, we project onto the image plane using a perspective projection matrix, which is a function of d, the ratio of the z-distance between the COP and VRP in the CVV and the z-distance between the VRP and the back viewplane. To finish up, the appropriate reflections and translations are done to move to whatever image format is desired.

We demonstrate our perspective projection with a unit cube. First we have a single image of a view of the cube (COP) from the point (0.5, 0.5, -4) with the VRP at (0.5, 0.5, -2) and a view window size of (du, dv) = (1, 1).


Here is a small version without anti-aliasing.


And here is a larger one with anti-aliasing.

We then extended our view of the cube by rotating it about two axes simultaneously and generated this nifty "tumbling cube" animation:


The cube! It tumbles!

Lab Questions

1. What are the (x,y) values for the eight corners of the cube in the first required image?

(0, 0, 0) goes to (50, 50)
(0, 0, 1) goes to (60, 60)
(1, 0, 1) goes to (140, 60)
(1, 0, 0) goes to (150, 50)
(0, 1, 0) goes to (50, 150)
(0, 1, 1) goes to (60, 140)
(1, 1, 1) goes to (140, 140)
(1, 1, 0) goes to (150, 150)

2. How does modifying the distance between the COP and the VRP affect the appearance of the cube in the first required image?

Modifying this distance changes the height of the cone of projection, producing an effect similar to a zoom. Pulling the COP back is effectively zooming in. This analogy loses physical meaning once the COP moves in front of the VRP though, as demonstrated below:


The cop moves from a distance of 10 behind the VRP to 1.5 in front of it and back.

3. How does modifying the direction of VUP modify the appearance of the cube in the first required image?

Modifying VUP changes the direction of the y-axis in model space, effectively rotating the scene in image space.

4. How does modifying the size of the view window modify the appearance of the cube in the first required image?

Making the view window larger makes the cube appear smaller and vice versa.

5. What extensions did you do for this assignment, how did you do them, and how well did they work?

Since we used our hierarchical modeling system to generate all our images, we created a 3D primitive of a cube in the process. We also generated the nifty animations above. As one can see from the animations, our system is capable of dealing with arbitrary vectors as parameterization of the view, including the COP. Below is an illustration of what happens when one moves the COP out of alignment with the VRP.


The COP is always behind the VRP but translates along lines in a clock-wise manner.