Anda di halaman 1dari 4

3D Matrix Transformations

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:

Translate3D -- translates in all 3 dimensions

Scale3D -- scales in all 3 dimensions

Rotate3DX -- Rotates about the x-axis

Rotate3DY -- Rotates about the y-axis

Rotate3DZ -- Rotates about the z-axis

RotateZ -- Rotates about the z-axis

Rotate3DXYZ -- Rotates about the x, y, and z-axes

ShearZ -- Shears x and y

PerspProj -- Performs the matrix transform necessary for perspective projection

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:

VRP -- View Reference Point

VPN -- View Plane Normal

VUP -- View Up Vector

d -- Projection Distance

du, dv -- View Window Extent in x and y

F, B -- Front and Back Clip Planes

screenX, screenY -- desired number of pixels in image

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

Normalize the VPN and VUP.

Create UVEC = VUP x VPN.

Redo VUP' = VPN x UVEC.

VTM = RotateXYZ(UVEC, VUP', VPN) * VTM.

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.

VTM = Scale( 2 * d / (du * B), 2 * d / (dv * B), 1 / B) * VTM.

5. Project onto the image plane:


o

Let d = d / B.

VTM = PerspProj(d) * VTM.

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.

Anda mungkin juga menyukai