CrystalSpace

Public API Reference

csgeom/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 #include "csutil/win32/msvc_deprecated_warn_off.h"
00029 
00030 struct csTriangle;
00031 
00039 class csVector3;
00040 class csPlane3;
00041 struct iPolygonMesh;
00042 
00043 
00048 struct CS_DEPRECATED_TYPE_MSG("csPolygonMeshEdge is deprecated; use csTriangleMeshEdge instead") CS_CRYSTALSPACE_EXPORT csPolygonMeshEdge
00049 {
00054   int vt1, vt2;
00059   int poly1, poly2;
00060 
00067   bool active;
00068 };
00069 
00073 struct CS_CRYSTALSPACE_EXPORT csTriangleMinMax : public csTriangle
00074 {
00075   float minx, maxx;
00076 };
00077 
00082 class CS_DEPRECATED_TYPE_MSG("csPolygonMeshTools is deprecated; use csTriangleMeshTools instead") CS_CRYSTALSPACE_EXPORT csPolygonMeshTools
00083 {
00084 private:
00085   static void CalculatePlanes (csVector3* vertices,
00086         csTriangleMinMax* tris, int num_tris, csPlane3* planes);
00087 
00088 public:
00094   static void CalculateNormals (iPolygonMesh* mesh, csVector3* normals);
00095 
00101   static void CalculatePlanes (iPolygonMesh* mesh, csPlane3* planes);
00102 
00110   static csPolygonMeshEdge* CalculateEdges (iPolygonMesh*, int& num_edges);
00111 
00117   static int CheckActiveEdges (csPolygonMeshEdge* edges, int num_edges,
00118         csPlane3* planes);
00119 
00141   static void CalculateOutline (csPolygonMeshEdge* edges, int num_edges,
00142         csPlane3* planes, int num_vertices,
00143         const csVector3& pos,
00144         int* outline_edges, int& num_outline_edges,
00145         bool* outline_verts,
00146         float& valid_radius);
00147 
00152   static bool IsMeshClosed (iPolygonMesh* polyMesh);
00153 
00159   static bool IsMeshConvex (iPolygonMesh* polyMesh);
00160 
00167   static void CloseMesh (iPolygonMesh* polyMesh, 
00168     csArray<csMeshedPolygon>& newPolys, int*& vertidx, int& vertidx_len);
00169 
00177   static void Triangulate (iPolygonMesh* polymesh,
00178         csTriangle*& tris, int& tri_count);
00179 
00185   static void Polygonize (iPolygonMesh* polymesh,
00186         csMeshedPolygon*& polygons, int& poly_count);
00187 
00196   static void SortTrianglesX (iPolygonMesh* polymesh,
00197         csTriangleMinMax*& tris, int& tri_count,
00198         csPlane3*& planes);
00199 
00207   static bool PointInClosedMesh (const csVector3& point,
00208         csVector3* vertices,
00209         csTriangleMinMax* tris, int tri_count,
00210         csPlane3* planes);
00211 
00224   static bool LineInClosedMesh (const csVector3& p1, const csVector3& p2,
00225         csVector3* vertices,
00226         csTriangleMinMax* tris, int tri_count,
00227         csPlane3* planes);
00228 
00241   static bool BoxInClosedMesh (const csBox3& box,
00242         csVector3* vertices,
00243         csTriangleMinMax* tris, int tri_count,
00244         csPlane3* planes);
00245 
00246   /* Create a table of vertex connections for this mesh. The resulting
00247    * data structure must be freed by user after using it. 
00248    */
00249   static csArray<csArray<int> > *CalculateVertexConnections (
00250                                                 iPolygonMesh* mesh);
00251 };
00252 
00253 #include "csutil/win32/msvc_deprecated_warn_on.h"
00254 
00257 #endif // __CS_PMTOOLS_H__
00258 

Generated for Crystal Space 1.2.1 by doxygen 1.5.3