csgeom/trimeshtools.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2007 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_TRIMESHTOOLS_H__ 00020 #define __CS_TRIMESHTOOLS_H__ 00021 00022 00023 #include "csextern.h" 00024 00025 #include "csgeom/trimesh.h" 00026 #include "csutil/array.h" 00027 00028 struct csTriangle; 00029 00033 struct CS_CRYSTALSPACE_EXPORT csTriangleMinMax : public csTriangle 00034 { 00035 float minx, maxx; 00036 }; 00037 00045 class csVector3; 00046 class csPlane3; 00047 struct iTriangleMesh; 00048 00052 struct CS_CRYSTALSPACE_EXPORT csTriangleMeshEdge : 00053 public CS::Memory::CustomAllocated 00054 { 00059 int vt1, vt2; 00064 int tri1, tri2; 00065 00072 bool active; 00073 }; 00074 00078 class CS_CRYSTALSPACE_EXPORT csTriangleMeshTools 00079 { 00080 private: 00081 static void CalculatePlanes (csVector3* vertices, 00082 csTriangleMinMax* tris, size_t num_tris, csPlane3* planes); 00083 00084 public: 00090 static void CalculateNormals (iTriangleMesh* mesh, csVector3* normals); 00091 00097 static void CalculatePlanes (iTriangleMesh* mesh, csPlane3* planes); 00098 00106 static csTriangleMeshEdge* CalculateEdges (iTriangleMesh*, size_t& num_edges); 00107 00113 static size_t CheckActiveEdges (csTriangleMeshEdge* edges, size_t num_edges, 00114 csPlane3* planes); 00115 00137 static void CalculateOutline (csTriangleMeshEdge* edges, size_t num_edges, 00138 csPlane3* planes, size_t num_vertices, 00139 const csVector3& pos, 00140 size_t* outline_edges, size_t& num_outline_edges, 00141 bool* outline_verts, 00142 float& valid_radius); 00143 00148 static bool IsMeshClosed (iTriangleMesh* trimesh); 00149 00155 static bool IsMeshConvex (iTriangleMesh* trimesh); 00156 00162 static void CloseMesh (iTriangleMesh* trimesh, csArray<csTriangle>& newtris); 00163 00172 static void SortTrianglesX (iTriangleMesh* trimesh, 00173 csTriangleMinMax*& tris, size_t& tri_count, 00174 csPlane3*& planes); 00175 00183 static bool PointInClosedMesh (const csVector3& point, 00184 csVector3* vertices, 00185 csTriangleMinMax* tris, size_t tri_count, 00186 csPlane3* planes); 00187 00200 static bool LineInClosedMesh (const csVector3& p1, const csVector3& p2, 00201 csVector3* vertices, 00202 csTriangleMinMax* tris, size_t tri_count, 00203 csPlane3* planes); 00204 00217 static bool BoxInClosedMesh (const csBox3& box, 00218 csVector3* vertices, 00219 csTriangleMinMax* tris, size_t tri_count, 00220 csPlane3* planes); 00221 00226 static csArray<csArray<int> > *CalculateVertexConnections ( 00227 iTriangleMesh* mesh); 00228 }; 00229 00232 #endif // __CS_TRIMESHTOOLS_H__ 00233
Generated for Crystal Space 2.0 by doxygen 1.6.1