1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2003 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
29 \*---------------------------------------------------------------------------*/
30 /*---------------------------------------------------------------------------*\
38 \*---------------------------------------------------------------------------*/
40 #ifndef _OSG_FRUSTUMVOLUME_H_
41 #define _OSG_FRUSTUMVOLUME_H_
43 #include "OSGVolume.h"
45 #include "OSGVolumeFunctions.h"
51 /*! \ingroup GrpBaseBase
52 \ingroup GrpBaseBaseVolume
53 \ingroup GrpLibOSGBase
56 class OSG_BASE_DLLMAPPING FrustumVolume
: public Volume
58 /*========================== PUBLIC =================================*/
62 /*---------------------------------------------------------------------*/
63 /*! \name Plane Selection */
73 P_ALL
= P_NEAR
| P_FAR
| P_LEFT
| P_RIGHT
| P_TOP
| P_BOTTOM
76 typedef UInt8 PlaneSet
;
79 /*---------------------------------------------------------------------*/
80 /*! \name Constructors */
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
);
90 /*---------------------------------------------------------------------*/
91 /*! \name Destructors */
97 /*---------------------------------------------------------------------*/
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
¢er
) 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;
120 /*---------------------------------------------------------------------*/
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
);
134 /*---------------------------------------------------------------------*/
135 /*! \name Extending */
138 virtual void extendBy(const Pnt3f
&pt
);
139 virtual void extendBy(const Volume
&volume
);
140 inline void extendBy(const FrustumVolume
&bb
);
143 /*---------------------------------------------------------------------*/
144 /*! \name Intersection */
147 virtual bool intersect (const Pnt3f
&point
) const;
148 virtual bool intersect (const Line
&line
) const;
149 virtual bool intersect (const Line
&line
,
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;
157 /*---------------------------------------------------------------------*/
158 /*! \name Transformation */
161 virtual void transform(const Matrix
&m
);
164 /*---------------------------------------------------------------------*/
165 /*! \name Operators */
168 FrustumVolume
&operator = (const FrustumVolume
&rhs
);
170 bool operator ==(const FrustumVolume
&rhs
) const;
171 bool operator !=(const FrustumVolume
&rhs
) const;
174 /*---------------------------------------------------------------------*/
178 virtual void dump ( UInt32 uiIndent
= 0,
179 const BitVector bvFlags
= 0) const;
180 virtual void print(std::ostream
&os
) const;
183 /*========================= PROTECTED ===============================*/
187 typedef Volume Inherited
;
199 /*========================== PRIVATE ================================*/
207 /*! \ingroup GrpBaseBaseVolume
208 \relatesalso FrustumVolume
211 bool intersect(const OSG::FrustumVolume
&frustum
,
212 const OSG::Volume
&vol
,
213 OSG::FrustumVolume::PlaneSet
&inplanes
);
217 #include "OSGFrustumVolume.inl"
219 #endif /* _OSG_FRUSTUMVOLUME_H_ */