Graphics Reference
In-Depth Information
void CDrawOnlyHandler::DrawGraphics() {
. // obtain the width and height for the world
Programming the VIEW matrix processor:
Source file.
DrawOnlyHandler.cpp
file in the WindowHan-
dler folder of the
D3D _ TranslateSingleObject
project.
D3DXMATRIX world2ndc;
D3DXVECTOR3 scale(2.0f/width, 2.0f/height, 1.0f);
D3DXVECTOR3 translate(-1.0f, -1.0f, 0.0);
D3DXMatrixTransformation(&world2ndc, ... &scale, ... &translate);
m _ pD3DDevice->SetTransform(D3DTS _ VIEW , &world2ndc);
. // calls the model to perform the actual drawing
theApp.GetModel().DrawModel();
.
Listing 8.3. Programming the M V matrix (Tutorial 8.1).
void CModel::DrawModel() {
. draws the grid ... // DrawGrid( m _ DrawHelper, m _ WorldBounds );
LPDIRECT3DDEVICE9 pDevice = UWBD3D _ GraphicsSystem::GetSystem().GetD3DDevice();
D3DXMATRIX translate _ matrix;
A: D3DXMatrixTranslation( &translate _ matrix, m _ TranslateX, m _ TranslateY, 0);
B: pDevice->SetTransform( D3DTS _ WORLD, &translate _ matrix );
Source file. Model.cpp
file in the Model folder of the
D3D _ TranslateSingleObject
project.
C: m _ Rectangle.Draw( lod, m _ DrawHelper );
.
Listing 8.4. Programming the M W matrix (Tutorial 8.1).
When we examine the implementation of the CModel::DrawModel() func-
tion in Listing 8.4, we see that at label A, we call the D3DXMatrixTranslation()
function to compute the translate _ matrix matrix based on the m _ TranslateX/Y
values set by the GUI slider bars. The translate _ matrix encodes our transla-
tion operator T . At label B, we call the SetTransform() function to load the
computed translate _ matrix into the WORLD matrix processor. By the time the
rectangle Draw() function is invoked, the D3D RC matrix processors have
=
,
M W
T
M V
=
M w 2 n
,
M P =
I 4 .
Search WWH ::




Custom Search