Game Development Reference
In-Depth Information
This effect is done by concatenating matrices. Every node in the hierarchy has a
matrix that describes position and orientation relative to its parent node. As the
scene graph is traversed, the matrices are multiplied to form a single matrix that per-
fectly describes the position and orientation of the node in the 3D world
even if it is
a gun attached to a hand attached to a forearm attached to a shoulder attached to a
guy standing on a boat.
Take notice that the VSetTransform() method takes two Mat4x4 objects, not just
one. It turns out to be really convenient to store two matrices for each scene node
the first one we just discussed about transforming object space to the space of its
parent (usually world space if there
s no complicated hierarchy involved). This is
the toWorld parameter in the SetTransform() and GetTransform() APIs.
The second one does the opposite: It transforms 3D world back into object space.
This is great if you want to know where a bullet strikes an object. The bullet ' s trajec-
tory is usually in world space, and the fromWorld transform matrix will tell you
where that trajectory is in object space.
This can be a little confusing, so if your brain is swimming a bit, don
'
t worry. Mine
did too when I first read it. You can imagine this by thinking about your hand as a
self-contained hierarchical object. The root would be your palm, and attached to it
are five children
'
the first segment of each of your five fingers. Each of those finger
segments has one child, the segment without a fingernail. Finally, the segment with
the fingernail attaches, making the palm its great-grandfather. If the transform matrix
for one of those finger segments is rotated around the right axis, the finger should
bend, carrying all the child segments with it. If I change the translation or rotation
of the palm (the root object), everything moves. That is the basic notion of a hierar-
chical animation system.
That
'
s Gotta Hurt!
It
s common for artists to create human figures with the hips, or should I say,
groin, as the root node. It
'
s convenient because it is close to the center of the
human body and has three children: the torso and two legs. One fine day the
Ultima VIII team went to the park for lunch and played a little Ultimate
Frisbee. As happens frequently in that game, two players went to catch the
Frisbee at the same time and collided, injuring one of the players. He was
curled up on the ground writhing in pain, and when I asked what happened I
was told that he took a blow to the root of his hierarchy.
'
The call to VSetTransform() will calculate the inverse transform matrix for you if
you don
ve ever seen the formula for
calculating the determinant of a 4 × 4 matrix, you know what I
'
t send it in. Yes, it
'
s somewhat expensive. If you
'
'
m talking about. If
Search WWH ::




Custom Search