1 //------------------------------------------------------------------------------
2 // File : SkyBoundingVolume.hpp
3 //------------------------------------------------------------------------------
4 // SkyWorks : Copyright 2002 Mark J. Harris and
5 // The University of North Carolina at Chapel Hill
6 //------------------------------------------------------------------------------
7 // Permission to use, copy, modify, distribute and sell this software and its
8 // documentation for any purpose is hereby granted without fee, provided that
9 // the above copyright notice appear in all copies and that both that copyright
10 // notice and this permission notice appear in supporting documentation.
11 // Binaries may be compiled with this software without any royalties or
14 // The author(s) and The University of North Carolina at Chapel Hill make no
15 // representations about the suitability of this software for any purpose.
16 // It is provided "as is" without express or
19 * @file SkyBoundingVolume.hpp
21 * Base class interface definition for a bounding volume.
23 #ifndef __SKYBOUNDINGVOLUME_HPP__
24 #define __SKYBOUNDINGVOLUME_HPP__
29 // forward to reduce unnecessary dependencies
32 //------------------------------------------------------------------------------
34 * @class SkyBoundingVolume
35 * @brief An abstract base class for bounding volumes (AABB,OBB,Sphere,etc.)
37 * This base class maintains a center and a radius, so it is effectively a bounding
38 * sphere. Derived classes may represent other types of bounding volumes, but they
39 * should be sure to update the radius and center, because some objects will treat
40 * all bounding volumes as spheres.
43 class SkyBoundingVolume
47 SkyBoundingVolume() : _vecCenter(0, 0, 0), _rRadius(0) {}
49 virtual ~SkyBoundingVolume() {}
52 //------------------------------------------------------------------------------
53 // Function : SetCenter
55 //------------------------------------------------------------------------------
57 * @fn SetCenter(const Vec3f ¢er)
58 * @brief Sets the center of the bounding volume.
60 virtual void SetCenter(const Vec3f ¢er) { _vecCenter = center; }
63 //------------------------------------------------------------------------------
64 // Function : SetRadius
66 //------------------------------------------------------------------------------
68 * @fn SetRadius(float radius)
69 * @brief Sets the radius of the bounding volume.
71 virtual void SetRadius(float radius) { _rRadius = radius; }
74 //------------------------------------------------------------------------------
75 // Function : Vec3f& GetCenter
77 //------------------------------------------------------------------------------
79 * @fn Vec3f& GetCenter() const
80 * @brief Returns the center of the bounding volume.
82 virtual const Vec3f& GetCenter() const { return _vecCenter; }
85 //------------------------------------------------------------------------------
86 // Function : GetRadius
88 //------------------------------------------------------------------------------
90 * @fn GetRadius() const
91 * @brief Returns the radius ofthe bounding volume.
93 virtual float GetRadius() const { return _rRadius; }
95 //------------------------------------------------------------------------------
96 // Function : ViewFrustumCull
98 //------------------------------------------------------------------------------
100 * @fn ViewFrustumCull( const Camera &cam, const Mat44f &mat )
101 * @brief Cull a bounding volume.
103 * Returns false if the bounding volume is entirely outside the camera's frustum,
106 virtual bool ViewFrustumCull( const Camera &cam, const Mat44f &mat ) = 0;
108 //------------------------------------------------------------------------------
109 // Function : AddPoint
111 //------------------------------------------------------------------------------
113 * @fn AddPoint( const Vec3f &pt )
114 * @brief Add a point to a bounding volume.
116 * One way to create a bounding volume is to add points. What should/could happen
117 * is that the BV will store an object space BV and then when a call to SetPosition
118 * is called, the stored values will be transformed and stored separately, so that
119 * the original values always exist.
122 //virtual void AddPoint( const Vec3f &point ) = 0;
124 //------------------------------------------------------------------------------
125 // Function : AddPoint
127 //------------------------------------------------------------------------------
129 * @fn AddPoint( float x, float y, float z )
130 * @brief Add a point to a bounding volume.
132 * @see AddPoint(const Vec3f &pt)
134 //virtual void AddPoint( float x, float y, float z ) = 0;
136 //------------------------------------------------------------------------------
139 //------------------------------------------------------------------------------
142 * @brief Clear all data from the bounding volume.
144 //virtual void Clear() = 0;
151 #endif //__SKYBOUNDINGVOLUME_HPP__