Graphics Reference
In-Depth Information
void CDrawOnlyHandler::DrawGraphics() {
//
Source file.
DrawOnlyHandler.cpp file
in the Source Files folder
of the D3D _ CameraMouseUI
project.
// Everything before Labels D are identical to Listing 15.16
//
.
// m _ ToDrawCamera rotation parameters
m _ ToDrawCamera->GetMouseRotations(xRot,xRef,yRot,yRef);
// ... format conversion not shown ...
// xRotMat = M v w
D:
x )
D3DXMatrixRotationAxis(&xRotMat, &xRef, -xRot);
// yRotMat = M y
x )
( θ
θ
(xRot=
y )
D3DXMatrixRotationAxis(&yRotMat, &yRef, -yRot);
// rotMat = M or = xRotMat * yRotMat
D3DXMatrixMultiply(&rotMat, &xRotMat, &yRotMat);
// M W M or (of m _ ToDrawCamera )
m _ pD3DDevice->SetTransform(D3DTS _ WORLD, &rotMat);
m _ ToDrawCamera->Draw(... draw _ helper);
.
y )
( θ
(yRot=
θ
Listing 15.17. Proper support for drawing the camera line.
As illustrated at label C in Listing 15.16, M W is initialized to I 4 . In our implemen-
tation, before drawing the m _ ToDrawCamera ,weload M or into the WORLD matrix
processor:
M W M V M P
=
M or
] 1 M w 2 e M e 2 n
[
,
M or
to rotate the m _ ToDrawCamera orbiting rotations. Listing 15.17 shows that the
implementation of camera drawing indeed agrees with the above derivations.
15.4
DC-to-WC Transformation
We have seen that the transformation pipeline introduced many layers of coordi-
nate systems and supported us in designing our scene in 3D space, modeling a
camera based on our daily experience, and generating images for our 2D display
device. Based on our experience from Chapter 10, we understand that the many
layers of coordinate systems mean our geometric objects are not defined in the
same space as they appear on the application window. For example, the squares
of Tutorial 15.3 are each defined in their own OC space, and yet depending on the
Search WWH ::




Custom Search