Graphics Reference
In-Depth Information
// ... From Listing 13.2 ...
Step 2: initialize selected hardware and set the coordinate system parameters.
Source file.
GrfxWindowD3D.cpp file in
the GrfxWindow folder of the
D3D _ Rectangles3D project.
A: M W : Transforms from Object Coordinate (OC) to World Coordinate (WC).
D3DXMATRIX identity;
// identity matrix: I 4
A1: D3DXMatrixIdentity(&identity);
// load I 4 to D3D WORLD processor
m _ pD3DDevice->SetTransform( D3DTS _ WORLD, &identity);
B: M V : Transforms from WC to Camera (Eye) Coordinate (EC).
D3DXMATRIX matView;
// camera parameters
D3DXVECTOR3 camera _ pos(...), target _ pos(...), up _ vector(...);
// compute matView
B1: D3DXMatrixLookAtRH(&matView,...camera/target/up _ vector...);
// load matView to D3D VIEW processor
m _ pD3DDevice->SetTransform( D3DTS _ VIEW, &matView );
C: M P : Transforms from EC to Normalized Device Coordinate (NDC).
D3DXMATRIX matProj;
// view frustum parameters
float fov=..., aspect=..., near/far _ plane=...;
// compute matProj
C1: D3DXMatrixPerspectiveFovRH(&matProj, fov/aspect/near/far );
// load matProj to D3D PROJECTION processor
m _ pD3DDevice->SetTransform(D3DTS _ PROJECTION, &matProj);
Listing 14.4. Details of matrix processor set-up (Tutorial 13.1).
V wc is input to the VIEW matrix processor, where the output V ec is in EC space:
V ec =
V wc M V =
V wc M w 2 e ,
and lastly, V ec is input to the PROJECTION matrix processor with output V ndc in
the NDC space:
V ndc =
V ec M P =
V ec M e 2 n .
We see that the input vertex in OC space V oc is indeed transformed by the (coor-
dinate) transformation pipeline:
V oc M W ( M o 2 w )
V wc M V ( M w 2 e )
V ec M P ( M e 2 n )
−→
−→
−→
V ndc .
We have worked with OC space extensively via the SceneNode class in Chap-
ter 11.
Recall that each SceneNode object has an instance of XformInfo that
Search WWH ::




Custom Search