1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
40 #ifndef _OSGVARIANTMATERIAL_H_
41 #define _OSGVARIANTMATERIAL_H_
46 #include "OSGPrimeMaterial.h"
47 #include "OSGVariantMaterialBase.h"
48 #include "OSGMapCacheHandlerMixin.h"
52 class VariantMaterial
;
54 /*! \ingroup GrpSystemMaterialBase
60 typedef VariantMaterialBase ParentT
;
61 typedef VariantMaterial FinalContainer
;
63 typedef SFMaterialPtrMap MapCacheField
;
64 typedef MapCacheField::StoredType MapCache
;
65 typedef SFMaterialPtrMap::EditHandle::KeyPool MapKeyPool
;
67 typedef MapCache::mapped_type MapCacheElement
;
68 typedef MapCache::key_type MapCacheKey
;
70 typedef PrimeMaterial FinalizedElement
;
72 static const bool IsInternal
= false;
74 static void setFallback(ParentT
*pContainer
, MapCacheElement pElem
)
76 pContainer
->setFallbackMaterial(pElem
);
79 static MapCacheElement
getFallback(ParentT
*pContainer
)
81 return pContainer
->getFallbackMaterial();
84 static const Char8
*getFieldName(void)
86 return "materialStore";
90 /*! \brief Material using variant set. See \ref
91 PageSystemMaterialVariantMaterial for a description.
92 \ingroup GrpSystemMaterialBase
93 \ingroup GrpLibOSGSystem
97 class OSG_SYSTEM_DLLMAPPING VariantMaterial
:
98 public MapCacheHandlerMixin
<VarMatMapCache
>
100 /*========================== PUBLIC =================================*/
104 typedef MapCacheHandlerMixin
<VarMatMapCache
> Inherited
;
105 typedef VariantMaterial Self
;
107 /*---------------------------------------------------------------------*/
111 virtual void changed(ConstFieldMaskArg whichField
,
116 /*---------------------------------------------------------------------*/
120 virtual PrimeMaterial
*finalize( MapCacheKey oKey
,
121 const StateOverride
*pOverrides
,
125 /*---------------------------------------------------------------------*/
129 void addMaterial(PrimeMaterial
* const materialP
,
130 MaterialMapKey key
= 0);
132 void subMaterial(MaterialMapKey key
= 0);
135 /*---------------------------------------------------------------------*/
139 PrimeMaterial
*findMaterial(MaterialMapKey key
) const;
142 /*---------------------------------------------------------------------*/
146 virtual bool isTransparent(void) const;
149 /*---------------------------------------------------------------------*/
150 /*! \name your_category */
153 const SFMaterialPtrMap
*getSFMaterialStore(void) const;
156 /*---------------------------------------------------------------------*/
160 virtual void dump( UInt32 uiIndent
= 0,
161 const BitVector bvFlags
= 0) const;
164 /*---------------------------------------------------------------------*/
165 /*! \name Rendering */
169 /*---------------------------------------------------------------------*/
174 /*---------------------------------------------------------------------*/
179 /*---------------------------------------------------------------------*/
184 /*---------------------------------------------------------------------*/
189 /*---------------------------------------------------------------------*/
194 virtual bool operator == (const VariantMaterial
&other
) const;
198 /*========================= PROTECTED ===============================*/
202 typedef SFMaterialPtrMap::StoredType MaterialPtrMap
;
203 typedef MaterialPtrMap ::iterator MaterialPtrMapIt
;
204 typedef MaterialPtrMap ::const_iterator MaterialPtrMapConstIt
;
206 typedef SFMaterialPtrMap::EditHandle::KeyPool MapKeyPool
;
208 /*---------------------------------------------------------------------*/
209 /*! \name Type information */
212 static void classDescInserter(TypeObject
&oType
);
215 /*---------------------------------------------------------------------*/
220 /*---------------------------------------------------------------------*/
221 /*! \name Constructors */
224 VariantMaterial(void);
225 VariantMaterial(const VariantMaterial
&source
);
228 /*---------------------------------------------------------------------*/
229 /*! \name Destructor */
232 virtual ~VariantMaterial(void);
235 /*---------------------------------------------------------------------*/
240 /*---------------------------------------------------------------------*/
241 /*! \name MT Destruction */
245 /*---------------------------------------------------------------------*/
249 static void initMethod(InitPhase ePhase
);
252 /*---------------------------------------------------------------------*/
253 /*! \name Ptr MField Set */
257 /*---------------------------------------------------------------------*/
258 /*! \name Destructor */
262 /*========================== PRIVATE ================================*/
266 friend class FieldContainer
;
267 friend class VariantMaterialBase
;
269 // prohibit default functions (move to 'public' if you need one)
270 void operator =(const VariantMaterial
&source
);
273 typedef VariantMaterial
*VariantMaterialP
;
277 #include "OSGVariantMaterialBase.inl"
278 #include "OSGVariantMaterial.inl"
280 #endif /* _OSGVARIANTMATERIAL_H_ */