Hints for Assignment 6: Perspective Projections and Stereo Viewing
You need to modify only four classes - Matrix, CSLIDECamera, CBound, CSLIDEFace
Class Matrix
Complete the 'SetPerspectiveWarp' and 'SetPerspectiveWarpInverse'
functions.
i.e., you need to construct the Qwarp_norm matrix as described in:
http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/projection.shtml
If you don't understand how the Qwarp_norm matrix is created, don't
worry too
much about it. For purposes of this assignment, you simply need to plug
in the appropriate variables to construct it.
For the exams,
you'll be asked only to use the Qwarp_norm (i.e. not to deduce how that
matrix came about).
Class CSLIDECamera
Complete CalculateProjectionMatrix() to add perspective projection. The
provided code performs parallel projection for both perspective
and parallel; you need to split up the cases.
Remember: for parallel projection, the projection matrix is a
combination of a scale, a
translate and a shear (see the provided code for this).
For perspective projection, you must combine a warp (the perspective
warp above), a scale (to construct a normalized frustum) and a shear
(to align the DOP with the negative Z axis for oblique projections).
Class CBound
For purposes of efficiency and numerical robustness, we must minimize
the amount of homogenizing points - this reduces the number of floating
point divisions, which, as you know, are evil. So, we homogenize at the
last possible step (i.e. before rendering).
This means we can no longer assume that the point will be homogenized
when this
function is called. So, we must modify the InHalf and Intercept
functions to account for the homogeneous coordinate.
You need to add minimal amounts of code to InHalf() and Intercept.
See http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/projection.shtml#intercept
for the exact homogeneous factor.
As mentioned above, we homogenize just before rendering any point. So,
add the appropriate command in the Render function of this class.
Class CSLIDEFace
The only (minimal) change to this function is to homogenize the points
prior to rendering them. So, add the appropriate command in the Render
function of this class.
Note - you don't need to add anything to RenderNormal()!