Graphics Reference
In-Depth Information
class CDrawOnlyHandler : public UWBD3D _ WindowHandler {
.
The WORLD matrix proces-
sor. Notice that our scene
hierarchy is defined by the
SceneNode class where
the matrix stack is used to
store/re-store the WORLD ma-
trix processor before drawing
each node. This means that at
the end of the DrawModel()
(at label E) function call, the
WORLD matrix processor is
restored to the identity matrix.
In this case, we can draw
the camera before or after
drawing the scene.
A: UWB _ Camera * m _ ToDrawCamera; // camera to be visualized
}
void CDrawOnlyHandler::DrawGraphics() {
.
BeginDraw();
B: LoadViewXform(); // compute/load M r w 2 e to VIEW
LoadProjectionXform(); // compute/load M e 2 n to PROJECTION
// initialized M o 2 w I 4
C: D3DXMATRIX identity; D3DXMatrixIdentity(&identity);
// load identity to WORLD
m _ pD3DDevice->SetTransform(D3DTS _ WORLD, &identity);
.
Source file. Pseudocode; no
corresponding source file.
D: m _ ToDrawCamera->Draw(... draw _ helper); // Draws the camera
E: theApp.GetModel().DrawModel();
// Draws the scene
EndDrawAndShow();
}
Listing 15.16. Drawing the camera in the simplest case.
the m _ ToDrawCamera , we must also consider its corresponding orbiting rotations.
However, in this case, we need to compute and rotate the m _ ToDrawCamera (and
not the entire world). For this reason, we need to compute the orbit rotation matrix
( M or )forthe m _ ToDrawCamera (Equation (15.2)):
R v w
M or =
d
x
R y
d
y
( θ
)
( θ
) ,
where v w is the side vector ( V w )and
y are the vertical and horizontal
rotation angles, respectively, of the m _ ToDrawCamera .
x and and
θ
θ
In this case, before the
drawing of the m _ ToDrawCamera , we need to compute
M W M V M P
=
M W M r w 2 e M e 2 n
M W M or
] 1 M w 2 e M e 2 n
=
[
.
M or
Search WWH ::




Custom Search