Graphics Reference
In-Depth Information
void UWBD3D _ WindowHandler::ComputeViewMatrix( D3DXMATRIX &mat) const {
// Labels A1a and A1b are identical to Listing 15.8
// Get p e , p a , and V up
A1a: m _ Camera.GetCameraPosition(p.x, p.y, p.z);
.
Source file.
uwbgl _ D3DWindowHandler6.h/cpp
files in the D3D Files/ Win-
dowHandler subfolder of the
UWBGL _ D3D _ Lib14 project.
// mat is M w 2 e of Equation 14.4
A1b: D3DXMatrixLookAtRH( &mat, &p, &a, &u );
A1c: The following details were not shown in Listing 15.8
// get camera rotation parameters
A1d: m _ Camera.GetMouseRotationsInRadian(xRot, xRef, yRot, yRef);
.
// some format conversions not shown
.
// xRotMat = R v w
θ x )
A1e: D3DXMatrixRotationAxis(&xRotMat, &xRef, xRot);
// yRotMat = R y
( θ x )
(xRot=
θ y )
D3DXMatrixRotationAxis(&yRotMat, &yRef, yRot);
// rotMat = yRotMat * xRotMat
A1f: D3DXMatrixMultiply(&rotMat,
( θ y )
(yRot=
&yRotMat, &xRotMat);
// M r w 2 e = rotMat M w 2 e
D3DXMatrixMultiply(&mat, &rotMat,
&mat);
}
Listing 15.13. M w 2 e with camera rotation.
In this section, we simulate the camera orbiting sensation by rotating the world
in the inverse directions. The matrix derived and implemented are with respect to
the origin of the world. This simulation is correct only when the camera look-at
position is located at the origin.
15.3.2
Pan: Tracking the Camera
As illustrated in Figure 15.8, another common operation we often perform on a
camera is, with a fixed gaze direction, moving the camera. When compared to
orbiting, instead of rotating the camera with a fixed look-at position, we move the
camera with a fixed view vector. The effect of this movement is panning on the
rendered image, or tracking of the application window.
Search WWH ::




Custom Search