glc_mesh.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 *****************************************************************************/
00022 
00024 
00025 #ifndef GLC_MESH_H_
00026 #define GLC_MESH_H_
00027 
00028 #include <QHash>
00029 #include <QList>
00030 #include "../maths/glc_vector2df.h"
00031 #include "../maths/glc_vector3df.h"
00032 #include "../glc_global.h"
00033 #include "../shading/glc_material.h"
00034 #include "glc_meshdata.h"
00035 #include "glc_geometry.h"
00036 #include "glc_primitivegroup.h"
00037 #include "../glc_state.h"
00038 #include "../shading/glc_selectionmaterial.h"
00039 
00040 #include "../glc_config.h"
00041 
00044 
00048 
00049 class GLC_LIB_EXPORT GLC_Mesh : public GLC_Geometry
00050 {
00051         friend QDataStream &operator<<(QDataStream &, const GLC_Mesh &);
00052         friend QDataStream &operator>>(QDataStream &, GLC_Mesh &);
00053 
00054 public:
00055         typedef QHash<GLC_uint, GLC_PrimitiveGroup*> LodPrimitiveGroups;
00056         typedef QHash<const int, LodPrimitiveGroups*> PrimitiveGroupsHash;
00057 
00059 
00061 
00062 public:
00064         GLC_Mesh();
00065 
00067         GLC_Mesh(const GLC_Mesh&);
00068 
00070         GLC_Mesh& operator=(const GLC_Mesh&);
00071 
00073         virtual ~GLC_Mesh();
00075 
00076 
00078 
00079 public:
00081         static quint32 chunckID();
00082 
00084         virtual unsigned int faceCount(int lod) const;
00085 
00087         virtual unsigned int VertexCount() const;
00088 
00090         inline unsigned int numberOfNormals() const
00091         { return m_NumberOfNormals;}
00092 
00094         virtual const GLC_BoundingBox& boundingBox(void);
00095 
00097         virtual GLC_Geometry* clone() const;
00098 
00100         inline bool ColorPearVertexIsAcivated() const
00101         {return m_ColorPearVertex;}
00102 
00104         inline int lodCount() const
00105         {return m_MeshData.lodCount();}
00106 
00108         inline GLfloatVector positionVector() const
00109         {return m_MeshData.positionVector();}
00110 
00112         inline GLfloatVector normalVector() const
00113         {return m_MeshData.normalVector();}
00114 
00116         inline GLfloatVector texelVector() const
00117         {return m_MeshData.texelVector();}
00118 
00120         bool containsTriangles(int lod, GLC_uint materialId) const;
00121 
00123 
00124         QVector<GLuint> getTrianglesIndex(int lod, GLC_uint materialId) const;
00125 
00127         int numberOfTriangles(int lod, GLC_uint materialId) const;
00128 
00130         bool containsStrips(int lod, GLC_uint materialId) const;
00131 
00133 
00134         QList<QVector<GLuint> > getStripsIndex(int lod, GLC_uint materialId) const;
00135 
00137         int numberOfStrips(int lod, GLC_uint materialId) const;
00138 
00140         bool containsFans(int lod, GLC_uint materialId) const;
00141 
00143 
00144         QList<QVector<GLuint> > getFansIndex(int lod, GLC_uint materialId) const;
00145 
00147         int numberOfFans(int lod, GLC_uint materialId) const;
00148 
00150         inline bool containsLod(int lod) const
00151         {return (NULL != m_MeshData.getLod(lod));}
00152 
00154         inline bool lodContainsMaterial(int lod, GLC_uint materialId) const
00155         {
00156                 if (!m_PrimitiveGroups.contains(lod))return false;
00157                 else return m_PrimitiveGroups.value(lod)->contains(materialId);
00158         }
00159 
00161 
00162         inline double getLodAccuracy(int lod) const
00163         {
00164                 Q_ASSERT(containsLod(lod));
00165                 return m_MeshData.getLod(lod)->accuracy();
00166         }
00167 
00169         inline GLC_uint nextPrimitiveLocalId() const
00170         {return m_NextPrimitiveLocalId;}
00171 
00173         inline bool isEmpty() const
00174         {return m_MeshData.isEmpty();}
00175 
00177         inline QColor wireColor() const
00178         {return m_WireColor;}
00179 
00181         GLC_Mesh* createMeshOfGivenLod(int lodIndex);
00182 
00184         GLC_Mesh* createMeshFromGivenLod(int lodIndex);
00185 
00186 
00188         GLC_Mesh& transformVertice(const GLC_Matrix4x4& matrix);
00189 
00191 
00192 
00194 
00195 public:
00196 
00198         virtual void clear();
00199 
00201         void clearMeshWireAndBoundingBox();
00202 
00204         inline void addVertice(const GLfloatVector& vertices)
00205         {
00206                 *(m_MeshData.positionVectorHandle())+= vertices;
00207                 m_NumberOfVertice+= vertices.size() / 3;
00208         }
00209 
00211         inline void addNormals(const GLfloatVector& normals)
00212         {
00213                 *(m_MeshData.normalVectorHandle())+= normals;
00214                 m_NumberOfNormals+= normals.size() / 3;
00215         }
00216 
00218         inline void addTexels(const GLfloatVector& texels)
00219         {*(m_MeshData.texelVectorHandle())+= texels;}
00220 
00222         inline void addColors(const GLfloatVector& colors)
00223         {*(m_MeshData.colorVectorHandle())+= colors;}
00224 
00226         GLC_uint addTriangles(GLC_Material*, const IndexList&, const int lod= 0, double accuracy= 0.0);
00227 
00229         GLC_uint addTrianglesStrip(GLC_Material*, const IndexList&, const int lod= 0, double accuracy= 0.0);
00230 
00232         GLC_uint addTrianglesFan(GLC_Material*, const IndexList&, const int lod= 0, double accuracy= 0.0);
00233 
00235         void reverseNormals();
00236 
00238         inline void setColorPearVertex(bool flag)
00239         {m_ColorPearVertex= flag;}
00240 
00242         void finish();
00243 
00245         virtual void setCurrentLod(const int);
00246 
00248         virtual void replaceMasterMaterial(GLC_Material*);
00249 
00251         void replaceMaterial(const GLC_uint, GLC_Material*);
00252 
00254         inline void setNextPrimitiveLocalId(GLC_uint id)
00255         {m_NextPrimitiveLocalId= id;}
00256 
00258         inline void setWireColor(const QColor& color)
00259         {m_WireColor= color;}
00260 
00262         virtual void copyVboToClientSide();
00263 
00265         virtual void releaseVboClientSide(bool update);
00266 
00268 
00270 
00272 
00273 public:
00275 
00279         void loadFromDataStream(QDataStream&, const MaterialHash&, const QHash<GLC_uint, GLC_uint>&);
00280 
00282         void saveToDataStream(QDataStream&) const;
00283 
00285 
00286 
00288 
00289 protected:
00290 
00292 
00293         virtual void glDraw(const GLC_RenderProperties&);
00294 
00296 
00298 
00300 
00301 private:
00303         GLC_uint setCurrentMaterial(GLC_Material*, const int, double);
00304 
00306         void fillVbosAndIbos();
00307 
00309         void finishSerialized();
00310 
00312         void finishVbo();
00313 
00315         void finishNonVbo();
00316 
00318         inline void vboDrawPrimitivesOf(GLC_PrimitiveGroup*);
00319 
00321         inline void vertexArrayDrawPrimitivesOf(GLC_PrimitiveGroup*);
00322 
00324         inline void vboDrawInSelectionModePrimitivesOf(GLC_PrimitiveGroup*);
00325 
00327         inline void vertexArrayDrawInSelectionModePrimitivesOf(GLC_PrimitiveGroup*);
00328 
00330         inline void vboDrawPrimitivesGroupOf(GLC_PrimitiveGroup*, GLC_Material*, bool, bool, QHash<GLC_uint, GLC_Material*>*);
00331 
00333         inline void vertexArrayDrawPrimitivesGroupOf(GLC_PrimitiveGroup*, GLC_Material*, bool, bool, QHash<GLC_uint, GLC_Material*>*);
00334 
00336         inline void vboDrawSelectedPrimitivesGroupOf(GLC_PrimitiveGroup*, GLC_Material*, bool, bool, const GLC_RenderProperties&);
00337 
00339         inline void vertexArrayDrawSelectedPrimitivesGroupOf(GLC_PrimitiveGroup*, GLC_Material*, bool, bool, const GLC_RenderProperties&);
00340 
00342         inline void activateVboAndIbo();
00343 
00345         inline void activateVertexArray();
00346 
00348         void normalRenderLoop(const GLC_RenderProperties&, bool);
00349 
00351         void OverwriteMaterialRenderLoop(const GLC_RenderProperties&, bool);
00352 
00354         void OverwriteTransparencyRenderLoop(const GLC_RenderProperties&, bool);
00355 
00357         void bodySelectionRenderLoop(bool);
00358 
00360         void primitiveSelectionRenderLoop(bool);
00361 
00363         void primitiveRenderLoop(const GLC_RenderProperties&, bool);
00364 
00366         void primitiveSelectedRenderLoop(const GLC_RenderProperties&, bool);
00367 
00369         void copyIndex(int lod, GLC_Mesh* pLodMesh, QHash<GLuint, GLuint>& sourceToTargetIndexMap, QHash<GLuint, GLuint>& tagetToSourceIndexMap, int& maxIndex, int targetLod);
00370 
00372         void copyBulkData(GLC_Mesh* pLodMesh, const QHash<GLuint, GLuint>& tagetToSourceIndexMap, int maxIndex);
00373 
00375 
00376 
00378 // Private members
00380 private:
00382         GLC_uint m_NextPrimitiveLocalId;
00383 
00385         PrimitiveGroupsHash m_PrimitiveGroups;
00386 
00388         GLC_uint m_DefaultMaterialId;
00389 
00391         unsigned int m_NumberOfVertice;
00392 
00394         unsigned int m_NumberOfNormals;
00395 
00397         bool m_ColorPearVertex;
00398 
00400         GLC_MeshData m_MeshData;
00401 
00403         int m_CurrentLod;
00404 
00406         static quint32 m_ChunkId;
00407 
00408 };
00409 
00410 // Inline functions
00411 
00412 // Use VBO to Draw triangles from the specified GLC_PrimitiveGroup
00413 void GLC_Mesh::vboDrawPrimitivesOf(GLC_PrimitiveGroup* pCurrentGroup)
00414 {
00415         // Draw triangles
00416         if (pCurrentGroup->containsTriangles())
00417         {
00418                 glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSize(), GL_UNSIGNED_INT, pCurrentGroup->trianglesIndexOffset());
00419         }
00420 
00421         // Draw Triangles strip
00422         if (pCurrentGroup->containsStrip())
00423         {
00424                 const GLsizei stripsCount= static_cast<GLsizei>(pCurrentGroup->stripsOffset().size());
00425                 for (GLint i= 0; i < stripsCount; ++i)
00426                 {
00427                         glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->stripsOffset().at(i));
00428                 }
00429         }
00430 
00431         // Draw Triangles fan
00432         if (pCurrentGroup->containsFan())
00433         {
00434                 const GLsizei fansCount= static_cast<GLsizei>(pCurrentGroup->fansOffset().size());
00435                 for (GLint i= 0; i < fansCount; ++i)
00436                 {
00437                         glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->fansOffset().at(i));
00438                 }
00439         }
00440 }
00441 // Use Vertex Array to Draw triangles from the specified GLC_PrimitiveGroup
00442 void GLC_Mesh::vertexArrayDrawPrimitivesOf(GLC_PrimitiveGroup* pCurrentGroup)
00443 {
00444         // Draw triangles
00445         if (pCurrentGroup->containsTriangles())
00446         {
00447                 GLvoid* pOffset= &(m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->trianglesIndexOffseti()]);
00448                 glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSize(), GL_UNSIGNED_INT, pOffset);
00449         }
00450 
00451         // Draw Triangles strip
00452         if (pCurrentGroup->containsStrip())
00453         {
00454                 const GLsizei stripsCount= static_cast<GLsizei>(pCurrentGroup->stripsOffseti().size());
00455                 for (GLint i= 0; i < stripsCount; ++i)
00456                 {
00457                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->stripsOffseti().at(i)];
00458                         glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pOffset);
00459                 }
00460         }
00461 
00462         // Draw Triangles fan
00463         if (pCurrentGroup->containsFan())
00464         {
00465                 const GLsizei fansCount= static_cast<GLsizei>(pCurrentGroup->fansOffseti().size());
00466                 for (GLint i= 0; i < fansCount; ++i)
00467                 {
00468                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->fansOffseti().at(i)];
00469                         glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pOffset);
00470                 }
00471         }
00472 }
00473 
00474 // Use VBO to Draw primitives in selection mode from the specified GLC_PrimitiveGroup
00475 void GLC_Mesh::vboDrawInSelectionModePrimitivesOf(GLC_PrimitiveGroup* pCurrentGroup)
00476 {
00477         GLubyte colorId[4];
00478         // Draw triangles
00479         if (pCurrentGroup->containsTrianglesGroupId())
00480         {
00481                 const GLsizei trianglesGroupCount= static_cast<GLsizei>(pCurrentGroup->trianglesGroupOffset().size());
00482                 for (GLint i= 0; i < trianglesGroupCount; ++i)
00483                 {
00484                         glc::encodeRgbId(pCurrentGroup->triangleGroupId(i), colorId);
00485                         glColor3ubv(colorId);
00486                         glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->trianglesGroupOffset().at(i));
00487                 }
00488         }
00489 
00490         // Draw Triangles strip
00491         if (pCurrentGroup->containsStripGroupId())
00492         {
00493                 const GLsizei stripsCount= static_cast<GLsizei>(pCurrentGroup->stripsOffset().size());
00494                 for (GLint i= 0; i < stripsCount; ++i)
00495                 {
00496                         glc::encodeRgbId(pCurrentGroup->stripGroupId(i), colorId);
00497                         glColor3ubv(colorId);
00498                         glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->stripsOffset().at(i));
00499                 }
00500         }
00501 
00502         // Draw Triangles fan
00503         if (pCurrentGroup->containsFanGroupId())
00504         {
00505                 const GLsizei fansCount= static_cast<GLsizei>(pCurrentGroup->fansOffset().size());
00506                 for (GLint i= 0; i < fansCount; ++i)
00507                 {
00508                         glc::encodeRgbId(pCurrentGroup->fanGroupId(i), colorId);
00509                         glColor3ubv(colorId);
00510 
00511                         glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->fansOffset().at(i));
00512                 }
00513         }
00514 
00515 }
00516 
00517 // Use Vertex Array to Draw primitives in selection mode from the specified GLC_PrimitiveGroup
00518 void GLC_Mesh::vertexArrayDrawInSelectionModePrimitivesOf(GLC_PrimitiveGroup* pCurrentGroup)
00519 {
00520         GLubyte colorId[4];
00521         // Draw triangles
00522         if (pCurrentGroup->containsTrianglesGroupId())
00523         {
00524                 const GLsizei trianglesGroupCount= static_cast<GLsizei>(pCurrentGroup->trianglesGroupOffseti().size());
00525                 for (GLint i= 0; i < trianglesGroupCount; ++i)
00526                 {
00527                         glc::encodeRgbId(pCurrentGroup->triangleGroupId(i), colorId);
00528                         glColor3ubv(colorId);
00529 
00530                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->trianglesGroupOffseti().at(i)];
00531                         glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pOffset);
00532                 }
00533 
00534                 GLvoid* pOffset= &(m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->trianglesIndexOffseti()]);
00535                 glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSize(), GL_UNSIGNED_INT, pOffset);
00536         }
00537 
00538         // Draw Triangles strip
00539         if (pCurrentGroup->containsStripGroupId())
00540         {
00541                 const GLsizei stripsCount= static_cast<GLsizei>(pCurrentGroup->stripsOffseti().size());
00542                 for (GLint i= 0; i < stripsCount; ++i)
00543                 {
00544                         glc::encodeRgbId(pCurrentGroup->stripGroupId(i), colorId);
00545                         glColor3ubv(colorId);
00546 
00547                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->stripsOffseti().at(i)];
00548                         glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pOffset);
00549                 }
00550         }
00551 
00552         // Draw Triangles fan
00553         if (pCurrentGroup->containsFanGroupId())
00554         {
00555                 const GLsizei fansCount= static_cast<GLsizei>(pCurrentGroup->fansOffseti().size());
00556                 for (GLint i= 0; i < fansCount; ++i)
00557                 {
00558                         glc::encodeRgbId(pCurrentGroup->fanGroupId(i), colorId);
00559                         glColor3ubv(colorId);
00560 
00561                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->fansOffseti().at(i)];
00562                         glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pOffset);
00563                 }
00564         }
00565 }
00566 
00567 // Use VBO to Draw primitives with specific materials from the specified GLC_PrimitiveGroup
00568 void GLC_Mesh::vboDrawPrimitivesGroupOf(GLC_PrimitiveGroup* pCurrentGroup, GLC_Material* pCurrentMaterial, bool materialIsRenderable
00569                 , bool isTransparent,  QHash<GLC_uint, GLC_Material*>* pMaterialHash)
00570 {
00571         GLC_Material* pCurrentLocalMaterial= pCurrentMaterial;
00572         // Draw triangles
00573         if (pCurrentGroup->containsTriangles())
00574         {
00575                 Q_ASSERT(pCurrentGroup->containsTrianglesGroupId());
00576                 const GLsizei trianglesGroupCount= static_cast<GLsizei>(pCurrentGroup->trianglesGroupOffset().size());
00577                 for (GLint i= 0; i < trianglesGroupCount; ++i)
00578                 {
00579                         GLC_uint currentPrimitiveId= pCurrentGroup->triangleGroupId(i);
00580                         if (pMaterialHash->contains(currentPrimitiveId))
00581                         {
00582                                 if (pCurrentLocalMaterial != pMaterialHash->value(currentPrimitiveId))
00583                                 {
00584                                         pCurrentLocalMaterial= pMaterialHash->value(currentPrimitiveId);
00585                                         if (pCurrentLocalMaterial->isTransparent() == isTransparent) pCurrentLocalMaterial->glExecute();
00586                                 }
00587                         }
00588                         else if (pCurrentLocalMaterial != pCurrentMaterial)
00589                         {
00590                                 pCurrentLocalMaterial= pCurrentMaterial;
00591                                 if (materialIsRenderable) pCurrentLocalMaterial->glExecute();
00592                         }
00593                         if (pCurrentLocalMaterial->isTransparent() == isTransparent)
00594                         {
00595                                 glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->trianglesGroupOffset().at(i));
00596                         }
00597                 }
00598         }
00599 
00600         // Draw Triangles strip
00601         if (pCurrentGroup->containsStrip())
00602         {
00603                 Q_ASSERT(pCurrentGroup->containsStripGroupId());
00604                 const GLsizei stripsCount= static_cast<GLsizei>(pCurrentGroup->stripsOffset().size());
00605                 for (GLint i= 0; i < stripsCount; ++i)
00606                 {
00607                         GLC_uint currentPrimitiveId= pCurrentGroup->stripGroupId(i);
00608                         if (pMaterialHash->contains(currentPrimitiveId))
00609                         {
00610                                 if (pCurrentLocalMaterial != pMaterialHash->value(currentPrimitiveId))
00611                                 {
00612                                         pCurrentLocalMaterial= pMaterialHash->value(currentPrimitiveId);
00613                                         if (pCurrentLocalMaterial->isTransparent() == isTransparent) pCurrentLocalMaterial->glExecute();
00614                                 }
00615                         }
00616                         else if (pCurrentLocalMaterial != pCurrentMaterial)
00617                         {
00618                                 pCurrentLocalMaterial= pCurrentMaterial;
00619                                 if (materialIsRenderable) pCurrentLocalMaterial->glExecute();
00620                         }
00621                         if (pCurrentLocalMaterial->isTransparent() == isTransparent)
00622                         {
00623                                 glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->stripsOffset().at(i));
00624                         }
00625                 }
00626         }
00627 
00628         // Draw Triangles fan
00629         if (pCurrentGroup->containsFan())
00630         {
00631                 Q_ASSERT(pCurrentGroup->containsFanGroupId());
00632                 const GLsizei fansCount= static_cast<GLsizei>(pCurrentGroup->fansOffset().size());
00633                 for (GLint i= 0; i < fansCount; ++i)
00634                 {
00635                         GLC_uint currentPrimitiveId= pCurrentGroup->fanGroupId(i);
00636                         if (pMaterialHash->contains(currentPrimitiveId))
00637                         {
00638                                 if (pCurrentLocalMaterial != pMaterialHash->value(currentPrimitiveId))
00639                                 {
00640                                         pCurrentLocalMaterial= pMaterialHash->value(currentPrimitiveId);
00641                                         if (pCurrentLocalMaterial->isTransparent() == isTransparent) pCurrentLocalMaterial->glExecute();
00642                                 }
00643                         }
00644                         else if (pCurrentLocalMaterial != pCurrentMaterial)
00645                         {
00646                                 pCurrentLocalMaterial= pCurrentMaterial;
00647                                 if (materialIsRenderable) pCurrentLocalMaterial->glExecute();
00648                         }
00649                         if (pCurrentLocalMaterial->isTransparent() == isTransparent)
00650                         {
00651                                 glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->fansOffset().at(i));
00652                         }
00653                 }
00654         }
00655 
00656 }
00657 
00658 // Use Vertex Array to Draw primitives with specific materials from the specified GLC_PrimitiveGroup
00659 void GLC_Mesh::vertexArrayDrawPrimitivesGroupOf(GLC_PrimitiveGroup* pCurrentGroup, GLC_Material* pCurrentMaterial, bool materialIsRenderable
00660                 , bool isTransparent, QHash<GLC_uint, GLC_Material*>* pMaterialHash)
00661 {
00662         GLC_Material* pCurrentLocalMaterial= pCurrentMaterial;
00663         // Draw triangles
00664         if (pCurrentGroup->containsTriangles())
00665         {
00666                 Q_ASSERT(pCurrentGroup->containsTrianglesGroupId());
00667                 const GLsizei trianglesGroupCount= static_cast<GLsizei>(pCurrentGroup->trianglesGroupOffseti().size());
00668                 for (GLint i= 0; i < trianglesGroupCount; ++i)
00669                 {
00670                         GLC_uint currentPrimitiveId= pCurrentGroup->triangleGroupId(i);
00671                         if (pMaterialHash->contains(currentPrimitiveId))
00672                         {
00673                                 if (pCurrentLocalMaterial != pMaterialHash->value(currentPrimitiveId))
00674                                 {
00675                                         pCurrentLocalMaterial= pMaterialHash->value(currentPrimitiveId);
00676                                         if (pCurrentLocalMaterial->isTransparent() == isTransparent) pCurrentLocalMaterial->glExecute();
00677                                 }
00678                         }
00679                         else if (pCurrentLocalMaterial != pCurrentMaterial)
00680                         {
00681                                 pCurrentLocalMaterial= pCurrentMaterial;
00682                                 if (materialIsRenderable) pCurrentLocalMaterial->glExecute();
00683                         }
00684                         if (pCurrentLocalMaterial->isTransparent() == isTransparent)
00685                         {
00686                                 GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->trianglesGroupOffseti().at(i)];
00687                                 glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pOffset);
00688                         }
00689                 }
00690         }
00691 
00692         // Draw Triangles strip
00693         if (pCurrentGroup->containsStrip())
00694         {
00695                 Q_ASSERT(pCurrentGroup->containsStripGroupId());
00696                 const GLsizei stripsCount= static_cast<GLsizei>(pCurrentGroup->stripsOffseti().size());
00697                 for (GLint i= 0; i < stripsCount; ++i)
00698                 {
00699                         GLC_uint currentPrimitiveId= pCurrentGroup->stripGroupId(i);
00700                         if (pMaterialHash->contains(currentPrimitiveId))
00701                         {
00702                                 if (pCurrentLocalMaterial != pMaterialHash->value(currentPrimitiveId))
00703                                 {
00704                                         pCurrentLocalMaterial= pMaterialHash->value(currentPrimitiveId);
00705                                         if (pCurrentLocalMaterial->isTransparent() == isTransparent) pCurrentLocalMaterial->glExecute();
00706                                 }
00707                         }
00708                         else if (pCurrentLocalMaterial != pCurrentMaterial)
00709                         {
00710                                 pCurrentLocalMaterial= pCurrentMaterial;
00711                                 if (materialIsRenderable) pCurrentLocalMaterial->glExecute();
00712                         }
00713                         if (pCurrentLocalMaterial->isTransparent() == isTransparent)
00714                         {
00715                                 GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->stripsOffseti().at(i)];
00716                                 glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pOffset);
00717                         }
00718                 }
00719         }
00720 
00721         // Draw Triangles fan
00722         if (pCurrentGroup->containsFan())
00723         {
00724                 Q_ASSERT(pCurrentGroup->containsFanGroupId());
00725                 const GLsizei fansCount= static_cast<GLsizei>(pCurrentGroup->fansOffseti().size());
00726                 for (GLint i= 0; i < fansCount; ++i)
00727                 {
00728                         GLC_uint currentPrimitiveId= pCurrentGroup->fanGroupId(i);
00729                         if (pMaterialHash->contains(currentPrimitiveId))
00730                         {
00731                                 if (pCurrentLocalMaterial != pMaterialHash->value(currentPrimitiveId))
00732                                 {
00733                                         pCurrentLocalMaterial= pMaterialHash->value(currentPrimitiveId);
00734                                         if (pCurrentLocalMaterial->isTransparent() == isTransparent) pCurrentLocalMaterial->glExecute();
00735                                 }
00736                         }
00737                         else if (pCurrentLocalMaterial != pCurrentMaterial)
00738                         {
00739                                 pCurrentLocalMaterial= pCurrentMaterial;
00740                                 if (materialIsRenderable) pCurrentLocalMaterial->glExecute();
00741                         }
00742                         if (pCurrentLocalMaterial->isTransparent() == isTransparent)
00743                         {
00744                                 GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->fansOffseti().at(i)];
00745                                 glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pOffset);
00746                         }
00747                 }
00748         }
00749 
00750 }
00751 
00752 // Use VBO to Draw primitives with specific materials from the specified GLC_PrimitiveGroup
00753 void GLC_Mesh::vboDrawSelectedPrimitivesGroupOf(GLC_PrimitiveGroup* pCurrentGroup, GLC_Material* pCurrentMaterial, bool materialIsRenderable
00754                 , bool isTransparent, const GLC_RenderProperties& renderProperties)
00755 {
00756         QSet<GLC_uint>* pSelectedPrimitive= renderProperties.setOfSelectedPrimitivesId();
00757         Q_ASSERT(NULL != pSelectedPrimitive);
00758 
00759         QHash<GLC_uint, GLC_Material*>* pMaterialHash= NULL;
00760         if (!renderProperties.hashOfOverwritePrimitiveMaterialsIsEmpty())
00761         {
00762                 pMaterialHash= renderProperties.hashOfOverwritePrimitiveMaterials();
00763         }
00764 
00765         GLC_Material* pCurrentLocalMaterial= pCurrentMaterial;
00766         // Draw triangles
00767         if (pCurrentGroup->containsTriangles())
00768         {
00769                 Q_ASSERT(pCurrentGroup->containsTrianglesGroupId());
00770                 const GLsizei trianglesGroupCount= static_cast<GLsizei>(pCurrentGroup->trianglesGroupOffset().size());
00771                 for (GLint i= 0; i < trianglesGroupCount; ++i)
00772                 {
00773                         GLC_uint currentPrimitiveId= pCurrentGroup->triangleGroupId(i);
00774                         if (pSelectedPrimitive->contains(currentPrimitiveId))
00775                         {
00776                                 if (!isTransparent)
00777                                 {
00778                                         GLC_SelectionMaterial::glExecute();
00779                                         pCurrentLocalMaterial= NULL;
00780                                         glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->trianglesGroupOffset().at(i));
00781                                 }
00782                         }
00783                         else if ((NULL != pMaterialHash) && pMaterialHash->contains(currentPrimitiveId))
00784                         {
00785                                 if (pMaterialHash->value(currentPrimitiveId)->isTransparent() == isTransparent)
00786                                 {
00787                                         GLC_Material* pMat= pMaterialHash->value(currentPrimitiveId);
00788                                         if (pMat != pCurrentLocalMaterial)
00789                                         {
00790                                                 pCurrentLocalMaterial= pMat;
00791                                                 pCurrentLocalMaterial->glExecute();
00792                                         }
00793                                         glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->trianglesGroupOffset().at(i));
00794                                 }
00795 
00796                         }
00797                         else if (materialIsRenderable)
00798                         {
00799                                 if (pCurrentLocalMaterial != pCurrentMaterial)
00800                                 {
00801                                         pCurrentLocalMaterial= pCurrentMaterial;
00802                                         pCurrentLocalMaterial->glExecute();
00803                                 }
00804                                 glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->trianglesGroupOffset().at(i));
00805                         }
00806                 }
00807         }
00808 
00809         // Draw Triangles strip
00810         if (pCurrentGroup->containsStrip())
00811         {
00812                 Q_ASSERT(pCurrentGroup->containsStripGroupId());
00813                 const GLsizei stripsCount= static_cast<GLsizei>(pCurrentGroup->stripsOffset().size());
00814                 for (GLint i= 0; i < stripsCount; ++i)
00815                 {
00816                         GLC_uint currentPrimitiveId= pCurrentGroup->stripGroupId(i);
00817                         if (pSelectedPrimitive->contains(currentPrimitiveId))
00818                         {
00819                                 if (!isTransparent)
00820                                 {
00821                                         GLC_SelectionMaterial::glExecute();
00822                                         pCurrentLocalMaterial= NULL;
00823                                         glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->stripsOffset().at(i));
00824                                 }
00825                         }
00826                         else if ((NULL != pMaterialHash) && pMaterialHash->contains(currentPrimitiveId))
00827                         {
00828                                 if (pMaterialHash->value(currentPrimitiveId)->isTransparent() == isTransparent)
00829                                 {
00830                                         GLC_Material* pMat= pMaterialHash->value(currentPrimitiveId);
00831                                         if (pMat != pCurrentLocalMaterial)
00832                                         {
00833                                                 pCurrentLocalMaterial= pMat;
00834                                                 pCurrentLocalMaterial->glExecute();
00835                                         }
00836                                         glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->stripsOffset().at(i));
00837                                 }
00838 
00839                         }
00840                         else if (materialIsRenderable)
00841                         {
00842                                 if (pCurrentLocalMaterial != pCurrentMaterial)
00843                                 {
00844                                         pCurrentLocalMaterial= pCurrentMaterial;
00845                                         pCurrentLocalMaterial->glExecute();
00846                                 }
00847                                 glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->stripsOffset().at(i));
00848                         }
00849                 }
00850         }
00851 
00852         // Draw Triangles fan
00853         if (pCurrentGroup->containsFan())
00854         {
00855                 Q_ASSERT(pCurrentGroup->containsFanGroupId());
00856                 const GLsizei fansCount= static_cast<GLsizei>(pCurrentGroup->fansOffset().size());
00857                 for (GLint i= 0; i < fansCount; ++i)
00858                 {
00859                         GLC_uint currentPrimitiveId= pCurrentGroup->fanGroupId(i);
00860                         if (pSelectedPrimitive->contains(currentPrimitiveId))
00861                         {
00862                                 if (!isTransparent)
00863                                 {
00864                                         GLC_SelectionMaterial::glExecute();
00865                                         pCurrentLocalMaterial= NULL;
00866                                         glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->fansOffset().at(i));
00867                                 }
00868                         }
00869                         else if ((NULL != pMaterialHash) && pMaterialHash->contains(currentPrimitiveId))
00870                         {
00871                                 if (pMaterialHash->value(currentPrimitiveId)->isTransparent() == isTransparent)
00872                                 {
00873                                         GLC_Material* pMat= pMaterialHash->value(currentPrimitiveId);
00874                                         if (pMat != pCurrentLocalMaterial)
00875                                         {
00876                                                 pCurrentLocalMaterial= pMat;
00877                                                 pCurrentLocalMaterial->glExecute();
00878                                         }
00879                                         glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->fansOffset().at(i));
00880                                 }
00881 
00882                         }
00883                         else if (materialIsRenderable)
00884                         {
00885                                 if (pCurrentLocalMaterial != pCurrentMaterial)
00886                                 {
00887                                         pCurrentLocalMaterial= pCurrentMaterial;
00888                                         pCurrentLocalMaterial->glExecute();
00889                                 }
00890                                 glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pCurrentGroup->fansOffset().at(i));
00891                         }
00892                 }
00893         }
00894 
00895 }
00896 
00897 // Use Vertex Array to Draw primitives with specific materials from the specified GLC_PrimitiveGroup
00898 void GLC_Mesh::vertexArrayDrawSelectedPrimitivesGroupOf(GLC_PrimitiveGroup* pCurrentGroup, GLC_Material* pCurrentMaterial, bool materialIsRenderable
00899                 , bool isTransparent, const GLC_RenderProperties& renderProperties)
00900 {
00901         QSet<GLC_uint>* pSelectedPrimitive= renderProperties.setOfSelectedPrimitivesId();
00902         Q_ASSERT(NULL != pSelectedPrimitive);
00903 
00904         QHash<GLC_uint, GLC_Material*>* pMaterialHash= NULL;
00905         if (!renderProperties.hashOfOverwritePrimitiveMaterialsIsEmpty())
00906         {
00907                 pMaterialHash= renderProperties.hashOfOverwritePrimitiveMaterials();
00908         }
00909 
00910         GLC_Material* pCurrentLocalMaterial= pCurrentMaterial;
00911         // Draw triangles
00912         if (pCurrentGroup->containsTriangles())
00913         {
00914                 Q_ASSERT(pCurrentGroup->containsTrianglesGroupId());
00915                 const GLsizei trianglesGroupCount= static_cast<GLsizei>(pCurrentGroup->trianglesGroupOffseti().size());
00916                 for (GLint i= 0; i < trianglesGroupCount; ++i)
00917                 {
00918                         GLC_uint currentPrimitiveId= pCurrentGroup->triangleGroupId(i);
00919                         if (pSelectedPrimitive->contains(currentPrimitiveId))
00920                         {
00921                                 if (!isTransparent)
00922                                 {
00923                                         GLC_SelectionMaterial::glExecute();
00924                                         pCurrentLocalMaterial= NULL;
00925                                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->trianglesGroupOffseti().at(i)];
00926                                         glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pOffset);
00927                                 }
00928                         }
00929                         else if ((NULL != pMaterialHash) && pMaterialHash->contains(currentPrimitiveId))
00930                         {
00931                                 if (pMaterialHash->value(currentPrimitiveId)->isTransparent() == isTransparent)
00932                                 {
00933                                         GLC_Material* pMat= pMaterialHash->value(currentPrimitiveId);
00934                                         if (pMat != pCurrentLocalMaterial)
00935                                         {
00936                                                 pCurrentLocalMaterial= pMat;
00937                                                 pCurrentLocalMaterial->glExecute();
00938                                         }
00939                                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->trianglesGroupOffseti().at(i)];
00940                                         glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pOffset);
00941                                 }
00942 
00943                         }
00944                         else if (materialIsRenderable)
00945                         {
00946                                 if (pCurrentLocalMaterial != pCurrentMaterial)
00947                                 {
00948                                         pCurrentLocalMaterial= pCurrentMaterial;
00949                                         pCurrentLocalMaterial->glExecute();
00950                                 }
00951                                 GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->trianglesGroupOffseti().at(i)];
00952                                 glDrawElements(GL_TRIANGLES, pCurrentGroup->trianglesIndexSizes().at(i), GL_UNSIGNED_INT, pOffset);
00953                         }
00954                 }
00955         }
00956 
00957         // Draw Triangles strip
00958         if (pCurrentGroup->containsStrip())
00959         {
00960                 Q_ASSERT(pCurrentGroup->containsStripGroupId());
00961                 const GLsizei stripsCount= static_cast<GLsizei>(pCurrentGroup->stripsOffseti().size());
00962                 for (GLint i= 0; i < stripsCount; ++i)
00963                 {
00964                         GLC_uint currentPrimitiveId= pCurrentGroup->stripGroupId(i);
00965                         if (pSelectedPrimitive->contains(currentPrimitiveId))
00966                         {
00967                                 if (!isTransparent)
00968                                 {
00969                                         GLC_SelectionMaterial::glExecute();
00970                                         pCurrentLocalMaterial= NULL;
00971                                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->stripsOffseti().at(i)];
00972                                         glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pOffset);
00973                                 }
00974                         }
00975                         else if ((NULL != pMaterialHash) && pMaterialHash->contains(currentPrimitiveId))
00976                         {
00977                                 if (pMaterialHash->value(currentPrimitiveId)->isTransparent() == isTransparent)
00978                                 {
00979                                         GLC_Material* pMat= pMaterialHash->value(currentPrimitiveId);
00980                                         if (pMat != pCurrentLocalMaterial)
00981                                         {
00982                                                 pCurrentLocalMaterial= pMat;
00983                                                 pCurrentLocalMaterial->glExecute();
00984                                         }
00985                                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->stripsOffseti().at(i)];
00986                                         glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pOffset);
00987                                 }
00988 
00989                         }
00990                         else if (materialIsRenderable)
00991                         {
00992                                 if (pCurrentLocalMaterial != pCurrentMaterial)
00993                                 {
00994                                         pCurrentLocalMaterial= pCurrentMaterial;
00995                                         pCurrentLocalMaterial->glExecute();
00996                                 }
00997                                 GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->stripsOffseti().at(i)];
00998                                 glDrawElements(GL_TRIANGLE_STRIP, pCurrentGroup->stripsSizes().at(i), GL_UNSIGNED_INT, pOffset);
00999                         }
01000                 }
01001         }
01002 
01003         // Draw Triangles fan
01004         if (pCurrentGroup->containsFan())
01005         {
01006                 Q_ASSERT(pCurrentGroup->containsFanGroupId());
01007                 const GLsizei fansCount= static_cast<GLsizei>(pCurrentGroup->fansOffseti().size());
01008                 for (GLint i= 0; i < fansCount; ++i)
01009                 {
01010                         GLC_uint currentPrimitiveId= pCurrentGroup->fanGroupId(i);
01011                         if (pSelectedPrimitive->contains(currentPrimitiveId))
01012                         {
01013                                 if (!isTransparent)
01014                                 {
01015                                         GLC_SelectionMaterial::glExecute();
01016                                         pCurrentLocalMaterial= NULL;
01017                                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->fansOffseti().at(i)];
01018                                         glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pOffset);
01019                                 }
01020                         }
01021                         else if ((NULL != pMaterialHash) && pMaterialHash->contains(currentPrimitiveId))
01022                         {
01023                                 if (pMaterialHash->value(currentPrimitiveId)->isTransparent() == isTransparent)
01024                                 {
01025                                         GLC_Material* pMat= pMaterialHash->value(currentPrimitiveId);
01026                                         if (pMat != pCurrentLocalMaterial)
01027                                         {
01028                                                 pCurrentLocalMaterial= pMat;
01029                                                 pCurrentLocalMaterial->glExecute();
01030                                         }
01031                                         GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->fansOffseti().at(i)];
01032                                         glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pOffset);
01033                                 }
01034 
01035                         }
01036                         else if (materialIsRenderable)
01037                         {
01038                                 if (pCurrentLocalMaterial != pCurrentMaterial)
01039                                 {
01040                                         pCurrentLocalMaterial= pCurrentMaterial;
01041                                         pCurrentLocalMaterial->glExecute();
01042                                 }
01043                                 GLvoid* pOffset= &m_MeshData.indexVectorHandle(m_CurrentLod)->data()[pCurrentGroup->fansOffseti().at(i)];
01044                                 glDrawElements(GL_TRIANGLE_FAN, pCurrentGroup->fansSizes().at(i), GL_UNSIGNED_INT, pOffset);
01045                         }
01046                 }
01047         }
01048 
01049 }
01050 
01051 // Activate mesh VBOs and IBO of the current LOD
01052 void GLC_Mesh::activateVboAndIbo()
01053 {
01054         // Activate Vertices VBO
01055         m_MeshData.useVBO(true, GLC_MeshData::GLC_Vertex);
01056         glVertexPointer(3, GL_FLOAT, 0, 0);
01057         glEnableClientState(GL_VERTEX_ARRAY);
01058 
01059         // Activate Normals VBO
01060         m_MeshData.useVBO(true, GLC_MeshData::GLC_Normal);
01061         glNormalPointer(GL_FLOAT, 0, 0);
01062         glEnableClientState(GL_NORMAL_ARRAY);
01063 
01064         // Activate texel VBO if needed
01065         if (m_MeshData.useVBO(true, GLC_MeshData::GLC_Texel))
01066         {
01067                 glTexCoordPointer(2, GL_FLOAT, 0, 0);
01068                 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
01069         }
01070 
01071         // Activate Color VBO if needed
01072         if ((m_ColorPearVertex && !m_IsSelected && !GLC_State::isInSelectionMode()) && m_MeshData.useVBO(true, GLC_MeshData::GLC_Color))
01073         {
01074                 glEnable(GL_COLOR_MATERIAL);
01075                 glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
01076                 glColorPointer(4, GL_FLOAT, 0, 0);
01077                 glEnableClientState(GL_COLOR_ARRAY);
01078         }
01079 
01080         m_MeshData.useIBO(true, m_CurrentLod);
01081 }
01082 
01083 // Activate vertex Array
01084 void GLC_Mesh::activateVertexArray()
01085 {
01086         // Use Vertex Array
01087         glVertexPointer(3, GL_FLOAT, 0, m_MeshData.positionVectorHandle()->data());
01088         glEnableClientState(GL_VERTEX_ARRAY);
01089 
01090         glNormalPointer(GL_FLOAT, 0, m_MeshData.normalVectorHandle()->data());
01091         glEnableClientState(GL_NORMAL_ARRAY);
01092 
01093         // Activate texel if needed
01094         if (!m_MeshData.texelVectorHandle()->isEmpty())
01095         {
01096                 glTexCoordPointer(2, GL_FLOAT, 0, m_MeshData.texelVectorHandle()->data());
01097                 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
01098         }
01099 
01100         // Activate Color array if needed
01101         if ((m_ColorPearVertex && !m_IsSelected && !GLC_State::isInSelectionMode()) && !m_MeshData.colorVectorHandle()->isEmpty())
01102         {
01103                 glEnable(GL_COLOR_MATERIAL);
01104                 glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
01105                 glColorPointer(4, GL_FLOAT, 0, m_MeshData.colorVectorHandle()->data());
01106                 glEnableClientState(GL_COLOR_ARRAY);
01107         }
01108 }
01109 
01110 
01111 
01112 #endif /* GLC_MESH_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon