Graphics Reference
In-Depth Information
class
CModel {
// ... similar to Tutorial
11.1
Source file.
Model.h/cpp
files in the
Model
folder of the
D3D
_
ParentChild
project.
...
.
// Rectangle
R
a
0
UWB
_
PrimitiveRectangle m
_
Arm;
// Circle
C
p
0
UWB
_
PrimitiveCircle m
_
Palm;
// Transformation operator:
M
a
=
T
(
−
P
a
)
S
a
R
a
T
(
P
a
)
T
a
UWB
_
XformInfo m
_
ArmXform;
// Transformation opeator:
M
p
=
T
(
−
P
p
)
S
p
R
p
T
(
P
p
)
T
p
UWB
_
XformInfo m
_
PalmXform;
.
A:
};
void
CModel::DrawModel() {
// ... similar to Tutorial
11.1
...
// 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
m
_
ArmXform.SetUpModelStack(m
_
DrawHelper);
// Draw the two triangles in
R
a
0
m
_
Arm.Draw(lod, m
_
DrawHelper);
//
M
t
2
=
M
p
M
t
1
and then
M
W
=
M
t
2
B:
m
_
PalmXform.SetUpModelStack(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();
C:
Listing 11.2.
The
CModel
class of Tutorial 11.2.
The first difference is at label A of the
CModel
class definition. We have
defined
m
_
PalmXform
, a second
XformInfo
object, to support the independent
transformation of the palm (
C
p
0
). When the corresponding radio button is se-
lected, the
m
_
PalmXform
object records the transformation values interactively
set by the user. These transformation values together define
M
p
=
T
(
−
P
p
)
S
p
R
p
T
(
P
p
)
T
p
,
Search WWH ::
Custom Search