glc_structoccurence.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_STRUCTOCCURENCE_H_
00028 #define GLC_STRUCTOCCURENCE_H_
00029
00030 #include "../maths/glc_matrix4x4.h"
00031 #include "../glc_boundingbox.h"
00032 #include "glc_structinstance.h"
00033 #include <QSet>
00034
00035 #include "../glc_config.h"
00036
00037 class GLC_WorldHandle;
00038 class GLC_Material;
00039 class GLC_RenderProperties;
00040
00043
00044
00045 class GLC_LIB_EXPORT GLC_StructOccurence
00046 {
00048
00050
00051
00052 public:
00054 GLC_StructOccurence();
00055
00057 GLC_StructOccurence(GLC_StructInstance*, GLC_WorldHandle* pWorldHandle= NULL, GLuint shaderId=0);
00058
00060 GLC_StructOccurence(GLC_3DRep*);
00061
00063 GLC_StructOccurence(GLC_WorldHandle*, const GLC_StructOccurence&, bool shareInstance);
00064
00066 virtual ~GLC_StructOccurence();
00068
00069
00071
00072 public:
00074 inline GLC_uint id() const
00075 {return m_Uid;}
00076
00078 inline const QString name() const
00079 {return m_pStructInstance->name();}
00080
00082 inline GLC_Matrix4x4 absoluteMatrix() const
00083 { return m_AbsoluteMatrix;}
00084
00086 inline bool isOrphan() const
00087 { return NULL == m_pParent;}
00088
00090 inline bool hasRepresentation() const
00091 { return m_HasRepresentation;}
00092
00094 inline GLC_StructInstance* structInstance() const
00095 { return m_pStructInstance;}
00096
00098 inline GLC_StructReference* structReference() const
00099 {
00100 Q_ASSERT(NULL != m_pStructInstance);
00101 return m_pStructInstance->structReference();
00102 }
00103
00105 inline int childCount() const
00106 { return m_Childs.size();}
00107
00109 inline bool hasChild() const
00110 {return childCount() > 0;}
00111
00113 inline GLC_StructOccurence* parent() const
00114 {return m_pParent;}
00115
00117
00118 inline GLC_StructOccurence* child(const int index) const
00119 {return m_Childs.at(index);}
00120
00122 inline QList<GLC_StructOccurence*> children() const
00123 { return m_Childs;}
00124
00126 unsigned int numberOfFaces() const;
00127
00129 unsigned int numberOfVertex() const;
00130
00132 unsigned int numberOfMaterials() const;
00133
00135 QSet<GLC_Material*> materialSet() const;
00136
00138 GLC_StructOccurence* clone(GLC_WorldHandle*, bool shareInstance) const;
00139
00141 bool isVisible() const;
00142
00144 GLC_BoundingBox boundingBox() const;
00145
00147 inline unsigned int occurenceNumber() const
00148 {return m_OccurenceNumber;}
00149
00151 GLC_RenderProperties* renderPropertiesHandle() const
00152 {return m_pRenderProperties;}
00153
00154
00156
00157
00159
00160 public:
00161
00163 inline void setName(const QString name) {m_pStructInstance->setName(name);}
00164
00166 GLC_StructOccurence* updateAbsoluteMatrix();
00167
00169 GLC_StructOccurence* updateChildrenAbsoluteMatrix();
00170
00172
00173 void addChild(GLC_StructOccurence*);
00174
00176 GLC_StructOccurence* addChild(GLC_StructInstance*);
00177
00179 void makeOrphan();
00180
00182
00183 bool removeChild(GLC_StructOccurence* pChild);
00184
00186 void reverseNormals();
00187
00189 void checkForRepresentation();
00190
00192 void setWorldHandle(GLC_WorldHandle*);
00193
00195 bool loadRepresentation();
00196
00198 bool unloadRepresentation();
00199
00201 inline void setOccurenceNumber(unsigned int n)
00202 {m_OccurenceNumber= n;}
00203
00205 unsigned int updateOccurenceNumber(unsigned int n);
00206
00208 void setVisibility(bool visibility);
00209
00211 void setRenderProperties(const GLC_RenderProperties& renderProperties);
00212
00214 void removeEmptyChildren();
00215
00217
00219
00221 private:
00223 void detach();
00224
00226
00228 private:
00230 GLC_uint m_Uid;
00231
00233 GLC_WorldHandle* m_pWorldHandle;
00234
00236 int* m_pNumberOfOccurence;
00237
00239 GLC_StructInstance* m_pStructInstance;
00240
00242 GLC_StructOccurence* m_pParent;
00243
00245 QList<GLC_StructOccurence*> m_Childs;
00246
00248 GLC_Matrix4x4 m_AbsoluteMatrix;
00249
00251 bool m_HasRepresentation;
00252
00254 unsigned int m_OccurenceNumber;
00255
00257 bool m_IsVisible;
00258
00260 GLC_RenderProperties* m_pRenderProperties;
00261
00262 };
00263
00264 #endif