glc_meshdata.h
Go to the documentation of this file.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_MESHDATA_H_
00028 #define GLC_MESHDATA_H_
00029
00030 #include <QVector>
00031
00032 #include "glc_lod.h"
00033 #include "../glc_global.h"
00034
00035 #include "../glc_config.h"
00036
00037
00040
00042
00043 class GLC_LIB_EXPORT GLC_MeshData
00044 {
00045 friend QDataStream &operator<<(QDataStream &, const GLC_MeshData &);
00046 friend QDataStream &operator>>(QDataStream &, GLC_MeshData &);
00047
00048 public:
00049
00051 enum VboType
00052 {
00053 GLC_Vertex= 30,
00054 GLC_Normal,
00055 GLC_Texel,
00056 GLC_Color
00057 };
00058
00060
00062
00063 public:
00065 GLC_MeshData();
00066
00068 GLC_MeshData(const GLC_MeshData&);
00069
00071 GLC_MeshData& operator=(const GLC_MeshData&);
00072
00074 virtual ~GLC_MeshData();
00076
00078
00080
00081 public:
00083 static quint32 chunckID();
00084
00086 inline int lodCount() const
00087 {return m_LodList.size();}
00088
00090 GLfloatVector positionVector() const;
00091
00093 GLfloatVector normalVector() const;
00094
00096 GLfloatVector texelVector() const;
00097
00099 GLfloatVector colorVector() const;
00100
00102 inline GLfloatVector* positionVectorHandle()
00103 { return &m_Positions;}
00104
00106 inline GLfloatVector* normalVectorHandle()
00107 { return &m_Normals;}
00108
00110 inline GLfloatVector* texelVectorHandle()
00111 { return &m_Texels;}
00112
00114 inline GLfloatVector* colorVectorHandle()
00115 { return &m_Colors;}
00116
00118 inline GLuintVector indexVector(const int i= 0) const
00119 {
00120 Q_ASSERT(i < m_LodList.size());
00121 return m_LodList.at(i)->indexVector();
00122 }
00123
00125 inline GLuintVector* indexVectorHandle(const int i= 0) const
00126 {
00127 Q_ASSERT(i < m_LodList.size());
00128 return m_LodList.at(i)->indexVectorHandle();
00129 }
00130
00132 inline int indexVectorSize(const int i= 0) const
00133 {
00134 Q_ASSERT(i < m_LodList.size());
00135 return m_LodList.at(i)->indexVectorSize();
00136 }
00138 inline GLC_Lod* getLod(int index) const
00139 {
00140 return m_LodList.value(index);
00141 }
00142
00144 inline bool isEmpty() const
00145 {return (0 == m_PositionSize) && (0 == m_Positions.size());}
00146
00147
00149
00151
00153
00154 public:
00156 inline void appendLod(double accuracy= 0.0)
00157 {m_LodList.append(new GLC_Lod(accuracy));}
00158
00160 void finishVbo();
00161
00163 void finishLod();
00164
00166 void clear();
00167
00169
00171
00173
00174 public:
00176 void createVBOs();
00177
00179 bool useVBO(bool, GLC_MeshData::VboType);
00180
00182 inline void useIBO(bool use, const int currentLod= 0)
00183 {
00184 if (use) m_LodList.at(currentLod)->useIBO();
00185 else glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
00186 }
00187
00189
00191
00193 private:
00194
00196 GLuint m_VboId;
00197
00199 GLfloatVector m_Positions;
00200
00202 GLfloatVector m_Normals;
00203
00205 GLfloatVector m_Texels;
00206
00208 GLfloatVector m_Colors;
00209
00211 GLuint m_NormalVboId;
00212
00214 GLuint m_TexelVboId;
00215
00217 GLuint m_ColorVboId;
00218
00220 QList<GLC_Lod*> m_LodList;
00221
00223 int m_PositionSize;
00224
00226 int m_TexelsSize;
00227
00229 int m_ColorSize;
00230
00232 static quint32 m_ChunkId;
00233 };
00234
00236 QDataStream &operator<<(QDataStream &, const GLC_MeshData &);
00237 QDataStream &operator>>(QDataStream &, GLC_MeshData &);
00238
00239 #endif