00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00026
00027 #ifndef GLC_EXTENDEDMESH_H_
00028 #define GLC_EXTENDEDMESH_H_
00029
00030 #include <QHash>
00031 #include <QList>
00032 #include "../maths/glc_vector2df.h"
00033 #include "../maths/glc_vector3df.h"
00034 #include "../glc_enum.h"
00035 #include "../shading/glc_material.h"
00036 #include "glc_extendedgeomengine.h"
00037 #include "glc_vbogeom.h"
00038 #include "glc_primitivegroup.h"
00039
00042
00046
00047 class GLC_ExtendedMesh : public GLC_VboGeom
00048 {
00049 public:
00050 typedef QHash<GLC_uint, GLC_PrimitiveGroup*> PrimitiveGroups;
00051 typedef QHash<const int, PrimitiveGroups*> PrimitiveGroupsHash;
00052
00054
00056
00057 public:
00059 GLC_ExtendedMesh();
00060
00062 GLC_ExtendedMesh(const GLC_ExtendedMesh&);
00063
00064 virtual ~GLC_ExtendedMesh();
00066
00067
00069
00070 public:
00072 virtual unsigned int numberOfFaces() const;
00073
00075 virtual unsigned int numberOfVertex() const;
00076
00078 inline unsigned int numberOfNormals() const
00079 { return m_NumberOfNormals;}
00080
00082 virtual GLC_BoundingBox& boundingBox(void);
00083
00085 virtual GLC_VboGeom* clone() const;
00086
00088 inline bool ColorPearVertexIsAcivated() const
00089 {return m_ColorPearVertex;}
00090
00092 inline int numberOfLod()
00093 {return m_ExtendedGeomEngine.numberOfLod();}
00094
00096 inline GLfloatVector positionVector() const
00097 {return m_ExtendedGeomEngine.positionVector();}
00098
00100 inline GLfloatVector normalVector() const
00101 {return m_ExtendedGeomEngine.normalVector();}
00102
00104 inline GLfloatVector texelVector() const
00105 {return m_ExtendedGeomEngine.texelVector();}
00106
00108 bool containsTriangles(int lod, GLC_uint materialId) const;
00109
00111 QVector<GLuint> getTrianglesIndex(int lod, GLC_uint materialId) const;
00112
00114 int numberOfTriangles(int lod, GLC_uint materialId) const;
00115
00117 bool containsStrips(int lod, GLC_uint materialId) const;
00118
00120 QList<QVector<GLuint> > getStripsIndex(int lod, GLC_uint materialId) const;
00121
00123 int numberOfStrips(int lod, GLC_uint materialId) const;
00124
00126 bool containsFans(int lod, GLC_uint materialId) const;
00127
00129 QList<QVector<GLuint> > getFansIndex(int lod, GLC_uint materialId) const;
00130
00132 int numberOfFans(int lod, GLC_uint materialId) const;
00133
00135 inline bool containsLod(int lod) const
00136 {return (NULL != m_ExtendedGeomEngine.getLod(lod));}
00137
00139 inline bool lodContainsMaterial(int lod, GLC_uint materialId) const
00140 {
00141 if (not m_PrimitiveGroups.contains(lod))return false;
00142 else return m_PrimitiveGroups.value(lod)->contains(materialId);
00143 }
00144
00146 inline double getLodAccuracy(int lod) const
00147 {
00148 Q_ASSERT(containsLod(lod));
00149 return m_ExtendedGeomEngine.getLod(lod)->accuracy();
00150 }
00151
00152
00154
00155
00157
00158 public:
00159
00161 inline void addVertices(const GLfloatVector& vertices)
00162 {
00163 *(m_ExtendedGeomEngine.positionVectorHandle())+= vertices;
00164 m_NumberOfVertice+= vertices.size() / 3;
00165 }
00166
00168 inline void addNormals(const GLfloatVector& normals)
00169 {
00170 *(m_ExtendedGeomEngine.normalVectorHandle())+= normals;
00171 m_NumberOfNormals+= normals.size() / 3;
00172 }
00173
00175 inline void addTexels(const GLfloatVector& texels)
00176 {*(m_ExtendedGeomEngine.texelVectorHandle())+= texels;}
00177
00179 inline void addColors(const GLfloatVector& colors)
00180 {*(m_ExtendedGeomEngine.colorVectorHandle())+= colors;}
00181
00183 void addTriangles(GLC_Material*, const IndexList&, const int lod= 0, double accuracy= 0.0);
00184
00186 void addTrianglesStrip(GLC_Material*, const IndexList&, const int lod= 0, double accuracy= 0.0);
00187
00189 void addTrianglesFan(GLC_Material*, const IndexList&, const int lod= 0, double accuracy= 0.0);
00190
00192 void reverseNormals();
00193
00195 inline void setColorPearVertex(bool flag){m_ColorPearVertex= flag;}
00196
00198 void finished();
00199
00201 virtual void setCurrentLod(const int);
00202
00204
00206
00208
00209 public:
00211 virtual void glExecute(bool, bool transparent= false);
00212
00213 private:
00214
00216
00218 virtual void glDraw(bool transparent= false);
00219
00221
00223
00225
00226 private:
00228 GLC_uint setCurrentMaterial(GLC_Material*, const int, double);
00229
00231 void createVbos();
00232
00234 void finishVbo();
00235
00237 void finishNonVbo();
00239
00240
00242
00244 private:
00245
00247 PrimitiveGroupsHash m_PrimitiveGroups;
00248
00250 GLC_uint m_DefaultMaterialId;
00251
00253 unsigned int m_NumberOfFaces;
00254
00256 unsigned int m_NumberOfVertice;
00257
00259 unsigned int m_NumberOfNormals;
00260
00262 bool m_IsSelected;
00263
00265 bool m_ColorPearVertex;
00266
00268 GLC_ExtendedGeomEngine m_ExtendedGeomEngine;
00269
00271 int m_CurrentLod;
00272
00273 };
00274
00275 #endif