glc_primitivegroup.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  Version 2.0.0 Beta 1, packaged on April 2010.
00006 
00007  http://glc-lib.sourceforge.net
00008 
00009  GLC-lib is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  GLC-lib is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with GLC-lib; if not, write to the Free Software
00021  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 *****************************************************************************/
00024 
00026 
00027 #ifndef GLC_PRIMITIVEGROUP_H_
00028 #define GLC_PRIMITIVEGROUP_H_
00029 
00030 #include "../glc_ext.h"
00031 #include "../glc_global.h"
00032 
00033 #include "glc_config.h"
00034 
00037 
00041 
00042 class GLC_LIB_EXPORT GLC_PrimitiveGroup
00043 {
00044         friend QDataStream &operator<<(QDataStream &, const GLC_PrimitiveGroup &);
00045         friend QDataStream &operator>>(QDataStream &, GLC_PrimitiveGroup &);
00046 
00047 public:
00049 
00051 
00052 
00054         GLC_PrimitiveGroup(GLC_uint id= 0);
00055 
00057         GLC_PrimitiveGroup(const GLC_PrimitiveGroup&);
00058 
00060         GLC_PrimitiveGroup(const GLC_PrimitiveGroup&, GLC_uint);
00061 
00063         GLC_PrimitiveGroup& operator=(const GLC_PrimitiveGroup&);
00064 
00065         ~GLC_PrimitiveGroup();
00066 
00068 
00070 
00072 
00073 public:
00075         static quint32 chunckID();
00076 
00078         inline bool isFinished() const
00079         {return m_IsFinished;}
00080 
00082         inline GLC_uint id() const
00083         {return m_Id;}
00084 
00086         inline bool containsTriangles() const
00087         {return m_TrianglesIndexSize > 0;}
00088 
00090         inline bool containsTrianglesGroupId() const
00091         {return !m_TrianglesId.isEmpty();}
00092 
00094         inline GLC_uint triangleGroupId(int index)
00095         {return m_TrianglesId.at(index);}
00096 
00098         inline int trianglesIndexSize() const
00099         {return m_TrianglesIndexSize;}
00100 
00102         inline const IndexSizes& trianglesIndexSizes() const
00103         {return m_TrianglesGroupsSizes;}
00104 
00106         inline const IndexList& trianglesIndex() const
00107         {
00108                 Q_ASSERT(!m_IsFinished);
00109                 return m_TrianglesIndex;
00110         }
00111 
00113         inline const GLvoid* trianglesIndexOffset() const
00114         {return m_TrianglesGroupOffset.first();}
00115 
00117         inline int trianglesIndexOffseti() const
00118         {return m_TrianglesGroupOffseti.first();}
00119 
00121         inline const OffsetVector& trianglesGroupOffset() const
00122         {return m_TrianglesGroupOffset;}
00123 
00125         inline const OffsetVectori& trianglesGroupOffseti() const
00126         {return m_TrianglesGroupOffseti;}
00127 
00129         inline bool containsStrip() const
00130         {return m_TrianglesStripSize > 0;}
00131 
00133         inline bool containsStripGroupId() const
00134         {return !m_StripsId.isEmpty();}
00135 
00137         inline GLC_uint stripGroupId(int index)
00138         {return m_StripsId.at(index);}
00139 
00141         inline int stripsIndexSize() const
00142         {return m_TrianglesStripSize;}
00143 
00145         inline const IndexList& stripsIndex() const
00146         {
00147                 Q_ASSERT(!m_IsFinished);
00148                 return m_StripsIndex;
00149         }
00150 
00152         inline const IndexSizes& stripsSizes() const
00153         {return m_StripIndexSizes;}
00154 
00156         inline const OffsetVector& stripsOffset() const
00157         {return m_StripIndexOffset;}
00158 
00160         inline const OffsetVectori& stripsOffseti() const
00161         {return m_StripIndexOffseti;}
00162 
00164         inline bool containsFan() const
00165         {return m_TrianglesFanSize > 0;}
00166 
00168         inline bool containsFanGroupId() const
00169         {return !m_FansId.isEmpty();}
00170 
00172         inline GLC_uint fanGroupId(int index)
00173         {return m_FansId.at(index);}
00174 
00176         inline int fansIndexSize() const
00177         {return m_TrianglesFanSize;}
00178 
00180         inline const IndexList& fansIndex() const
00181         {
00182                 Q_ASSERT(!m_IsFinished);
00183                 return m_FansIndex;
00184         }
00185 
00187         inline const IndexSizes& fansSizes() const
00188         {return m_FansIndexSizes;}
00189 
00191         inline const OffsetVector& fansOffset() const
00192         {return m_FanIndexOffset;}
00193 
00195         inline const OffsetVectori& fansOffseti() const
00196         {return m_FanIndexOffseti;}
00197 
00199 
00201 
00203 
00204 public:
00206         inline void setId(GLC_uint id)
00207         {m_Id= id;}
00208 
00210         void addTriangles(const IndexList& input, GLC_uint id= 0);
00211 
00213         void setTrianglesOffset(GLvoid* pOffset);
00214 
00216         void setTrianglesOffseti(int offset);
00217 
00219         void addTrianglesStrip(const IndexList&, GLC_uint id= 0);
00220 
00222         void setBaseTrianglesStripOffset(GLvoid*);
00223 
00225         void setBaseTrianglesStripOffseti(int);
00226 
00228         void addTrianglesFan(const IndexList&, GLC_uint id= 0);
00229 
00231         void setBaseTrianglesFanOffset(GLvoid*);
00232 
00234         void setBaseTrianglesFanOffseti(int);
00235 
00237         void changeToVboMode();
00238 
00240         inline void finish()
00241         {
00242                 m_TrianglesIndex.clear();
00243                 m_StripsIndex.clear();
00244                 m_FansIndex.clear();
00245                 m_IsFinished= true;
00246         }
00247 
00249         void clear();
00250 
00252 
00254 // Private members
00256 private:
00258         GLC_uint m_Id;
00259 
00261         IndexList m_TrianglesIndex;
00262 
00264         IndexSizes m_TrianglesGroupsSizes;
00265 
00267         OffsetVector m_TrianglesGroupOffset;
00268         OffsetVectori m_TrianglesGroupOffseti;
00269 
00271         QList<GLC_uint> m_TrianglesId;
00272 
00274         IndexList m_StripsIndex;
00275 
00277         IndexSizes m_StripIndexSizes;
00278 
00280         OffsetVector m_StripIndexOffset;
00281         OffsetVectori m_StripIndexOffseti;
00282 
00284         QList<GLC_uint> m_StripsId;
00285 
00287         IndexList m_FansIndex;
00288 
00290         IndexSizes m_FansIndexSizes;
00291 
00293         OffsetVector m_FanIndexOffset;
00294         OffsetVectori m_FanIndexOffseti;
00295 
00297         QList<GLC_uint> m_FansId;
00298 
00300         int m_IsFinished;
00301 
00303         int m_TrianglesIndexSize;
00304 
00306         int m_TrianglesStripSize;
00307 
00309         int m_TrianglesFanSize;
00310 
00312         static quint32 m_ChunkId;
00313 
00314 };
00315 
00317 QDataStream &operator<<(QDataStream &, const GLC_PrimitiveGroup &);
00318 QDataStream &operator>>(QDataStream &, GLC_PrimitiveGroup &);
00319 
00320 #endif /* GLC_PRIMITIVEGROUP_H_ */

SourceForge.net Logo

©2005 Laurent Ribon