Graphics Reference
In-Depth Information
class
UWB
_
WindowHandler :
public
UWB
_
IWindowHandler {
public
:
.
A:
Support for camera and visible volume: to be discussed in
Tutorial 15.1
virtual void
SetCamera(
const
UWB
_
Camera &c);
virtual
UWB
_
Camera& GetCamera();
virtual void
LoadViewXform()
const
=0;
virtual void
LoadProjectionXform()
const
=0;
B:
Support for mouse click input: to be discussed in
Tutorial 15.4
virtual void
DeviceToWorld(
int
dcX,
int
dcY,
vec3
& wcPt,
vec3
& wcRay)
const
;
};
Listing 15.4.
The
UWB
_
WindowHandler
class of Lib14.
Source file.
WindowHandler5.h
file
in the
Common Files/Win-
dowHandler
subfolder of the
UWBGL
_
D3D
_
Lib14
project.
of functionality. At label A are supports for setting and getting the camera and
visible volume parameters. At label B is the support for drawing the camera. As
we will see, this is an important functionality for visualizing the relative posi-
tions between the camera and the scene. At label C are supports for interactive
manipulation of the camera. As shown at label D, internally, the
UWB
_
Camera
class is represented by the simple parameters of the camera and view frustum.
As we will see in subsequent tutorials, the functions under labels A, B, and C
interpret and modify the variables at label D. In this way, the
UWB
_
Camera
class
is an abstract representation of a camera but has no knowledge of any graphics
API or any transformation matrices. It is the
WindowHandler
class that accesses
the camera and view frustum parameters, computes the necessary matrices, and
loads the graphics API matrix processors to establish the coordinate transforma-
tion pipeline necessary for 3D rendering. Listing 15.4 shows the modification
to the
UWB
_
WindowHandler
class for the proper support of the new
UWB
_
Camera
class. At label A are functions that set/get camera association and compute/set
the matrix processors. At label B is the support for transforming points from DC
to WC space. We will describe the details of these functions with appropriate
examples in subsequent tutorials.
Recall that in 2D space, with translation vector
t
, scaling factor
s
, rotation
angle
, and pivot position
p
, Equation (9.10) says the transformation operator
defined by the
XformInfo
object would be
θ
M
t
1
=
T
(
−
p
)
S
(
s
)
R
(
θ
)
T
(
p
)
T
(
t
)
M
t
,
where
M
t
1
is the computed top of matrix stack and
M
t
is the initial top of matrix
stack. In the 2D case, because we only work in 2D
x
/
y
space, the only valid axis of
Search WWH ::
Custom Search