Graphics Reference
In-Depth Information
where T p , R p ,and S p are the translation, rotation, and scaling matrices, respec-
tively, defined by the user's interactive settings, and P p =(
3
,
0
)
is the pivot posi-
tion defined in Figure 11.3.
The second important difference between the implementations of Tutorial 11.1
and Tutorial 11.2 is in the CModel::DrawModel() function. Similar to Tuto-
rial 11.1, after the InitializeModelTransform() and the SetUpModelStack()
function calls at label B, the top of the matrix stack M t 1 becomes
M t 1 =
M a
,
and M t 1 is loaded into the WORLD matrix processor ( M W ). In this way, the trian-
gles of R a 0 are transformed according to Equation (11.2). However, at label C,
m _ PalmXform is invoked to compute and concatenate M p onto the top of the ma-
trix stack M t 2 :
M t 2
=
M p M t 1
M p M a ,
and M t 2 is loaded into the WORLD matrix. In this way, the vertices of C p 0 triangle
fan, V c ,aretransformedto V co according to
=
V co
=
V c M W M V M P
=
V c M t 2 M V M P
(11.3)
=
V c M p M a M V M P .
Notice that V c is first transformed by m _ PalmXform ( M p ) and then by m _ ArmXform
( M a ). In this way, the C p 0 circle is transformed as an integral element of the arm
object (by M a ), whereas it is also independently transformed as a component on
the arm's object (by M p ).
In general, since the palm inherits the transform from the arm object, we refer
to the palm as the child and the arm as the parent. We observe that one way to de-
fine independently transformable components in objects is to apply the involved
primitive transform operators in a tree-like ordering. In the next section, we in-
troduce the SceneNode class to support the building of a tree-like structure to
support the appropriate hierarchical concatenation of transformation operators.
11.2
The SceneNode Class
Tutorials 11.1 and 11.2 demonstrated the following.
• Graphical objects (e.g., the arm) are defined by geometric primitives (e.g.,
the rectangle R a 0 and circle C p 0 ). In addition, to control the graphical ob-
Search WWH ::




Custom Search