00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_POLYPLANE_H__
00020 #define __CS_POLYPLANE_H__
00021
00022 #include "csgeom/math3d.h"
00023 #include "csgeom/transfrm.h"
00024
00030 class csPolyPlane
00031 {
00033 friend class csPolygon2D;
00035 friend class csPolyTexture;
00036
00037 private:
00039 csPlane3 plane_obj;
00041 csPlane3 plane_wor;
00043 csPlane3 plane_cam;
00045 int ref_count;
00046
00048 virtual ~csPolyPlane ();
00049
00050 public:
00052 csPolyPlane ();
00053
00055 void IncRef () { ref_count++; }
00057 void DecRef () { if (!--ref_count) delete this; }
00058
00065 void ObjectToWorld (
00066 const csReversibleTransform& obj,
00067 const csVector3& vertex1);
00068
00075 void WorldToCamera (
00076 const csReversibleTransform& t,
00077 const csVector3& vertex1);
00078
00083 float SquaredDistance (csVector3& v) const
00084 {
00085 float d = plane_wor.Distance (v);
00086 return d*d;
00087 }
00088
00094 bool NearlyEqual (csPolyPlane* plane) const
00095 {
00096 return csMath3::PlanesEqual (plane_wor, plane->plane_wor);
00097 }
00098
00103 void ClosestPoint (csVector3& v, csVector3& isect) const;
00104
00112 bool IntersectSegment (const csVector3& start, const csVector3& end,
00113 csVector3& isect, float* pr) const;
00114
00118 csPlane3& GetObjectPlane () { return plane_obj; }
00119
00123 const csPlane3& GetObjectPlane () const { return plane_obj; }
00124
00128 csPlane3& GetWorldPlane () { return plane_wor; }
00129
00133 const csPlane3& GetWorldPlane () const { return plane_wor; }
00134
00138 csPlane3& GetCameraPlane () { return plane_cam; }
00139
00143 const csPlane3& GetCameraPlane () const { return plane_cam; }
00144
00148 void GetObjectNormal (float* p_A, float* p_B, float* p_C, float* p_D) const;
00149
00153 void GetWorldNormal (float* p_A, float* p_B, float* p_C, float* p_D) const;
00154
00158 void GetCameraNormal (float* p_A, float* p_B, float* p_C, float* p_D) const;
00159 };
00160
00161 #endif // __CS_POLYPLANE_H__