Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

mesh3.h

00001 //FILE:         mesh3.cpp
00002 //AUTHOR:       Nathan Cournia <nathan@cournia.com>
00003 //TODO copy, assignemt, get_*, get_surf( name )
00004 
00005 #ifndef CLEMSON_MESH3_H
00006 #define CLEMSON_MESH3_H 1
00007 
00008 #include <vector>
00009 #include "vector.h"
00010 #include "texture.h"
00011 
00012 #define MESH3_VERTS 3
00013 
00015 class mesh3
00016 {
00017 public:
00019         typedef math::vector3 point3;
00020 
00022         typedef std::vector<point3*> point_list;
00023 
00025         typedef math::vector3 normal3;
00026 
00028         typedef std::vector<normal3*> normal_list;
00029 
00031         struct uv2 {
00032                 real_t uv[ 2 ]; 
00033 
00035                 inline void set( real_t u_, real_t v_ ) {
00036                         uv[ 0 ] = u_; uv[ 1 ] = v_;
00037                 }
00038         };
00039         
00041         typedef std::vector<uv2*> uv_list;
00042 
00044         struct vertex3 {
00045                 int vertex_index; 
00046                 int normal_index; 
00047                 int uv_index; 
00048 
00050                 vertex3( void ): vertex_index( -1 ), normal_index( -1 ), 
00051                         uv_index( -1 )
00052                 { }
00053         };
00054 
00056         struct triangle {
00057                 gl::texture texture; 
00058                 vertex3 vertex[ MESH3_VERTS ]; 
00059         };
00060 
00062         class surface: public std::vector<triangle*>
00063         {
00064          private:
00065                 std::string m_name;
00066                 
00067          public:
00069                 ~surface( void );
00070 
00072                 inline std::string get_name( void ) const {
00073                         return m_name;
00074                 }
00075         };
00076 
00078         typedef std::vector<surface*> surface_list;
00079         
00080 protected:
00081         point_list m_vertexes;
00082         normal_list m_normals;
00083         uv_list m_uvs;
00084         surface_list m_surfaces;
00085 
00086 public:
00088         mesh3( void );
00089 
00091         virtual ~mesh3( void );
00092 
00094         void render_triangle( const triangle& tri ) const;
00095         
00097         void render_surface( const surface& surf ) const;
00098         
00100         void render( void ) const;
00101 
00102 }; //end of mesh3
00103 
00104 #endif

Generated on Tue Feb 11 18:49:41 2003 for uber by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002