1 //------------------------------------------------------------------------------
2 // File : SkyMinMaxBox.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 SkyMinMaxBox.hpp
21 * Interface definition for a min-max bounding box class for bounding volume hierarchies.
23 #ifndef __SKYMINMAXBOX_HPP__
24 #define __SKYMINMAXBOX_HPP__
26 #include "SkyBoundingVolume.hpp"
28 //------------------------------------------------------------------------------
31 * @brief An AABB class that can be used in bounding volume hierarchies.
33 * @todo <WRITE EXTENDED CLASS DESCRIPTION>
35 class SkyMinMaxBox : public SkyBoundingVolume
40 virtual ~SkyMinMaxBox() {}
42 void AddPoint( const Vec3f &pt );
43 void AddPoint( float x , float y , float z );
45 //! Expand this box to contain @a box.
46 void Union(const SkyMinMaxBox& box) { AddPoint(box.GetMin()); AddPoint(box.GetMax()); }
48 //! Returns the minimum corner of the bounding box.
49 const Vec3f &GetMin() const { return _min; }
50 //! Returns the maximum corner of the bounding box.
51 const Vec3f &GetMax() const { return _max; }
53 //! Sets the minimum corner of the bounding box.
54 void SetMin(const Vec3f &min) { _min = min; _UpdateSphere(); }
55 //! Sets the maximum corner of the bounding box.
56 void SetMax(const Vec3f &max) { _max = max; _UpdateSphere(); }
58 //! Returns the X width of the bounding box.
59 float GetWidthInX() const { return _max.x - _min.x;}
60 //! Returns the Y width of the bounding box.
61 float GetWidthInY() const { return _max.y - _min.y;}
62 //! Returns the Z width of the bounding box.
63 float GetWidthInZ() const { return _max.z - _min.z;}
65 bool PointInBBox( const Vec3f &pt ) const;
67 bool ViewFrustumCull( const Camera &cam, const Mat44f &mat );
69 void Transform(const Mat44f& mat);
71 // Reset the bounding box
78 void _CalcVerts(Vec3f pVerts[8]) const;
81 Vec3f _min; // Original object space BV
85 #endif //__SKYMINMAXBOX_HPP__