Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
pmtools.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2002 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_PMTOOLS_H__ 00020 #define __CS_PMTOOLS_H__ 00021 00022 00023 #include "csextern.h" 00024 00025 #include "csgeom/polymesh.h" 00026 #include "csutil/array.h" 00027 00028 struct csTriangle; 00029 00036 class csVector3; 00037 class csPlane3; 00038 struct iPolygonMesh; 00039 00040 00044 struct CS_CRYSTALSPACE_EXPORT csPolygonMeshEdge 00045 { 00046 // Indices of the two vertices forming the edge. 00047 // vt1 < vt2. 00048 int vt1, vt2; 00049 // Indices of the two polygons sharing this edge. 00050 // If poly2 == -1 then this is an edge with only one polygon attached. 00051 int poly1, poly2; 00052 00053 // Active or not. If this flag is true the edge is active in the sense 00054 // that it actually connects two non-coplanar polygons (or is only 00055 // connected to one polygon). Edges that are not active are not relevant 00056 // for outline calculation. 00057 bool active; 00058 }; 00059 00063 struct CS_CRYSTALSPACE_EXPORT csTriangleMinMax : public csTriangle 00064 { 00065 float minx, maxx; 00066 }; 00067 00071 class CS_CRYSTALSPACE_EXPORT csPolygonMeshTools 00072 { 00073 private: 00074 static void CalculatePlanes (csVector3* vertices, 00075 csTriangleMinMax* tris, int num_tris, csPlane3* planes); 00076 00077 public: 00083 static void CalculateNormals (iPolygonMesh* mesh, csVector3* normals); 00084 00090 static void CalculatePlanes (iPolygonMesh* mesh, csPlane3* planes); 00091 00099 static csPolygonMeshEdge* CalculateEdges (iPolygonMesh*, int& num_edges); 00100 00106 static int CheckActiveEdges (csPolygonMeshEdge* edges, int num_edges, 00107 csPlane3* planes); 00108 00130 static void CalculateOutline (csPolygonMeshEdge* edges, int num_edges, 00131 csPlane3* planes, int num_vertices, 00132 const csVector3& pos, 00133 int* outline_edges, int& num_outline_edges, 00134 bool* outline_verts, 00135 float& valid_radius); 00136 00141 static bool IsMeshClosed (iPolygonMesh* polyMesh); 00142 00148 static bool IsMeshConvex (iPolygonMesh* polyMesh); 00149 00156 static void CloseMesh (iPolygonMesh* polyMesh, 00157 csArray<csMeshedPolygon>& newPolys, int*& vertidx, int& vertidx_len); 00158 00166 static void Triangulate (iPolygonMesh* polymesh, 00167 csTriangle*& tris, int& tri_count); 00168 00174 static void Polygonize (iPolygonMesh* polymesh, 00175 csMeshedPolygon*& polygons, int& poly_count); 00176 00185 static void SortTrianglesX (iPolygonMesh* polymesh, 00186 csTriangleMinMax*& tris, int& tri_count, 00187 csPlane3*& planes); 00188 00196 static bool PointInClosedMesh (const csVector3& point, 00197 csVector3* vertices, 00198 csTriangleMinMax* tris, int tri_count, 00199 csPlane3* planes); 00200 00213 static bool LineInClosedMesh (const csVector3& p1, const csVector3& p2, 00214 csVector3* vertices, 00215 csTriangleMinMax* tris, int tri_count, 00216 csPlane3* planes); 00217 00230 static bool BoxInClosedMesh (const csBox3& box, 00231 csVector3* vertices, 00232 csTriangleMinMax* tris, int tri_count, 00233 csPlane3* planes); 00234 }; 00235 00238 #endif // __CS_PMTOOLS_H__ 00239
Generated for Crystal Space by doxygen 1.4.4