Graphics Reference
In-Depth Information
graphics, we typically define collision primitives to perform proximity tests. Now,
click on the “Show Collision Sphere” checkbox to see the red wire-frame bound
used for collision computation. Instead of performing computation based on the
actual geometries, in this case the collision is approximated between the traveling
sphere and the red wire-frame sphere. In this way, we have simplified the collision
between two scene nodes of arbitrary geometries into a problem of intersecting
two spheres in WC space. We know the intersection routine should be:
// 1. compute the positions (centers) of the two spheres
// 2. compute the distance between the two centers
// 3. if (computed distance > sum of radius)
//
no collision
//
else
//
collision
Listing 16.23. Compute intersection between two spheres.
To follow the next part of the explanation, you should restart the tutorial such
that the positions and distances between scene nodes are at their initial values.
Now, adjust the “Ball Speed” slider bar to see that we can control the speed of the
sphere that is released from the tiger. Adjust this slider bar such that the speed of
the traveling sphere is around 71 units. Notice that with this speed, the released
sphere travels right through the plane as though the intersection has failed!
V b
P b
V a
target
bound
P a
P 0
Recall that we simulate the traveling of a sphere by changing its position ac-
cording to its velocity at each timer update. As illustrated in Figure 16.19, in real-
ity, our implementation positions the traveling sphere at discrete locations along
the traveling path. For example, at time t 0 , the sphere is located at position P 0 .At
the subsequent timer update t 1 , the sphere's position will depend on its velocity.
If the sphere is traveling at velocity V a ,thenat t 1 , the sphere will be located at
position P a . However, if the sphere is traveling at a higher speed at velocity V b ,
then in the same timer update interval the sphere will cover a greater distance.
In this example, the sphere is traveling at velocity V b and thus will be located at
P b at time t 1 . Figure 16.19 shows that even though the target bound is located in
between positions P 0 and P b , the collision computation from Listing 16.23 will
fail! In this case, we must intersect the target bound with the line segment P 0 P b .
Refer to the collision results echoed in the Status area:
Figure 16.19. Instanta-
neous positions of the trav-
eling sphere.
DistHit
(
F
)
LineHit
(
T
)
where DistHit is the result based on distance computation and LineHit is the
result based on line/sphere intersection.
This tutorial shows us that collision computation in 3D is similar to that in
2D. In particular, we observe:
Search WWH ::




Custom Search