glc_structoccurence.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_STRUCTOCCURENCE_H_
00026 #define GLC_STRUCTOCCURENCE_H_
00027 
00028 #include "../maths/glc_matrix4x4.h"
00029 #include "../glc_boundingbox.h"
00030 #include "glc_structinstance.h"
00031 #include <QSet>
00032 
00033 #include "../glc_config.h"
00034 
00035 class GLC_WorldHandle;
00036 class GLC_Material;
00037 class GLC_RenderProperties;
00038 
00041 
00042 
00043 class GLC_LIB_EXPORT GLC_StructOccurence
00044 {
00046 
00048 
00049 
00050 public:
00052         GLC_StructOccurence();
00053 
00055         GLC_StructOccurence(GLC_StructInstance*, GLC_WorldHandle* pWorldHandle= NULL, GLuint shaderId=0);
00056 
00058         GLC_StructOccurence(GLC_3DRep*);
00059 
00061         GLC_StructOccurence(GLC_WorldHandle*, const GLC_StructOccurence&, bool shareInstance);
00062 
00064         virtual ~GLC_StructOccurence();
00066 
00067 
00069 
00070 public:
00072         inline GLC_uint id() const
00073         {return m_Uid;}
00074 
00076         inline const QString name() const
00077         {return m_pStructInstance->name();}
00078 
00080         inline GLC_Matrix4x4 absoluteMatrix() const
00081         { return m_AbsoluteMatrix;}
00082 
00084         GLC_Matrix4x4 occurrenceRelativeMatrix() const;
00085 
00087         inline bool isOrphan() const
00088         { return NULL == m_pParent;}
00089 
00091         inline bool hasParent() const
00092         { return NULL != m_pParent;}
00093 
00095         bool hasRepresentation() const;
00096 
00098         bool has3DViewInstance() const;
00099 
00101         inline GLC_StructInstance* structInstance() const
00102         { return m_pStructInstance;}
00103 
00105         inline GLC_StructReference* structReference() const
00106         {
00107                 Q_ASSERT(NULL != m_pStructInstance);
00108                 return m_pStructInstance->structReference();
00109         }
00110 
00112         inline int childCount() const
00113         { return m_Childs.size();}
00114 
00116         inline bool hasChild() const
00117         {return childCount() > 0;}
00118 
00120         bool canBeAddedToChildren(GLC_StructOccurence* pOccurence) const;
00121 
00123         inline GLC_StructOccurence* parent() const
00124         {return m_pParent;}
00125 
00127 
00128         inline GLC_StructOccurence* child(const int index) const
00129         {return m_Childs.at(index);}
00130 
00132         inline QList<GLC_StructOccurence*> children() const
00133         {return m_Childs;}
00134 
00136         QList<GLC_StructOccurence*> subOccurenceList() const;
00137 
00139         unsigned int numberOfFaces() const;
00140 
00142         unsigned int numberOfVertex() const;
00143 
00145         unsigned int numberOfMaterials() const;
00146 
00148         QSet<GLC_Material*> materialSet() const;
00149 
00151         GLC_StructOccurence* clone(GLC_WorldHandle*, bool shareInstance) const;
00152 
00154         bool isVisible() const;
00155 
00157         GLC_BoundingBox boundingBox() const;
00158 
00160         inline unsigned int occurenceNumber() const
00161         {return m_OccurenceNumber;}
00162 
00164         GLC_RenderProperties* renderPropertiesHandle() const
00165         {return m_pRenderProperties;}
00166 
00168         unsigned int nodeCount() const;
00169 
00171         inline GLC_WorldHandle* worldHandle() const
00172         {return m_pWorldHandle;}
00173 
00175         QSet<GLC_StructReference*> childrenReferences() const;
00176 
00178         static QSet<GLC_StructReference*> parentsReferences(const GLC_StructOccurence* pOccurence);
00179 
00181         inline bool useAutomatic3DViewInstanceCreation() const
00182         {return m_AutomaticCreationOf3DViewInstance;}
00183 
00185         inline bool isFlexible() const
00186         {return (m_pRelativeMatrix != NULL);}
00188 
00189 
00191 
00192 public:
00193 
00195         inline void setName(const QString name) {m_pStructInstance->setName(name);}
00196 
00198         GLC_StructOccurence* updateAbsoluteMatrix();
00199 
00201         GLC_StructOccurence* updateChildrenAbsoluteMatrix();
00202 
00204 
00205         void addChild(GLC_StructOccurence*);
00206 
00208         GLC_StructOccurence* addChild(GLC_StructInstance*);
00209 
00211         void makeOrphan();
00212 
00214 
00215         bool removeChild(GLC_StructOccurence* pChild);
00216 
00218         void reverseNormals();
00219 
00221         bool create3DViewInstance();
00222 
00224         bool remove3DViewInstance();
00225 
00227         void setWorldHandle(GLC_WorldHandle*);
00228 
00230         bool loadRepresentation();
00231 
00233         bool unloadRepresentation();
00234 
00236         inline void setOccurenceNumber(unsigned int n)
00237         {m_OccurenceNumber= n;}
00238 
00240         unsigned int updateOccurenceNumber(unsigned int n);
00241 
00243         void setVisibility(bool visibility);
00244 
00246         void setRenderProperties(const GLC_RenderProperties& renderProperties);
00247 
00249         void removeEmptyChildren();
00250 
00252         void setReference(GLC_StructReference* pRef);
00253 
00255         inline void setAutomatic3DViewInstanceCreationUsage(bool usage)
00256         {m_AutomaticCreationOf3DViewInstance= usage;}
00257 
00259         void makeFlexible(const GLC_Matrix4x4& relativeMatrix);
00260 
00262         void makeRigid();
00264 
00266 // Private services function
00268 private:
00270         void detach();
00271 
00273 // Private members
00275 private:
00277         GLC_uint m_Uid;
00278 
00280         GLC_WorldHandle* m_pWorldHandle;
00281 
00283         int* m_pNumberOfOccurence;
00284 
00286         GLC_StructInstance* m_pStructInstance;
00287 
00289         GLC_StructOccurence* m_pParent;
00290 
00292         QList<GLC_StructOccurence*> m_Childs;
00293 
00295         GLC_Matrix4x4 m_AbsoluteMatrix;
00296 
00298         unsigned int m_OccurenceNumber;
00299 
00301         bool m_IsVisible;
00302 
00304         GLC_RenderProperties* m_pRenderProperties;
00305 
00307         bool m_AutomaticCreationOf3DViewInstance;
00308 
00310         GLC_Matrix4x4* m_pRelativeMatrix;
00311 
00312 };
00313 
00314 #endif /* GLC_STRUCTOCCURENCE_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon