00001 /* 00002 00003 ZMACHINE 2.0 (SIGFRID) 00004 00005 CPOLYGON.H 00006 00007 author: Trombetta Roberto 00008 filename: CPolygon.h 00009 description: header file for polygon class 00010 date: 07/04/2003 00011 00012 */ 00013 00014 #ifndef __CPOLYGON_H_ 00015 #define __CPOLYGON_H_ 00016 00017 #include "CVector3.h" 00018 #include "CVectorTex3.h" 00019 #include "CPlane.h" 00020 #include "Zdef.h" 00021 #include "Zmacro.h" 00022 00024 00026 #define ZD_POLYGON_MAX_POLYGON_VERTICES 16 00027 #define ZD_POLYGON_MAX_COORD_X 0 00028 #define ZD_POLYGON_MAX_COORD_Y 1 00029 #define ZD_POLYGON_MAX_COORD_Z 2 00030 #define ZD_POLYGON_CLIP_COINCIDENT 0 00031 #define ZD_POLYGON_CLIP_ALLIN 1 00032 #define ZD_POLYGON_CLIP_ALLOUT 2 00033 #define ZD_POLYGON_CLIP_CLIPPED 3 00034 #define ZD_POLYGON_CLIP_ERROR -1 00035 #define ZD_POLYGON_CLIP_EPSILON 0.000001 00036 #define ZD_POLYGON_MAX_INT 16535 00037 00038 class CPolygon { 00039 00040 public: 00041 00043 zulong uliNumvertex; 00045 CVectorTex3 vertex[ZD_POLYGON_MAX_POLYGON_VERTICES]; 00046 00048 CPolygon (); 00050 CPolygon (zulong n); 00052 CPolygon (const CPolygon &poly); 00054 CPolygon& operator= (const CPolygon &poly); 00056 CVector3 Norm () const; 00058 CVector3 NormUnit () const; 00060 void RotateVertex (); 00062 zfloat Dist (const CVector3 &v) const; 00064 CPlane GetPlane() const; 00066 // #TO DO: could be improved !!! 00079 zbool IsInside (const CVector3 &v) const; 00081 zfloat MinX () const; 00083 zfloat MinY () const; 00085 zfloat MinZ () const; 00087 zfloat MaxX () const; 00089 zfloat MaxY () const; 00091 zfloat MaxZ () const; 00093 CVector3 ClosestPointOnPoly (const CVector3 &p) const; 00095 zuint MaxNormCoord () const; 00097 zuint ClipToPlane (const CPlane &p); 00099 00103 zbool PolyIsInside (const CPlane &p) const; 00104 }; 00105 00106 #endif // __CPOLYGON_H_