usata-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Usata-commits] Changes to usata2/src/gfx/mesh.hpp


From: Chong Kai Xiong
Subject: [Usata-commits] Changes to usata2/src/gfx/mesh.hpp
Date: Sun, 09 Jan 2005 05:21:10 -0500

Index: usata2/src/gfx/mesh.hpp
diff -u usata2/src/gfx/mesh.hpp:1.1 usata2/src/gfx/mesh.hpp:1.2
--- usata2/src/gfx/mesh.hpp:1.1 Tue Jan  4 16:05:03 2005
+++ usata2/src/gfx/mesh.hpp     Sun Jan  9 09:58:55 2005
@@ -9,43 +9,75 @@
 // included in the software distribution, or visit
 // http://www.fsf.org/licenses/gpl.html.
 //
-// $Id: mesh.hpp,v 1.1 2005/01/04 16:05:03 Descender Exp $
+// $Id: mesh.hpp,v 1.2 2005/01/09 09:58:55 Descender Exp $
 
 #ifndef USATA_GFX_MESH_HPP
 #define USATA_GFX_MESH_HPP
 
+#include <iostream>
+#include <vector>
+#include <string>
+#include <map>
+#include <boost/tuple/tuple.hpp>
 #include "math/vector.hpp"
 
 namespace usata
 {
     namespace gfx
     {
-       class TriangleMesh
-       {
-       public:
-
-           struct Vertex
-           {
-               math::Vector4d position;
-               math::Vector4d texture;
-               math::Vector4d normal;
-           };
-
-           struct Face
-           {
-               int vertices[3];
-               math::Vector4d normal;
-           }
-
-           TriangleMesh();
-           ~TriangleMesh();
-           
-
-       private:
-
-           std::vector<Vertex> m_vertices;
-           std::vector<Face>   m_faces;
-       };
+               struct Vertex
+               {
+                       math::Vector4d position;
+                       math::Vector4d texture;
+                       math::Vector4d normal;
+               };
+
+               class Triangle
+               {
+               public:
+                       Vertex *vertices[3];
+                       math::Vector4d plane;
+               };
+
+               typedef boost::tuple<Vertex *, Vertex *>     EdgePair;
+               typedef boost::tuple<Triangle *, Triangle *> TrianglePair;
+
+               class TriangleMeshImpl;
+
+               class TriangleMesh
+               {
+               public:
+                       typedef std::vector<Vertex>   VertexList;
+                       typedef std::vector<Triangle> TriangleList;
+                       typedef std::map<EdgePair, TrianglePair> EdgeTable;
+
+                       TriangleMesh();
+                       ~TriangleMesh();
+
+                       void
+                       clear();
+
+                       void
+                       add_vertex(const Vertex& vertex);
+
+                       void
+                       add_triangle(int v0, int v1, int v2);
+
+                       void
+                       draw();
+
+                       void
+                       load(const std::string& filename);
+
+               private:
+
+                       VertexList   m_vertices;
+                       TriangleList m_triangles;
+                       EdgeTable    m_edges;
+
+                       void
+                       compute_edge_table();
+               };
 
     } // namespace gfx
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]