CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 
00028 class csVector3;
00029 class csPlane3;
00030 struct iPolygonMesh;
00031 
00032 #include "csutil/array.h"
00033 #include "csgeom/polymesh.h"
00034 
00038 struct csPolygonMeshEdge
00039 {
00040   // Indices of the two vertices forming the edge.
00041   // vt1 < vt2.
00042   int vt1, vt2;
00043   // Indices of the two polygons sharing this edge.
00044   // If poly2 == -1 then this is an edge with only one polygon attached.
00045   int poly1, poly2;
00046 
00047   // Active or not. If this flag is true the edge is active in the sense
00048   // that it actually connects two non-coplanar polygons (or is only
00049   // connected to one polygon). Edges that are not active are not relevant
00050   // for outline calculation.
00051   bool active;
00052 };
00053 
00057 class csPolygonMeshTools
00058 {
00059 public:
00065   static void CalculateNormals (iPolygonMesh* mesh, csVector3* normals);
00066 
00072   static void CalculatePlanes (iPolygonMesh* mesh, csPlane3* planes);
00073 
00081   static csPolygonMeshEdge* CalculateEdges (iPolygonMesh*, int& num_edges);
00082 
00088   static int CheckActiveEdges (csPolygonMeshEdge* edges, int num_edges,
00089         csPlane3* planes);
00090 
00112   static void CalculateOutline (csPolygonMeshEdge* edges, int num_edges,
00113         csPlane3* planes, int num_vertices,
00114         const csVector3& pos,
00115         int* outline_edges, int& num_outline_edges,
00116         bool* outline_verts,
00117         float& valid_radius);
00118 
00123   static bool IsMeshClosed (iPolygonMesh* polyMesh);
00124 
00131   static void CloseMesh (iPolygonMesh* polyMesh, 
00132     csArray<csMeshedPolygon>& newPolys, int*& vertidx, int& vertidx_len);
00133 
00138   static void Triangulate (iPolygonMesh* polymesh,
00139         csTriangle*& tris, int& tri_count);
00140 
00146   static void Polygonize (iPolygonMesh* polymesh,
00147         csMeshedPolygon*& polygons, int& poly_count);
00148 };
00149 
00152 #endif // __CS_PMTOOLS_H__
00153 

Generated for Crystal Space by doxygen 1.2.18