Game Development Reference
In-Depth Information
B. Determine whether the sphere's center intersects any of the cylinders of radi-
us r corresponding to the expanded edges of the model. If it does intersect an
edge, skip the third step.
C. Determine whether the sphere's center intersects any of the spheres of radius
r corresponding to the expanded vertices of the model.
When performing intersections with the edge cylinders, we do not have to
worry about whether the intersection occurs on the exterior surface because an
intersection with the interior surface would be preceded along the ray by a face
intersection (see Figure 12.4). Likewise, an interior intersection with a vertex
sphere would be preceded by either a face intersection or an edge cylinder inter-
section.
A ray intersection with a triangular face of a model can be accomplished us-
ing the method discussed in Section 6.2.1. Each face's plane needs to be offset by
the distance r to determine the point of ray intersection. The barycentric coordi-
nates of that point can then be calculated using the original vertex positions of the
triangle (see Chapter 6, Exercise 5). A ray intersection with a vertex sphere can
be performed using the method discussed in Section 6.2.3 after translating the
vertex's position to the origin. Calculating the intersection of a ray and an edge
cylinder is slightly more complicated since the cylinder can have an arbitrary
orientation.
Figure 12.4. A ray intersection with the interior surface of an edge cylinder must be pre-
ceded by a face intersection, in which case the cylinder intersection calculation would
never have been performed. Thus, cylinder intersections can be assumed to lie on the
exterior of the expanded surface. A similar argument applies to vertex spheres.
Search Nedrilad ::




Custom Search