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 #ifndef _OSGPLANE_H_
00040 #define _OSGPLANE_H_
00041
00042 #include <OSGBaseTypes.h>
00043 #include <OSGBaseFunctions.h>
00044
00045 #include <OSGVector.h>
00046 #include <OSGMatrix.h>
00047
00048 OSG_BEGIN_NAMESPACE
00049
00050 class Line;
00051
00055 class OSG_BASE_DLLMAPPING Plane
00056 {
00057
00058
00059 public:
00060
00061
00065 Plane( void );
00066 Plane(const Plane &obj );
00067 Plane(const Pnt3f &p0, const Pnt3f &p1, const Pnt3f &p2);
00068 Plane(const Vec3f &n, Real32 d );
00069 Plane(const Vec3f &n, const Pnt3f &p );
00070
00072
00076 ~Plane(void);
00077
00079
00083 void offset(Real32 d);
00084
00086
00090 bool intersect (const Plane &pl, Line &intersection) const;
00091 bool intersect (const Line &l, Pnt3f &intersection) const;
00092 bool intersect (const Line &l, Real32 &t ) const;
00093
00094 bool intersectInfinite(const Line &l, Real32 &t ) const;
00095 bool intersectInfinite(const Line &l, Pnt3f &intersection) const;
00096
00097 void transform (const Matrix &matrix );
00098
00099 int clip (Pnt3f *polyIn, Pnt3f *polyOut, int count) const;
00100
00101 inline bool isOnPlane (const Pnt3f &point ) const;
00102 inline bool isInHalfSpace (const Pnt3f &point ) const;
00103 inline Real32 distance (const Pnt3f &point ) const;
00104
00105 inline bool isInHalfSpace (const Pnt3f &min, const Pnt3f &max) const;
00106 inline bool isOutHalfSpace (const Pnt3f &min, const Pnt3f &max) const;
00107
00109
00113 inline void set(const Vec3f &normal,
00114 Real32 distance);
00115 inline void set( Real32 x,
00116 Real32 y,
00117 Real32 z,
00118 Real32 distance);
00119 inline void set(const Vec4f &plane );
00120
00122
00126 inline const Vec3f &getNormal (void) const;
00127 inline Real32 getDistanceFromOrigin(void) const;
00128
00129
00130 inline void setDirectionIndexPoint(
00131 const Pnt3f &min, const Pnt3f & max,
00132 const UInt8 index, Pnt3f & pnt) const;
00133
00135
00139 OSG_BASE_DLLMAPPING
00140 friend bool operator ==(const Plane &p1, const Plane &p2);
00141
00142 inline
00143 friend bool operator !=(const Plane &p1, const Plane &p2);
00144
00146
00147
00148 private:
00149
00150 void updateDirectionIndex(void);
00151
00152 Vec3f _normalVec;
00153 Real32 _distance;
00154 UInt8 _directionIndex;
00155 };
00156
00157 OSG_BASE_DLLMAPPING
00158 std::ostream &operator <<( std::ostream &os,
00159 const Plane &obj);
00160
00161 OSG_END_NAMESPACE
00162
00163 #include "OSGPlane.inl"
00164
00165 #endif // _OSG_PLANE_H_