Graphics Reference
In-Depth Information
NDC
W dc
2
H dc
2
DC
W dc
2
H dc
2
T ( , )
S( , )
T
H dc
2
(1,1)
W dc
2
(W dc ,H dc )
(0,0)
( , )
2
H dc
(0,0)
(-1,-1)
2
W dc
Figure 10.7.
D3D's M n 2 d operator.
The M n 2 d transform.
From our discussions, we observe that the D3D API must
be performing
S W dc
2
T W dc
2
H dc
2
H dc
2
M n 2 d =
,
,
(10.6)
on all vertices, where
W dc
=
Width of drawing area (on device)
,
H dc
=
Height of drawing area (on device)
.
Figure 10.7 illustrates the transformation described by Equation (10.6). On the
left diagram we see that the S
W dc
2
H dc
2
(
,
)
operator scales the 2
×
2 NDC space into
an H dc ×
W dc region. The center and right diagrams of Figure 10.7 show that the
translation operator moves the region to the proper device location. In general,
any vertex V i we specify to the D3D graphics API undergoes the transform
Figure 10.6. Tutorial
10.5: Drawing the circle
onto a 200 × 100 window.
V dc =
V i M W M V M P M n 2 d ,
where M W , M V ,and M P are the WORLD , VIEW ,and PROJECTION matrix processors
of the D3D RC and V dc is the vertex on the UI drawing area. A very important
lesson we have learned so far is that whereas the matrix processors ( M W , M V ,
and M P ) are under our program's control, M n 2 d will be applied internally by the
D3D graphics API automatically and is not under our program's control. Another
important observation is that the graphics API (D3D) knows what the underlying
display device resolution is (width/height) and computes M n 2 d accordingly.
We see the that the M w 2 n operator we construct in Step 2 of Listing 10.1 for
Tutorial 10.1 (and for every single tutorial we have worked with so far) is to com-
plement the M n 2 d transform (Equation (10.6)) that D3D performs automatically.
An obvious question is, “Why would D3D automatically perform the M n 2 d oper-
ation?” To answer this question, we must first understand coordinate systems.
Linearity of affine transformation. Before we leave this section, notice that
we analyzed the M w 2 n operator from Equation (10.3) based on transforming the
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search