Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | 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 00028 class csVector3; 00029 class csPlane3; 00030 struct iPolygonMesh; 00031 00032 #include "csextern.h" 00033 00034 #include "csutil/array.h" 00035 #include "csgeom/polymesh.h" 00036 00040 struct CS_CSGEOM_EXPORT csPolygonMeshEdge 00041 { 00042 // Indices of the two vertices forming the edge. 00043 // vt1 < vt2. 00044 int vt1, vt2; 00045 // Indices of the two polygons sharing this edge. 00046 // If poly2 == -1 then this is an edge with only one polygon attached. 00047 int poly1, poly2; 00048 00049 // Active or not. If this flag is true the edge is active in the sense 00050 // that it actually connects two non-coplanar polygons (or is only 00051 // connected to one polygon). Edges that are not active are not relevant 00052 // for outline calculation. 00053 bool active; 00054 }; 00055 00059 struct CS_CSGEOM_EXPORT csTriangleMinMax : public csTriangle 00060 { 00061 float minx, maxx; 00062 }; 00063 00067 class CS_CSGEOM_EXPORT csPolygonMeshTools 00068 { 00069 private: 00070 static void CalculatePlanes (csVector3* vertices, 00071 csTriangleMinMax* tris, int num_tris, csPlane3* planes); 00072 00073 public: 00079 static void CalculateNormals (iPolygonMesh* mesh, csVector3* normals); 00080 00086 static void CalculatePlanes (iPolygonMesh* mesh, csPlane3* planes); 00087 00095 static csPolygonMeshEdge* CalculateEdges (iPolygonMesh*, int& num_edges); 00096 00102 static int CheckActiveEdges (csPolygonMeshEdge* edges, int num_edges, 00103 csPlane3* planes); 00104 00126 static void CalculateOutline (csPolygonMeshEdge* edges, int num_edges, 00127 csPlane3* planes, int num_vertices, 00128 const csVector3& pos, 00129 int* outline_edges, int& num_outline_edges, 00130 bool* outline_verts, 00131 float& valid_radius); 00132 00137 static bool IsMeshClosed (iPolygonMesh* polyMesh); 00138 00144 static bool IsMeshConvex (iPolygonMesh* polyMesh); 00145 00152 static void CloseMesh (iPolygonMesh* polyMesh, 00153 csArray<csMeshedPolygon>& newPolys, int*& vertidx, int& vertidx_len); 00154 00162 static void Triangulate (iPolygonMesh* polymesh, 00163 csTriangle*& tris, int& tri_count); 00164 00170 static void Polygonize (iPolygonMesh* polymesh, 00171 csMeshedPolygon*& polygons, int& poly_count); 00172 00181 static void SortTrianglesX (iPolygonMesh* polymesh, 00182 csTriangleMinMax*& tris, int& tri_count, 00183 csPlane3*& planes); 00184 00192 static bool PointInClosedMesh (const csVector3& point, 00193 csVector3* vertices, 00194 csTriangleMinMax* tris, int tri_count, 00195 csPlane3* planes); 00196 00209 static bool LineInClosedMesh (const csVector3& p1, const csVector3& p2, 00210 csVector3* vertices, 00211 csTriangleMinMax* tris, int tri_count, 00212 csPlane3* planes); 00213 00226 static bool BoxInClosedMesh (const csBox3& box, 00227 csVector3* vertices, 00228 csTriangleMinMax* tris, int tri_count, 00229 csPlane3* planes); 00230 }; 00231 00234 #endif // __CS_PMTOOLS_H__ 00235
Generated for Crystal Space by doxygen 1.3.9.1