Graphics Reference
In-Depth Information
class
CModel {
.
Source file.
Model.h/cpp
files in the
Model
folder of the
D3D
_
SimpleArm
project.
UWB
_
PrimitiveRectangle m
_
Arm;
// Rectangle
R
a
0
UWB
_
PrimitiveCircle m
_
Palm;
// Circle
C
p
0
// Transformation operator:
M
a
=
T
(
−
P
a
)
S
a
R
a
T
(
P
a
)
T
a
A:
UWB
_
XformInfo m
_
ArmXform;
B:
void
DrawModel();
// To draw the arm (
R
a
0
and
C
p
0
)
.
};
void
CModel::DrawModel() {
.
// Initialize top of matrix stack (
M
t
=
I
4
)
m
_
DrawHelper.InitializeModelTransform();
// Push the matrix stack
m
_
DrawHelper.PushModelTransform();
//
M
t
1
=
M
a
M
t
and then
M
W
=
M
t
1
C:
m
_
ArmXform.SetUpModelStack(m
_
DrawHelper);
// Draw the two triangles in
R
a
0
m
_
Arm.Draw(lod, m
_
DrawHelper);
// Draw the triangle Fan of
C
p
0
m
_
Palm.Draw(lod, m
_
DrawHelper);
// Pop off the top of the matrix stack
m
_
DrawHelper.PopModelTransform();
.
D:
Listing 11.1.
The
CModel
class of Tutorial 11.1.
Listing 11.1 shows that in our implementation, we follow Figure 11.1 and de-
fine the
R
a
0
rectangle and
C
p
0
circle (at label A). In addition, we define the
m
_
ArmXform
(at label B), an
XformInfo
object, to implement
=
(
−
)
(
,
)
(
θ
)
(
)
(
,
)
.
M
a
T
P
a
S
a
s
x
s
y
R
a
T
P
a
T
a
t
x
t
y
Through interacting with the slider bars, the user sets the
m
_
ArmXform
object to
control the translation
of
the simple arm. During
DrawModel()
, at label C, we initialize the top of the
matrix stack (
M
t
) to identity (with the
InitializeModelTransform()
function
(
t
x
,
t
y
)
and pivoted (
P
a
) rotation
(
θ
)
and scaling
(
s
x
,
s
y
)
Search WWH ::
Custom Search