Graphics Reference
In-Depth Information
(20,30)
WC
Window
S( 2 / 10 , 2 / 10 )
(
NDC to DC
(by D3D)
10
T(-20,-30)
T(
10
(1,1)
10
NDC
(Internal
To D3D)
(-1,-1)
10
Figure 10.12.
M w 2 n : world-to-NDC transform for the face of Figure 10.11.
Tutoral 10.7. Working with a Convenient WC Space ( Figure 10.12 )
Tutorial 10.7.
Project Name:
D3D _ ChangedCoordinate
Library Support:
UWB _ MFC _ Lib1
UWB _ D3D _ Lib9
Goal. Understand and work with a world coordinate (WC) window that is
not centered on the origin.
Approach. Program the transformation of Figure 10.12 and observe the
output.
Figure 10.13 is a screenshot of running Tutorial 10.7. We observe that the output
of this tutorial is identical to that of Tutorial 10.6. However, this tutorial im-
plements the geometric face as defined by Figure 10.11 (in CModel.cpp ). The
DrawGraphics() function shown in Listing 10.4 defines the M w 2 n transform op-
erator of Equation 10.7. We see that although the world coordinate spaces and
the actual geometric values specified in this tutorial are very different from that
of Tutorial 10.6, the output from the two tutorials are identical to each other. This
tutorial verifies that we can define the WC window to support a convenient WC
space for designing our world and that the WC space is independent of the dimen-
sions of the UI drawing device.
Figure 10.13.
Tutorial
10.7.
void CDrawOnlyHandler::DrawGraphics()
.
// Translate the center of WC to the origin
D3DXMatrixTranslation(&toPlace, -20.0f, -30.0f, 0.0);
// Scale to 2x2
D3DXMatrixScaling(&toSize, 2.0f/10.0f, 2.0f/10.0f, 1.0);
Source file.
DrawOnlyHandler.cpp
file in the WindowHan-
dler folder of the
D3D _ ChangedCoordinates
project.
// build M w 2 n operator of Equation 10.7
D3DXMatrixMultiply(&world2ndc, &toPlace, &toSize);
// Load to the VIEW matrix ( M V )
m _ pD3DDevice->SetTransform(D3DTS _ VIEW, &world2ndc);
Listing 10.4. The DrawGraphics() function of Tutorial 10.7.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search