Graphics Reference
In-Depth Information
•
Approach.
With the camera settings as in Tutorial 14.1, define a rectan-
gular visible volume with orthographic projection where we can control all
aspects of the volume.
Tutorial 14.2.
Project Name:
D3D
_
AdjustOrtho
Library Support:
UWB_MFC_Lib1
Figure 14.9 is a screenshot of running Tutorial 14.2. Although the application
window is somewhat larger, the implementation of this tutorial is only slightly dif-
ferent from that of Tutorial 14.1. Listing 14.2 shows the set-up of the
PROJECTION
matrix processor in the
GrfxWindowD3D::OnPaint()
function. The only differ-
ence between the implementation of this tutorial and that of Tutorial 14.1 is in
the computation of the matrix for the
PROJECTION
processor. The variables that
correspond to the parameters of the rectangular visible volume are controlled by
the GUI slider bars. At label A, we see the visible volume parameters being ref-
erenced for the computation of the
matProj
matrix, and then the
matProj
matrix
is loaded into the D3D
PROJECTION
matrix processor. As in Tutorial 14.1, we are
not interested in the details of the
matProj
matrix. Rather, we want to verify the
effects of changing the rectangular visible volume parameters.
We see that with the exact same camera setting as in Tutorial 14.1, the two
rectangles in the rendered image do not resemble squares in 3D space. The major
problem here is the absence of the distance hint. As humans, our visual system
expects the farther edge of the squares to be shorter than the closer ones. In the
image, those edges are of the same length. We can verify this is indeed an image
of the two squares in 3D space by raising the camera position (increasing the
value of camera
y
-position slider bar).
Figure 14.9.
Tutorial
14.2.
void
CGrfxWindowD3D::OnPaint() {
.
Source file.
GrfxWindowD3D.cpp
file in
the
GrfxWindow
folder of the
D3D
_
AdjustOrtho
project.
//
Identical to Tutorial 14.1
.
Step 2:
initialize selected hardware and set the coordinate system parameters.
// Set
WORLD
and
VIEW
matrix processors...
Identical to Tutorial 14.1
.
D3DXMATRIX
matProj;
// Rect. visible volume parameters: m
_
ViewWidth, m
_
ViewHeight, m
_
ViewNearPlane, m
_
ViewFarPlane
// compute
matProj
A:
D3DXMatrixOrthoRH(&matProj, width/height/near/far);
// load
matProj
to D3D PROJECTION processor
m
_
pD3DDevice->SetTransform(D3DTS
_
PROJECTION, &matProj);
Listing 14.2.
Details of the matrix processors settings (Tutorial 14.2).
Search WWH ::
Custom Search