CrystalSpace

Public API Reference

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 "csgeom/pmtools.h"
00027 #include "csutil/array.h"
00028 
00029 struct csTriangle;
00030 
00038 class csVector3;
00039 class csPlane3;
00040 struct iTriangleMesh;
00041 
00045 struct CS_CRYSTALSPACE_EXPORT csTriangleMeshEdge
00046 {
00051   int vt1, vt2;
00056   int tri1, tri2;
00057 
00064   bool active;
00065 };
00066 
00070 class CS_CRYSTALSPACE_EXPORT csTriangleMeshTools
00071 {
00072 private:
00073   static void CalculatePlanes (csVector3* vertices,
00074         csTriangleMinMax* tris, size_t num_tris, csPlane3* planes);
00075 
00076 public:
00082   static void CalculateNormals (iTriangleMesh* mesh, csVector3* normals);
00083 
00089   static void CalculatePlanes (iTriangleMesh* mesh, csPlane3* planes);
00090 
00098   static csTriangleMeshEdge* CalculateEdges (iTriangleMesh*, size_t& num_edges);
00099 
00105   static size_t CheckActiveEdges (csTriangleMeshEdge* edges, size_t num_edges,
00106         csPlane3* planes);
00107 
00129   static void CalculateOutline (csTriangleMeshEdge* edges, size_t num_edges,
00130         csPlane3* planes, size_t num_vertices,
00131         const csVector3& pos,
00132         size_t* outline_edges, size_t& num_outline_edges,
00133         bool* outline_verts,
00134         float& valid_radius);
00135 
00140   static bool IsMeshClosed (iTriangleMesh* trimesh);
00141 
00147   static bool IsMeshConvex (iTriangleMesh* trimesh);
00148 
00154   static void CloseMesh (iTriangleMesh* trimesh, csArray<csTriangle>& newtris);
00155 
00164   static void SortTrianglesX (iTriangleMesh* trimesh,
00165         csTriangleMinMax*& tris, size_t& tri_count,
00166         csPlane3*& planes);
00167 
00175   static bool PointInClosedMesh (const csVector3& point,
00176         csVector3* vertices,
00177         csTriangleMinMax* tris, int tri_count,
00178         csPlane3* planes);
00179 
00192   static bool LineInClosedMesh (const csVector3& p1, const csVector3& p2,
00193         csVector3* vertices,
00194         csTriangleMinMax* tris, int tri_count,
00195         csPlane3* planes);
00196 
00209   static bool BoxInClosedMesh (const csBox3& box,
00210         csVector3* vertices,
00211         csTriangleMinMax* tris, int tri_count,
00212         csPlane3* planes);
00213 
00218   static csArray<csArray<int> > *CalculateVertexConnections (
00219                                                 iTriangleMesh* mesh);
00220 };
00221 
00224 #endif // __CS_TRIMESHTOOLS_H__
00225 

Generated for Crystal Space 1.2.1 by doxygen 1.5.3