| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# 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 struct csTriangle;
    00029
    00037 class csVector3;
    00038 class csPlane3;
    00039 struct iPolygonMesh;
    00040
    00041
    00045 struct CS_CRYSTALSPACE_EXPORT csPolygonMeshEdge
    00046 {
    00051   int vt1, vt2;
    00056   int poly1, poly2;
    00057
    00064   bool active;
    00065 };
    00066
    00070 struct CS_CRYSTALSPACE_EXPORT csTriangleMinMax : public csTriangle
    00071 {
    00072   float minx, maxx;
    00073 };
    00074
    00078 class CS_CRYSTALSPACE_EXPORT csPolygonMeshTools
    00079 {
    00080 private:
    00081   static void CalculatePlanes (csVector3* vertices,
    00082         csTriangleMinMax* tris, int num_tris, csPlane3* planes);
    00083
    00084 public:
    00090   static void CalculateNormals (iPolygonMesh* mesh, csVector3* normals);
    00091
    00097   static void CalculatePlanes (iPolygonMesh* mesh, csPlane3* planes);
    00098
    00106   static csPolygonMeshEdge* CalculateEdges (iPolygonMesh*, int& num_edges);
    00107
    00113   static int CheckActiveEdges (csPolygonMeshEdge* edges, int num_edges,
    00114         csPlane3* planes);
    00115
    00137   static void CalculateOutline (csPolygonMeshEdge* edges, int num_edges,
    00138         csPlane3* planes, int num_vertices,
    00139         const csVector3& pos,
    00140         int* outline_edges, int& num_outline_edges,
    00141         bool* outline_verts,
    00142         float& valid_radius);
    00143
    00148   static bool IsMeshClosed (iPolygonMesh* polyMesh);
    00149
    00155   static bool IsMeshConvex (iPolygonMesh* polyMesh);
    00156
    00163   static void CloseMesh (iPolygonMesh* polyMesh,
    00164     csArray<csMeshedPolygon>& newPolys, int*& vertidx, int& vertidx_len);
    00165
    00173   static void Triangulate (iPolygonMesh* polymesh,
    00174         csTriangle*& tris, int& tri_count);
    00175
    00181   static void Polygonize (iPolygonMesh* polymesh,
    00182         csMeshedPolygon*& polygons, int& poly_count);
    00183
    00192   static void SortTrianglesX (iPolygonMesh* polymesh,
    00193         csTriangleMinMax*& tris, int& tri_count,
    00194         csPlane3*& planes);
    00195
    00203   static bool PointInClosedMesh (const csVector3& point,
    00204         csVector3* vertices,
    00205         csTriangleMinMax* tris, int tri_count,
    00206         csPlane3* planes);
    00207
    00220   static bool LineInClosedMesh (const csVector3& p1, const csVector3& p2,
    00221         csVector3* vertices,
    00222         csTriangleMinMax* tris, int tri_count,
    00223         csPlane3* planes);
    00224
    00237   static bool BoxInClosedMesh (const csBox3& box,
    00238         csVector3* vertices,
    00239         csTriangleMinMax* tris, int tri_count,
    00240         csPlane3* planes);
    00241 };
    00242
    00245 #endif // __CS_PMTOOLS_H__
    00246