00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef _OSG_FRUSTUMVOLUME_H_
00041 #define _OSG_FRUSTUMVOLUME_H_
00042
00043 #include "OSGConfig.h"
00044 #include "OSGBase.h"
00045 #include "OSGVolume.h"
00046 #include "OSGPlane.h"
00047 #include "OSGMatrix.h"
00048
00049 OSG_BEGIN_NAMESPACE
00050
00054 class OSG_BASE_DLLMAPPING FrustumVolume : public Volume
00055 {
00056
00057
00058 public:
00059
00060
00064 enum { P_NONE = 0,
00065 P_NEAR = 1,
00066 P_FAR = 2,
00067 P_LEFT = 4,
00068 P_RIGHT = 8,
00069 P_TOP = 16,
00070 P_BOTTOM = 32,
00071 P_ALL = P_NEAR | P_FAR | P_LEFT | P_RIGHT | P_TOP | P_BOTTOM
00072 };
00073
00074 typedef UInt8 PlaneSet;
00075
00077
00081 FrustumVolume( void );
00082 FrustumVolume(const Plane &pnear, const Plane &pfar,
00083 const Plane &left, const Plane &right,
00084 const Plane &top, const Plane &bottom);
00085 FrustumVolume(const FrustumVolume &obj );
00086
00088
00092 ~FrustumVolume(void);
00093
00095
00099 const Plane &getNear (void ) const;
00100 const Plane &getFar (void ) const;
00101 const Plane &getLeft (void ) const;
00102 const Plane &getRight (void ) const;
00103 const Plane &getTop (void ) const;
00104 const Plane &getBottom (void ) const;
00105 const Plane *getPlanes (void ) const;
00106
00107 virtual void getCenter (Pnt3f ¢er) const;
00108 virtual Real32 getScalarVolume(void ) const;
00109 virtual void getBounds (Pnt3f &minPnt,
00110 Pnt3f &maxPnt) const;
00111
00113
00117 void setPlanes(const Plane &pnear, const Plane &pfar,
00118 const Plane &left, const Plane &right,
00119 const Plane &top, const Plane &bottom);
00120 void setPlanes(const Pnt3f &nlt, const Pnt3f &nlb,
00121 const Pnt3f &nrt, const Pnt3f &nrb,
00122 const Pnt3f &flt, const Pnt3f &flb,
00123 const Pnt3f &frt, const Pnt3f &frb );
00124 void setPlanes(const Matrix &matrix );
00125
00127
00131 virtual void extendBy(const Pnt3f &pt );
00132 virtual void extendBy(const Volume &volume);
00133 inline void extendBy(const FrustumVolume &bb );
00134
00136
00140 virtual bool intersect (const Pnt3f &point ) const;
00141 virtual bool intersect (const Line &line ) const;
00142 virtual bool intersect (const Line &line,
00143 Real32 &minDist,
00144 Real32 &maxDist) const;
00145 virtual bool intersect (const Volume &volume ) const;
00146 bool intersect (const FrustumVolume &bb ) const;
00147 virtual bool isOnSurface(const Pnt3f &point ) const;
00148
00150
00154 virtual void transform(const Matrix &m);
00155
00157
00161 const FrustumVolume &operator =(const FrustumVolume &b1);
00162
00164
00168 virtual void dump( UInt32 uiIndent = 0,
00169 const BitVector bvFlags = 0) const;
00170
00172
00173
00174 protected:
00175
00176
00177
00178 private:
00179
00180 Plane _planeVec[6];
00181
00182 };
00183
00184 OSG_BASE_DLLMAPPING
00185 bool operator ==(const FrustumVolume &b1, const FrustumVolume &b2);
00186
00187 inline
00188 bool operator !=(const FrustumVolume &b1, const FrustumVolume &b2);
00189
00190 OSG_BASE_DLLMAPPING
00191 bool intersect(const FrustumVolume &frustum, const Volume &vol,
00192 FrustumVolume::PlaneSet &inplanes);
00193
00194 OSG_END_NAMESPACE
00195
00196 #include <OSGFrustumVolume.inl>
00197
00198 #endif
00199