Graphics Reference
In-Depth Information
M
t
5
=
T
(
−
p
x
,−
p
y
)
S
(
s
x
,
s
y
)
R
(
θ
)
T
(
p
x
,
p
y
)
T
(
t
x
,
t
y
)
M
t
,
(9.10)
where
M
t
5
is the final top of the matrix stack,
M
t
is the initial top of the matrix
stack, and
is the pivot position. In this way, this function concatenates (or
accumulates) the scaling, rotation, and translation operators with the top of the
matrix stack. Notice the following
(
p
x
,
p
y
)
•
Pivot position.
Scaling and rotation have the same pivot position. This
is more restrictive then the general pivoted scaling and rotation of Equa-
tions (9.4) and (9.5). However, we do have a simpler interface to the func-
tion, and in most cases we require the same pivot position for scaling and
rotation operations.
•
Order of operation.
The scaling operation is applied before the rotation
operation, with the translation operation being applied last. This ordering
computes more intuitive results.
Once again, the
AccumuateModelTransform()
function changes the D3D
WORLD
matrix by loading it with the accumulated results from the top of the matrix stack.
The
UWB
_
XformInfo
class.
The
UWB
_
XformInfo
class is shown in Listing 9.10.
At label D, we see that the
XformInfo
class defines instance variables to represent
the transformation parameters. This class then provides the set/get functions (A
and A1) to support accessing the translation, rotation, scaling, and pivot settings.
class
UWB
_
XformInfo {
Source file.
uwbgl
_
XformInfo1.h/cpp
files in the
Common Files/
XFormInfo
subfolder
A:
vec3
GetTranslation()
const
;
void
SetTranslation(
vec3
translation);
.
// Get/Set functions for scaling, rotation, and pivot
.
of
the
UWBGL
_
D3D
_
Lib9
project.
void
SetUpModelStack(UWB
_
DrawHelper& draw
_
helper)
const
;
B:
void
DrawPivot(UWB
_
DrawHelper&,
float
size=1.0f);
C:
protected
:
D:
vec3
m
_
translation, m
_
scale;
//
(
t
x
,
t
y
)
(
s
x
,
s
y
)
and
float
m
_
rotation
_
radians;
θ
//
in radians
vec3
m
_
pivot;
// pivot position for scaling and rotation
};
Listing 9.10.
The
UWB
_
DrawHelper
class (
Lib9
).
Search WWH ::
Custom Search