CrystalSpace

Public API Reference

csgeom/trimesh.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_TRIMESH_H__
00020 #define __CS_TRIMESH_H__
00021 
00022 #include "csextern.h"
00023 
00024 #include "csgeom/tri.h"
00025 #include "csgeom/vector3.h"
00026 
00027 #include "csutil/array.h"
00028 #include "csutil/dirtyaccessarray.h"
00029 
00041 class CS_CRYSTALSPACE_EXPORT csTriangleMesh
00042 {
00043 protected:
00045   csDirtyAccessArray<csTriangle> triangles;
00046 
00047 public:
00049   csTriangleMesh () { }
00051   csTriangleMesh (const csTriangleMesh& mesh);
00053   ~csTriangleMesh ();
00054 
00056   void AddTriangle (int a, int b, int c);
00058   csTriangle* GetTriangles () { return triangles.GetArray (); }
00060   const csTriangle* GetTriangles () const { return triangles.GetArray (); }
00062   csTriangle& GetTriangle (int i) { return triangles[i]; }
00064   size_t GetTriangleCount () const { return triangles.Length (); }
00065 
00067   void Clear ();
00069   void SetSize (int count);
00071   void SetTriangles (csTriangle const* trigs, int count);
00072 };
00073 
00079 class CS_CRYSTALSPACE_EXPORT csTriangleVertex
00080 {
00081 public:
00083   csVector3 pos;
00085   int idx;
00086 
00088   csArray<size_t> con_triangles;
00089 
00091   csArray<int> con_vertices;
00092 
00094   csTriangleVertex () { }
00096   ~csTriangleVertex () { }
00098   void AddTriangle (size_t idx);
00100   void AddVertex (int idx);
00101 };
00102 
00107 class CS_CRYSTALSPACE_EXPORT csTriangleVertices
00108 {
00109 protected:
00110   csTriangleVertex* vertices;
00111   int num_vertices;
00112 
00113 public:
00115   csTriangleVertices (csTriangleMesh* mesh, csVector3* verts, int num_verts);
00117   ~csTriangleVertices ();
00122   void UpdateVertices (csVector3* verts);
00123 
00125   int GetVertexCount () const { return num_vertices; }
00127   csTriangleVertex& GetVertex (int idx) { return vertices[idx]; }
00128 };
00129 
00132 #endif // __CS_TRIMESH_H__
00133 

Generated for Crystal Space 1.0.2 by doxygen 1.4.7