Graphics Reference
In-Depth Information
class UWB _ BoundingBox : public UWB _ BoundingVolume {
Source files.
uwbgl _ Intersect1.h/cpp
files in the Common Files
/BoundingVolumes subfolder
of the UWBGL _ D3D _ Lib6
project. Notice that in this
case the UWB _ BoundingBox
class is also defined/im-
plemented in the uwbgl _
Intersect1.h/cpp files.
A: volume _ type GetType() const { return box;}
vec3 GetMin() const { return m _ min;}
.
B: void SetCorners( vec3 corner1, vec3 corner2);
.
C: bool Intersects( const UWB _ BoundingVolume& other) const ;
bool ContainsPoint( vec3 location) const ;
.
D: void Draw(UWB _ DrawHelper * pDrawHelper) const ;
private :
E: vec3 m _ min, m _ max;
};
Listing 7.16. The UWB _ BoundingBox class (Tutorial 7.3).
Listing 7.16 shows that UWB _ BoundingBox subclasses from the UWB _ Bounding
Volume class. We see that besides implementing all the pure virtual functions
defined in the base class, additional information-accessing functions are defined
at label A, and information-setting functions are defined at label B. At label E, we
see that a bounding box is represented internally by the max and min positions.
Primitive collision response support. With the UWB _ BoundingBox class sup-
port, all primitives that know how to set the min/max bounds can participate
in colliding with other primitives. Listing 7.17 shows the modification of the
Primitive base class to support collisions. Listing 7.18 shows that to collide two
primitives, we first determine if their bounding volumes overlap, and if so, we call
the CollisionResponse() functions to allow the primitives to update their be-
havior as a result of successful collision. Subclasses from the Primitive class are
responsible for defining the actual bounding volume. However, the Primitive
base class does define simple behavior for CollisionResponse() . Listing 7.19
shows that by default, primitives respond to a collision by traveling at the same
speed but away from the colliding primitive. In this version of the D3D library, all
concrete primitive classes (point, line, circle) implement the UWB _ BoundingBox
as their bounding volume.
Search WWH ::




Custom Search