added: travMask to csm viewport
[opensg.git] / Source / Base / Base / OSGFrustumVolume.h
blob9c220b6fca545338457bd4b6d455f2cc802c13d7
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2003 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 * *
29 \*---------------------------------------------------------------------------*/
30 /*---------------------------------------------------------------------------*\
31 * Changes *
32 * *
33 * *
34 * *
35 * *
36 * *
37 * *
38 \*---------------------------------------------------------------------------*/
40 #ifndef _OSG_FRUSTUMVOLUME_H_
41 #define _OSG_FRUSTUMVOLUME_H_
43 #include "OSGVolume.h"
44 #include "OSGPlane.h"
45 #include "OSGVolumeFunctions.h"
47 OSG_BEGIN_NAMESPACE
49 class Line;
51 /*! \ingroup GrpBaseBase
52 \ingroup GrpBaseBaseVolume
53 \ingroup GrpLibOSGBase
56 class OSG_BASE_DLLMAPPING FrustumVolume : public Volume
58 /*========================== PUBLIC =================================*/
60 public:
62 /*---------------------------------------------------------------------*/
63 /*! \name Plane Selection */
64 /*! \{ */
66 enum { P_NONE = 0,
67 P_NEAR = 1,
68 P_FAR = 2,
69 P_LEFT = 4,
70 P_RIGHT = 8,
71 P_TOP = 16,
72 P_BOTTOM = 32,
73 P_ALL = P_NEAR | P_FAR | P_LEFT | P_RIGHT | P_TOP | P_BOTTOM
76 typedef UInt8 PlaneSet;
78 /*! \} */
79 /*---------------------------------------------------------------------*/
80 /*! \name Constructors */
81 /*! \{ */
83 FrustumVolume( void );
84 FrustumVolume(const Plane &pnear, const Plane &pfar,
85 const Plane &left, const Plane &right,
86 const Plane &top, const Plane &bottom);
87 FrustumVolume(const FrustumVolume &obj );
89 /*! \} */
90 /*---------------------------------------------------------------------*/
91 /*! \name Destructors */
92 /*! \{ */
94 ~FrustumVolume(void);
96 /*! \} */
97 /*---------------------------------------------------------------------*/
98 /*! \name Get */
99 /*! \{ */
101 const Plane &getNear (void ) const;
102 const Plane &getFar (void ) const;
103 const Plane &getLeft (void ) const;
104 const Plane &getRight (void ) const;
105 const Plane &getTop (void ) const;
106 const Plane &getBottom (void ) const;
107 const Plane *getPlanes (void ) const;
109 virtual void getCenter (Pnt3f &center ) const;
110 virtual Real32 getScalarVolume(void ) const;
111 virtual void getBounds (Pnt3f &minPnt,
112 Pnt3f &maxPnt ) const;
114 void getCorners (Pnt3f &nlt, Pnt3f &nlb,
115 Pnt3f &nrt, Pnt3f &nrb,
116 Pnt3f &flt, Pnt3f &flb,
117 Pnt3f &frt, Pnt3f &frb ) const;
119 /*! \} */
120 /*---------------------------------------------------------------------*/
121 /*! \name Get */
122 /*! \{ */
124 void setPlanes(const Plane &pnear, const Plane &pfar,
125 const Plane &left, const Plane &right,
126 const Plane &top, const Plane &bottom);
127 void setPlanes(const Pnt3f &nlt, const Pnt3f &nlb,
128 const Pnt3f &nrt, const Pnt3f &nrb,
129 const Pnt3f &flt, const Pnt3f &flb,
130 const Pnt3f &frt, const Pnt3f &frb );
131 void setPlanes(const Matrix &matrix );
133 /*! \} */
134 /*---------------------------------------------------------------------*/
135 /*! \name Extending */
136 /*! \{ */
138 virtual void extendBy(const Pnt3f &pt );
139 virtual void extendBy(const Volume &volume);
140 inline void extendBy(const FrustumVolume &bb );
142 /*! \} */
143 /*---------------------------------------------------------------------*/
144 /*! \name Intersection */
145 /*! \{ */
147 virtual bool intersect (const Pnt3f &point ) const;
148 virtual bool intersect (const Line &line ) const;
149 virtual bool intersect (const Line &line,
150 Real32 &minDist,
151 Real32 &maxDist) const;
152 virtual bool intersect (const Volume &volume ) const;
153 bool intersect (const FrustumVolume &bb ) const;
154 virtual bool isOnSurface(const Pnt3f &point ) const;
156 /*! \} */
157 /*---------------------------------------------------------------------*/
158 /*! \name Transformation */
159 /*! \{ */
161 virtual void transform(const Matrix &m);
163 /*! \} */
164 /*---------------------------------------------------------------------*/
165 /*! \name Operators */
166 /*! \{ */
168 FrustumVolume &operator = (const FrustumVolume &rhs);
170 bool operator ==(const FrustumVolume &rhs) const;
171 bool operator !=(const FrustumVolume &rhs) const;
173 /*! \} */
174 /*---------------------------------------------------------------------*/
175 /*! \name Output */
176 /*! \{ */
178 virtual void dump ( UInt32 uiIndent = 0,
179 const BitVector bvFlags = 0) const;
180 virtual void print(std::ostream &os ) const;
182 /*! \} */
183 /*========================= PROTECTED ===============================*/
185 protected:
187 typedef Volume Inherited;
189 enum
191 PLANE_NEAR = 0,
192 PLANE_FAR = 1,
193 PLANE_LEFT = 2,
194 PLANE_RIGHT = 3,
195 PLANE_TOP = 4,
196 PLANE_BOTTOM = 5
199 /*========================== PRIVATE ================================*/
201 private:
203 Plane _planeVec[6];
207 /*! \ingroup GrpBaseBaseVolume
208 \relatesalso FrustumVolume
210 OSG_BASE_DLLMAPPING
211 bool intersect(const OSG::FrustumVolume &frustum,
212 const OSG::Volume &vol,
213 OSG::FrustumVolume::PlaneSet &inplanes);
215 OSG_END_NAMESPACE
217 #include "OSGFrustumVolume.inl"
219 #endif /* _OSG_FRUSTUMVOLUME_H_ */