CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | 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/vector3.h"
00026 
00027 #include "csutil/array.h"
00028 #include "csutil/dirtyaccessarray.h"
00029 
00035 class CS_CRYSTALSPACE_EXPORT csTriangleMesh
00036 {
00037 protected:
00039   csDirtyAccessArray<csTriangle> triangles;
00040 
00041 public:
00043   csTriangleMesh () { }
00045   csTriangleMesh (const csTriangleMesh& mesh);
00047   ~csTriangleMesh ();
00048 
00050   void AddTriangle (int a, int b, int c);
00052   csTriangle* GetTriangles () { return triangles.GetArray (); }
00054   const csTriangle* GetTriangles () const { return triangles.GetArray (); }
00056   csTriangle& GetTriangle (int i) { return triangles[i]; }
00058   size_t GetTriangleCount () const { return triangles.Length (); }
00059 
00061   void Clear ();
00063   void SetSize (int count);
00065   void SetTriangles (csTriangle const* trigs, int count);
00066 };
00067 
00073 class CS_CRYSTALSPACE_EXPORT csTriangleVertex
00074 {
00075 public:
00077   csVector3 pos;
00079   int idx;
00080 
00082   csArray<size_t> con_triangles;
00083 
00085   csArray<int> con_vertices;
00086 
00088   csTriangleVertex () { }
00090   ~csTriangleVertex () { }
00092   void AddTriangle (size_t idx);
00094   void AddVertex (int idx);
00095 };
00096 
00101 class CS_CRYSTALSPACE_EXPORT csTriangleVertices
00102 {
00103 protected:
00104   csTriangleVertex* vertices;
00105   int num_vertices;
00106 
00107 public:
00109   csTriangleVertices (csTriangleMesh* mesh, csVector3* verts, int num_verts);
00111   ~csTriangleVertices ();
00116   void UpdateVertices (csVector3* verts);
00117 
00119   int GetVertexCount () const { return num_vertices; }
00121   csTriangleVertex& GetVertex (int idx) { return vertices[idx]; }
00122 };
00123 
00124 #endif // __CS_TRIMESH_H__
00125 

Generated for Crystal Space by doxygen 1.4.4