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 
00003 
00005 
00006 
00011 
00016 
00021 //                            MeshBuilder.h                                   //
00023 
00024 #ifndef MESHBUILDER_H
00025 #define MESHBUILDER_H
00026 
00027 #include "X3DTypes.h"
00028 #include "MeshTypes.h"
00029 #include "TemplateVertex.h"
00030 #include "TemplateEdge.h"
00031 #include "TemplateFace.h"
00032 #include "TemplateMesh.h"
00033 #include "TemplateMeshBuilder.h"
00034 #include "IndexedFaceSet.h"
00035 #include "Coordinate.h"
00036 #include "Normal.h"
00037 #include "TextureCoordinate.h"
00038 #include "Color.h"
00039 #include "ColorRGBA.h"
00040 
00041 #include <list>
00042 #include <iostream>
00043 
00044 namespace X3DTK {
00045 namespace Mesh {
00046 
00048 
00049 class VertexFData
00050 {
00051 public:
00053   VertexFData();
00054 
00056   void setNormal(const SFVec3f &normal);
00058   void setColor(const SFColorRGBA &color);
00060   void setTexCoord(const SFVec2f &texCoord);
00061 
00063   inline const SFVec3f &getNormal() const {return _normal;};
00065   inline const SFColorRGBA &getColor() const {return _color;};
00067   inline const SFVec2f &getTexCoord() const {return _texCoord;};  
00068   
00069 private:
00070   SFVec3f _normal;
00071   SFColorRGBA _color;
00072   SFVec2f _texCoord;         
00073 };
00074 
00076 
00077 class VertexData
00078 {
00079 public:
00081   VertexData();
00083   ~VertexData();
00084   
00086   void setPoint(const SFVec3f &point);
00088   void addFaceData(void *face, VertexFData *vdata);
00089   
00091   inline const SFVec3f &getPoint() const {return _point;};
00093   VertexFData *getFaceData(void *face) const; 
00094   
00095 private:
00096   SFVec3f _point;
00097   std::list<std::pair<void *, VertexFData *> > _FDataList;
00098 };
00099 
00101 
00102 class EdgeData
00103 {
00104 public:
00106   EdgeData();
00107 };
00108 
00110 
00111 class FaceData
00112 {
00113 public:
00115   FaceData();
00116   
00118   void setNormal(const SFVec3f &normal);
00120   void setColor(const SFColorRGBA &color);
00121   
00123   inline const SFVec3f &getNormal() const {return _normal;};
00125   inline const SFColorRGBA &getColor() const {return _color;};
00126   
00127 private:
00128   SFVec3f _normal;
00129   SFColorRGBA _color;
00130 };
00131 
00133 
00134 class MeshData
00135 {
00136 public:
00138   MeshData();
00139   
00141   void setVertexNormal(bool vertexNormal);
00143   void setVertexColor(bool vertexColor);
00145   void setVertexTexCoord(bool vertexTexCoord);
00147   void setFaceNormal(bool faceNormal);
00149   void setFaceColor(bool faceColor);
00150   
00152   inline bool hasVertexNormal() const {return _vertexNormal;};
00154   inline bool hasVertexColor() const {return _vertexColor;};
00156   inline bool hasVertexTexCoord() const {return _vertexTexCoord;};
00158   inline bool hasFaceNormal() const {return _faceNormal;};
00160   inline bool hasFaceColor() const {return _faceColor;};
00161   
00162 private:
00163   bool _vertexNormal; 
00164   bool _vertexColor; 
00165   bool _vertexTexCoord;
00166   bool _faceNormal;
00167   bool _faceColor;
00168 };
00169 
00170 typedef TemplateMesh<MeshData, VertexData, EdgeData, FaceData> Mesh;
00171 
00173 template<>
00174 Mesh::TemplateMesh()
00175 {
00176   defineTypeName("Mesh");
00177 };
00178 
00179 
00180 }
00181 
00182 namespace X3D {
00183 
00184 typedef TemplateMeshBuilder<Mesh::MeshData, Mesh::VertexData, Mesh::EdgeData, Mesh::FaceData> MeshBuilder;
00185 
00186 }
00187 }
00188 
00189 #endif

Generated on Wed Sep 10 11:25:13 2003 for X3DToolKit by doxygen1.3