Graphics Reference
In-Depth Information
UWBGL_D3D_Lib6
Change summary. See p. 516
for a summary of changes to
the library.
In this library, we introduce the UWB _ BoundingVolume class to support bounding
volume collision computation. When compared to UWBGL _ D3D _ Lib5 ,thereare
two changes.
1. BoundingVolumes folder. A new subfolder is created in the Common Files
folder. There are two new source files in this folder, uwbgl _ Intersect1.h
/cpp , which define and implement the UWB _ BoundingVolume functional-
ity.
2. Primitive hierarchy. All files in the Primitive hierarchy are updated to
support the new collision functionality.
The BoundingVolume class. As in the case of Primitive hierarchy, the bound-
ing volume abstraction also has a pure virtual base class. Label A in Listing 7.15
shows that a UWB _ BoundingVolume object must know what type of bounding vol-
ume it is (e.g., a bounding sphere or a bounding box). At label B are the general
behaviors. Notice that the Intersects() function can only return a true/false
status. This function answers the bounding volume overlap-in-space question
without any intersection details. The Add() function allows the bounding volume
to grow by inserting additional volumes. The Draw() function at label C allows
the drawing of the bounding volumes. As we will see, this is a useful option for
debugging.
Source files.
uwbgl _ Intersect1.h/cpp
files in the Common Files/
BoundingVolumes
class UWB _ BoundingVolume {
// types of bounding volume
subfolder
UWBGL _ D3D _ Lib6
of
the
enum volume _ type { box, sphere};
// subclass returns the appropriate from above
virtual volume _ type GetType() const =0;
virtual vec3 GetCenter() const =0;
A:
project.
virtual bool Intersects( const UWB _ BoundingVolume& other) const =0;
// subclass returns the appropriate from above
virtual ContainsPoint( vec3 ) const =0;
virtual void Add( const UWB _ BoundingVolume * pBV) const =0;
B:
virtual void Draw(UWB _ DrawHelper * pDrawHelper) const {}
C:
};
Listing 7.15. The UWB _ BoundingVolume class (Tutorial 7.3).
Search WWH ::




Custom Search