Graphics Reference
In-Depth Information
void UWB _ Camera::MouseZoom( int x) { // x is a mouse displacement
Source file.
uwbgl _ Camera _ Xform1.cpp
file
A: float dx=...; // convert mouse movement into distance
B: vec3 view _ vec = m _ LookAt - m _ CameraPos; // V v = p a p e
float view _ distance = length(view _ vec); // v d =
in
the Common Files/
Camera
subfolder
of
the
UWBGL _ D3D _ Lib14 project.
V v
V v normalize( V v )
normalize(view _ vec);
//
// implement Equation 15.5
m _ CameraPos = m _ LookAt-((view _ distance+dx) * view _ vec);
.
Listing 15.15. The UWB _ Camera support for zooming.
the view vector. At label B, the new camera position is computed according to
Equation (15.5).
15.3.4
Drawing of the Camera
The camera and look-at positions are specified in the WC space. In the sim-
plest case, we can simply draw a line from the camera position to the look-at
position to represent the camera. The top of Listing 15.16 (label A) shows that in
the WindowHandler class, we have defined a m _ ToDrawCamera , a reference to the
Drawing WindowHandler
camera. It is difficult,
if not impossible, to
draw and observe the
WindowHandler::m _ Camera
in the same WindowHandler
view. For example, a line
along the camera viewing
direction is a single point
in the middle of the draw-
ing area. For this reason,
the m _ ToDrawCamera is
defined to be a reference
to a camera from another
WindowHandler . In our case,
the main view has a reference
to the small view camera and
vice versa.
camera to be drawn. For proper visualization, this is a reference to a camera of an-
other WindowHander . In our case, the main view has a reference to the small view
camera and vice versa. The lower portion of Listing 15.16 shows that the drawing
of the camera can be integrated into the WindowHandler::DrawGraphics() rou-
tine. At label B, as previously, the VIEW and PROJECTION matrix processors are
loaded with the proper matrices. At label C, we initialize the M o 2 w matrix (the
WORLD matrix processor) to I 4 . Since the M o 2 w matrix is identity, we can draw
objects in the WC space without further transformations. Thus, at label D, we can
simply invoke the camera Draw() function to draw a line between the camera and
the look-at position.
As discussed in Section 15.3.1, in the presence of camera tumbling where a
user can specify
θ x vertical camera orbiting, the
VIEW matrix processor will be loaded with M r w 2 e (Equation (15.4)):
M r w 2 e =[
θ y horizontal camera orbiting and
M or ] 1
M w 2 e .
In this way, the world-to-eye coordinate transformation matrix is augmented with
the inverse of the m _ camera orbiting rotations,
M or ] 1 , to simulate the tum-
bling of the m _ camera . In a similar fashion, to properly visualize the position of
[
Search WWH ::




Custom Search