Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

MeshBuilder.h

Go to the documentation of this file.
00001 
00002 //                            MeshBuilder.h                                   //
00004 
00005 #ifndef MESHBUILDER_H
00006 #define MESHBUILDER_H
00007 
00008 #include "X3DTypes.h"
00009 #include "MeshTypes.h"
00010 #include "TemplateVertex.h"
00011 #include "TemplateEdge.h"
00012 #include "TemplateFace.h"
00013 #include "TemplateMesh.h"
00014 #include "TemplateMeshBuilder.h"
00015 #include "IndexedFaceSet.h"
00016 #include "Coordinate.h"
00017 #include "Normal.h"
00018 #include "TextureCoordinate.h"
00019 #include "Color.h"
00020 #include "ColorRGBA.h"
00021 
00022 #include <list>
00023 #include <iostream>
00024 
00025 namespace X3DTK {
00026 namespace Mesh {
00027 
00029 
00030 class VertexFData
00031 {
00032 public:
00034   VertexFData();
00035 
00037   void setNormal(const SFVec3f &normal);
00039   void setColor(const SFColorRGBA &color);
00041   void setTexCoord(const SFVec2f &texCoord);
00042 
00044   inline const SFVec3f &getNormal() const {return _normal;};
00046   inline const SFColorRGBA &getColor() const {return _color;};
00048   inline const SFVec2f &getTexCoord() const {return _texCoord;};  
00049   
00050 private:
00051   SFVec3f _normal;
00052   SFColorRGBA _color;
00053   SFVec2f _texCoord;         
00054 };
00055 
00057 
00058 class VertexData
00059 {
00060 public:
00062   VertexData();
00064   ~VertexData();
00065   
00067   void setPoint(const SFVec3f &point);
00069   void addFaceData(void *face, VertexFData *vdata);
00070   
00072   inline const SFVec3f &getPoint() const {return _point;};
00074   VertexFData *getFaceData(void *face) const; 
00075   
00076 private:
00077   SFVec3f _point;
00078   std::list<std::pair<void *, VertexFData *> > _FDataList;
00079 };
00080 
00082 
00083 class EdgeData
00084 {
00085 public:
00087   EdgeData();
00088 };
00089 
00091 
00092 class FaceData
00093 {
00094 public:
00096   FaceData();
00097   
00099   void setNormal(const SFVec3f &normal);
00101   void setColor(const SFColorRGBA &color);
00102   
00104   inline const SFVec3f &getNormal() const {return _normal;};
00106   inline const SFColorRGBA &getColor() const {return _color;};
00107   
00108 private:
00109   SFVec3f _normal;
00110   SFColorRGBA _color;
00111 };
00112 
00114 
00115 class MeshData
00116 {
00117 public:
00119   MeshData();
00120   
00122   void setVertexNormal(bool vertexNormal);
00124   void setVertexColor(bool vertexColor);
00126   void setVertexTexCoord(bool vertexTexCoord);
00128   void setFaceNormal(bool faceNormal);
00130   void setFaceColor(bool faceColor);
00131   
00133   inline bool hasVertexNormal() const {return _vertexNormal;};
00135   inline bool hasVertexColor() const {return _vertexColor;};
00137   inline bool hasVertexTexCoord() const {return _vertexTexCoord;};
00139   inline bool hasFaceNormal() const {return _faceNormal;};
00141   inline bool hasFaceColor() const {return _faceColor;};
00142   
00143 private:
00144   bool _vertexNormal; 
00145   bool _vertexColor; 
00146   bool _vertexTexCoord;
00147   bool _faceNormal;
00148   bool _faceColor;
00149 };
00150 
00151 typedef TemplateMesh<MeshData, VertexData, EdgeData, FaceData> Mesh;
00152 
00154 Mesh::TemplateMesh()
00155 {
00156   defineTypeName("Mesh");
00157 };
00158 
00159 
00160 }
00161 
00162 namespace X3D {
00163 
00164 typedef TemplateMeshBuilder<Mesh::MeshData, Mesh::VertexData, Mesh::EdgeData, Mesh::FaceData> MeshBuilder;
00165 
00166 }
00167 }
00168 
00169 #endif

Generated on Tue Jul 15 16:46:52 2003 for X3DToolKit by doxygen1.3