CrystalSpace

Public API Reference

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

trimesh.h

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_TRIMESH_H__
00020 #define __CS_TRIMESH_H__
00021 
00022 #include "csextern.h"
00023 
00024 #include "csgeom/tri.h"
00025 #include "csgeom/math3d.h"
00026 #include "csutil/array.h"
00027 #include "csutil/dirtyaccessarray.h"
00028 
00034 class CS_CSGEOM_EXPORT csTriangleMesh
00035 {
00036 protected:
00038   csDirtyAccessArray<csTriangle> triangles;
00039 
00040 public:
00042   csTriangleMesh () { }
00044   csTriangleMesh (const csTriangleMesh& mesh);
00046   ~csTriangleMesh ();
00047 
00049   void AddTriangle (int a, int b, int c);
00051   csTriangle* GetTriangles () { return triangles.GetArray (); }
00053   const csTriangle* GetTriangles () const { return triangles.GetArray (); }
00055   csTriangle& GetTriangle (int i) { return triangles[i]; }
00057   size_t GetTriangleCount () const { return triangles.Length (); }
00058 
00060   void Clear ();
00062   void SetSize (int count);
00064   void SetTriangles (csTriangle const* trigs, int count);
00065 };
00066 
00072 class CS_CSGEOM_EXPORT csTriangleVertex
00073 {
00074 public:
00076   csVector3 pos;
00078   int idx;
00079 
00081   csArray<size_t> con_triangles;
00082 
00084   csArray<int> con_vertices;
00085 
00087   csTriangleVertex () { }
00089   ~csTriangleVertex () { }
00091   void AddTriangle (size_t idx);
00093   void AddVertex (int idx);
00094 };
00095 
00100 class CS_CSGEOM_EXPORT csTriangleVertices
00101 {
00102 protected:
00103   csTriangleVertex* vertices;
00104   int num_vertices;
00105 
00106 public:
00108   csTriangleVertices (csTriangleMesh* mesh, csVector3* verts, int num_verts);
00110   ~csTriangleVertices ();
00115   void UpdateVertices (csVector3* verts);
00116 
00118   int GetVertexCount () const { return num_vertices; }
00120   csTriangleVertex& GetVertex (int idx) { return vertices[idx]; }
00121 };
00122 
00123 #endif // __CS_TRIMESH_H__
00124 

Generated for Crystal Space by doxygen 1.3.9.1