Graphics Reference
In-Depth Information
bel B is defined to maintain all the bullets in the world. Listing 11.20 shows the
implementation of the CModel::UpdateSimulation() function of Tutorial 11.8.
Recall that this function is called at about 25 msec intervals from the timer event
service routine. In this function, we must collide all the bullets with the two
palm nodes, generate new bullets, and remove all the bullets that are outside of
the world boundaries. With the matrix stack properly initialized at label A, the
GetNodeBounds() functions are called at label B to compute the WC bounding
box of the left and right palm node. At label C, we loop through every bullet in the
world to compute the bounding volume of the bullet (label C1) and intersect the
bounding volume with the left and right arm bounding box (labels C2 and C3).
New bullets are created at about 0.5 sec intervals (at label D), and finally at label
E, bullets that are outside the world bounds are removed from the m _ bullets list.
There are three details we should notice from this tutorial.
1. Rough approximations. Collision approximations of non-axis aligned
rectangular objects have relatively low accuracy. Try rotating the arm and
the palm such that these scene nodes are about 45 degrees from the x / y
axes. Notice that successful collisions of the palm with the dropping arm
bullet often have relatively large gaps in between the actual primitives. This
low accuracy in intersection approximation is a direct result of the large
void spaces in axis-aligned bounding boxes. In many cases, using strategic
bounding circles/spheres would result in much better results.
2. Multiple collisions. The hitCount echoed in the status area may be incre-
mented by several counts for one actual collision. This is a result of multi-
ple successful intersections between a bullet and the palm over several timer
update cycles. For example, within one update cycle, a fast-traveling bullet
would move from outside to well inside the bounds of a palm object. In
this case, the bullet's velocity will be updated after the successful collision.
However, during the subsequent timer update cycle, before the bullet has
the opportunity to move outside the palm's bound, another successful inter-
section may result. This problem becomes especially prominent when the
human model hierarchy is also moving. For example, try rotating the left
arm scene node while observing the hitCount ; it will increase at a higher
rate than the actual number of intersections. One easy way to fix this prob-
lem is to test the bullet's velocity direction and only perform intersection
tests on bullets that are moving towards a palm object.
3. Collision limitations. The SceneNode::GetNodeBounds() function re-
turns the WC bounding box of a branch , or subtree, rooted at the target
scene node. This means that with the current functionality of the SceneNode
Search WWH ::




Custom Search