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_CLASS_DECLARATION
00040 #define OSGPLANE_CLASS_DECLARATION
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
00052 #ifdef WIN32 // Workaround for a bug in Visual C++ 6.0
00053 class Plane;
00054 OSG_BASE_DLLMAPPING
00055 bool operator ==(const Plane &p1, const Plane &p2);
00056 OSG_BASE_DLLMAPPING
00057 bool operator !=(const Plane &p1, const Plane &p2);
00058 #endif
00059
00060
00080 class OSG_BASE_DLLMAPPING Plane {
00081
00082
00083 public:
00084
00085
00089 Plane(void);
00090 Plane(const Plane &obj);
00091 Plane(const Pnt3f &p0, const Pnt3f &p1, const Pnt3f &p2);
00092 Plane(const Vec3f &n, Real32 d);
00093 Plane(const Vec3f &n, const Pnt3f &p);
00094
00096
00100 void offset(Real32 d);
00101
00103
00107 bool intersect (const Plane &pl, Line &intersection) const;
00108
00109 bool intersect (const Line &l, Pnt3f &intersection) const;
00110
00111 bool intersect (const Line &l, Real32 &t) const;
00112
00113 bool intersectInfinite (const Line &l, Real32 &t) const;
00114
00115 bool intersectInfinite (const Line &l, Pnt3f &intersection) const;
00116
00117
00118 void transform (const Matrix &matrix);
00119
00120 bool isInHalfSpace (const Pnt3f &point) const;
00121
00122 bool isOnPlane (const Pnt3f &point) const;
00123
00124 Real32 distance (const Pnt3f &point) const;
00125
00127
00131 void set(const Vec3f &normal, Real32 distance);
00132 void set(Real32 x, Real32 y, Real32 z, Real32 distance);
00133 void set(const Vec4f &plane);
00134
00136
00140 inline const Vec3f &getNormal (void) const;
00141 inline Real32 getDistanceFromOrigin (void) const;
00142
00144
00148 OSG_BASE_DLLMAPPING
00149 friend bool operator ==(const Plane &p1, const Plane &p2);
00150
00151 inline OSG_BASE_DLLMAPPING
00152 friend bool operator !=(const Plane &p1, const Plane &p2);
00153
00155
00156 private:
00157
00158 Vec3f _normalVec;
00159
00160 Real32 _distance;
00161
00162 };
00163
00164 OSG_BASE_DLLMAPPING ostream &operator <<(ostream &os, const Plane &obj);
00165
00166 OSG_END_NAMESPACE
00167
00168 #include "OSGPlane.inl"
00169
00170 #endif // OSGPLANE_CLASS_DECLARATION