Graphics Reference
In-Depth Information
takes advantage of the matrix stack in computing appropriate OC-to-WC trans-
formations to load into the D3D WORLD matrix processor. In this case, we did not
define individual OC spaces for the two squares and thus M W is set to the identity
matrix at label A.
At label B, the variables that correspond to the camera parameters are initial-
ized to with values that correspond the set up from Figure 13.6. At label B1 the
D3DXMatrixLookAtRH() function uses these values to compute the matView ma-
trix. The computed matView would transform vertices from WC to EC in exactly
the same manner as discussed in Equation 14.4. In general graphics APIs support
many alternatives for specifying the camera, for example, the information convey
by look at position can be specified with a view vector; or the up vector can be
replaced with a twist angle, and so on. There are also many ways to compute the
M w 2 e matrix. However independent from the approach, the resulting matrix is
always Equation 14.4. The M w 2 e matrix encodes all information concerning the
viewing camera, and thus this matrix is also referred to as the view or the viewing
matrix. The view matrix is essentially our abstract representation for the camera.
At label C the matProj matrix is computed by the D3DXMatrixPerspective
ForRH() function. The computation is based on a viewing frustum that encloses
the two squares. The matProj serves the purpose of the M e 2 n matrix (Sec-
tion 14.6), this matrix transforms the cut-off pyramid into the NDC cube and is
also referred to as the projection matrix. As in the case of the view matrix, there
are many approaches to computing the projection matrix. However and very im-
portantly, unlike the view matrix, some of the contents of the projection matrix are
graphics API-dependent. This is due to the fact that the NDC to DC conversion
process involves graphics hardware and they can be different for implementation
efficiency reasons. For example, OpenGL defines the z range of NDC space to be:
1
z
+
1
whereas the NDC z range for D3D is
0
z
+
1
.
In this case, because of the different NDC z range, the corresponding projection
matrices are slightly different. Notice that with the same visible volume specifi-
cations, the x and y components in the matrices will be the same.
Tutorial 13.1 is a 3D computer graphics program designed to compute the
photograph of Figure 13.1 in 3D. It is interesting that when we compare the im-
plementation to that of Tutorial 3.1, a 2D computer graphics program designed to
draw squares in a 2D window, the only real difference is in the ways the transfor-
Search WWH ::




Custom Search