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  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_PRIMITIVEGROUP_H_
00026 #define GLC_PRIMITIVEGROUP_H_
00027 
00028 #include "../glc_ext.h"
00029 #include "../glc_global.h"
00030 
00031 #include "../glc_config.h"
00032 
00035 
00039 
00040 class GLC_LIB_EXPORT GLC_PrimitiveGroup
00041 {
00042         friend GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_PrimitiveGroup &);
00043         friend GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_PrimitiveGroup &);
00044 
00045 public:
00047 
00049 
00050 
00052         GLC_PrimitiveGroup(GLC_uint id= 0);
00053 
00055         GLC_PrimitiveGroup(const GLC_PrimitiveGroup&);
00056 
00058         GLC_PrimitiveGroup(const GLC_PrimitiveGroup&, GLC_uint);
00059 
00061         GLC_PrimitiveGroup& operator=(const GLC_PrimitiveGroup&);
00062 
00063         ~GLC_PrimitiveGroup();
00064 
00066 
00068 
00070 
00071 public:
00073         static quint32 chunckID();
00074 
00076         inline bool isFinished() const
00077         {return m_IsFinished;}
00078 
00080         inline GLC_uint id() const
00081         {return m_Id;}
00082 
00084         inline bool containsTriangles() const
00085         {return m_TrianglesIndexSize > 0;}
00086 
00088         inline bool containsTrianglesGroupId() const
00089         {return !m_TrianglesId.isEmpty();}
00090 
00092         inline GLC_uint triangleGroupId(int index)
00093         {return m_TrianglesId.at(index);}
00094 
00096         inline int trianglesIndexSize() const
00097         {return m_TrianglesIndexSize;}
00098 
00100         inline const IndexSizes& trianglesIndexSizes() const
00101         {return m_TrianglesGroupsSizes;}
00102 
00104         inline const IndexList& trianglesIndex() const
00105         {
00106                 Q_ASSERT(!m_IsFinished);
00107                 return m_TrianglesIndex;
00108         }
00109 
00111         inline const GLvoid* trianglesIndexOffset() const
00112         {return m_TrianglesGroupOffset.first();}
00113 
00115         inline int trianglesIndexOffseti() const
00116         {return m_TrianglesGroupOffseti.first();}
00117 
00119         inline const OffsetVector& trianglesGroupOffset() const
00120         {return m_TrianglesGroupOffset;}
00121 
00123         inline const OffsetVectori& trianglesGroupOffseti() const
00124         {return m_TrianglesGroupOffseti;}
00125 
00127         inline bool containsStrip() const
00128         {return m_TrianglesStripSize > 0;}
00129 
00131         inline bool containsStripGroupId() const
00132         {return !m_StripsId.isEmpty();}
00133 
00135         inline GLC_uint stripGroupId(int index)
00136         {return m_StripsId.at(index);}
00137 
00139         inline int stripsIndexSize() const
00140         {return m_TrianglesStripSize;}
00141 
00143         inline const IndexList& stripsIndex() const
00144         {
00145                 Q_ASSERT(!m_IsFinished);
00146                 return m_StripsIndex;
00147         }
00148 
00150         inline const IndexSizes& stripsSizes() const
00151         {return m_StripIndexSizes;}
00152 
00154         inline const OffsetVector& stripsOffset() const
00155         {return m_StripIndexOffset;}
00156 
00158         inline const OffsetVectori& stripsOffseti() const
00159         {return m_StripIndexOffseti;}
00160 
00162         inline bool containsFan() const
00163         {return m_TrianglesFanSize > 0;}
00164 
00166         inline bool containsFanGroupId() const
00167         {return !m_FansId.isEmpty();}
00168 
00170         inline GLC_uint fanGroupId(int index)
00171         {return m_FansId.at(index);}
00172 
00174         inline int fansIndexSize() const
00175         {return m_TrianglesFanSize;}
00176 
00178         inline const IndexList& fansIndex() const
00179         {
00180                 Q_ASSERT(!m_IsFinished);
00181                 return m_FansIndex;
00182         }
00183 
00185         inline const IndexSizes& fansSizes() const
00186         {return m_FansIndexSizes;}
00187 
00189         inline const OffsetVector& fansOffset() const
00190         {return m_FanIndexOffset;}
00191 
00193         inline const OffsetVectori& fansOffseti() const
00194         {return m_FanIndexOffseti;}
00195 
00197 
00199 
00201 
00202 public:
00204         inline void setId(GLC_uint id)
00205         {m_Id= id;}
00206 
00208         void addTriangles(const IndexList& input, GLC_uint id= 0);
00209 
00211         void setTrianglesOffset(GLvoid* pOffset);
00212 
00214         void setTrianglesOffseti(int offset);
00215 
00217         void addTrianglesStrip(const IndexList&, GLC_uint id= 0);
00218 
00220         void setBaseTrianglesStripOffset(GLvoid*);
00221 
00223         void setBaseTrianglesStripOffseti(int);
00224 
00226         void addTrianglesFan(const IndexList&, GLC_uint id= 0);
00227 
00229         void setBaseTrianglesFanOffset(GLvoid*);
00230 
00232         void setBaseTrianglesFanOffseti(int);
00233 
00235         void computeVboOffset();
00236 
00238         inline void finish()
00239         {
00240                 m_TrianglesIndex.clear();
00241                 m_StripsIndex.clear();
00242                 m_FansIndex.clear();
00243                 m_IsFinished= true;
00244         }
00245 
00247         void clear();
00248 
00250 
00252 // Private members
00254 private:
00256         GLC_uint m_Id;
00257 
00259         IndexList m_TrianglesIndex;
00260 
00262         IndexSizes m_TrianglesGroupsSizes;
00263 
00265         OffsetVector m_TrianglesGroupOffset;
00266         OffsetVectori m_TrianglesGroupOffseti;
00267 
00269         QList<GLC_uint> m_TrianglesId;
00270 
00272         IndexList m_StripsIndex;
00273 
00275         IndexSizes m_StripIndexSizes;
00276 
00278         OffsetVector m_StripIndexOffset;
00279         OffsetVectori m_StripIndexOffseti;
00280 
00282         QList<GLC_uint> m_StripsId;
00283 
00285         IndexList m_FansIndex;
00286 
00288         IndexSizes m_FansIndexSizes;
00289 
00291         OffsetVector m_FanIndexOffset;
00292         OffsetVectori m_FanIndexOffseti;
00293 
00295         QList<GLC_uint> m_FansId;
00296 
00298         int m_IsFinished;
00299 
00301         int m_TrianglesIndexSize;
00302 
00304         int m_TrianglesStripSize;
00305 
00307         int m_TrianglesFanSize;
00308 
00310         static quint32 m_ChunkId;
00311 
00312 };
00313 
00315 GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_PrimitiveGroup &);
00316 GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_PrimitiveGroup &);
00317 
00318 #endif /* GLC_PRIMITIVEGROUP_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon