]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/clouds3d/SkyMinMaxBox.hpp
Clouds3D crashes because there is no Light
[simgear.git] / simgear / scene / sky / clouds3d / SkyMinMaxBox.hpp
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 
12 // restrictions. 
13 //
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 
17 // implied warranty.
18 /**
19 * @file SkyMinMaxBox.hpp
20
21 * Interface definition for a min-max bounding box class for bounding volume hierarchies.
22 */
23 #ifndef __SKYMINMAXBOX_HPP__
24 #define __SKYMINMAXBOX_HPP__
25
26 #include "SkyBoundingVolume.hpp"
27
28 //------------------------------------------------------------------------------
29 /**
30 * @class SkyMinMaxBox
31 * @brief An AABB class that can be used in bounding volume hierarchies.
32
33 * @todo <WRITE EXTENDED CLASS DESCRIPTION>
34 */
35 class SkyMinMaxBox : public SkyBoundingVolume
36 {
37 public:
38   SkyMinMaxBox();
39   //! Destructor
40   virtual ~SkyMinMaxBox() {}
41   
42   void  AddPoint( const Vec3f &pt );
43   void  AddPoint( float x , float y , float z );
44   
45   //! Expand this box to contain @a box.
46   void  Union(const SkyMinMaxBox& box)           { AddPoint(box.GetMin()); AddPoint(box.GetMax()); }
47
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; }
52   
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(); }
57   
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;}
64   
65   bool  PointInBBox( const Vec3f &pt ) const;
66   
67   bool  ViewFrustumCull( const Camera &cam, const Mat44f &mat );
68
69   void  Transform(const Mat44f& mat);
70   
71   // Reset the bounding box
72   void  Clear();
73   
74   void  Display() const;
75   
76 protected:
77   void _UpdateSphere();
78   void _CalcVerts(Vec3f pVerts[8]) const;
79
80 private:
81         Vec3f _min;   // Original object space BV
82         Vec3f _max;
83 };
84
85 #endif //__SKYMINMAXBOX_HPP__