1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
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 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
50 *****************************************************************************
51 \*****************************************************************************/
54 #ifndef _OSGCGFXMATERIALBASE_H_
55 #define _OSGCGFXMATERIALBASE_H_
61 #include "OSGConfig.h"
62 #include "OSGContribCgFXDef.h"
64 //#include "OSGBaseTypes.h"
66 #include "OSGVariantMaterial.h" // Parent
68 #include "OSGSysFields.h" // TreatTechniquesAsVariants type
69 #include "OSGBaseFields.h" // EffectFile type
70 #include "OSGShaderProgramVariablesFields.h" // Variables type
71 #include "OSGCgFXTechniqueFields.h" // Techniques type
72 #include "OSGTextureObjChunkFields.h" // Textures type
74 #include "OSGCgFXMaterialFields.h"
81 //! \brief CgFXMaterial Base Class.
83 class OSG_CONTRIBCGFX_DLLMAPPING CgFXMaterialBase
: public VariantMaterial
87 typedef VariantMaterial Inherited
;
88 typedef VariantMaterial ParentContainer
;
90 typedef Inherited::TypeObject TypeObject
;
91 typedef TypeObject::InitPhase InitPhase
;
93 OSG_GEN_INTERNALPTR(CgFXMaterial
);
95 /*========================== PUBLIC =================================*/
101 TreatTechniquesAsVariantsFieldId
= Inherited::NextFieldId
,
102 EffectFileFieldId
= TreatTechniquesAsVariantsFieldId
+ 1,
103 ParameterValueSourceFieldId
= EffectFileFieldId
+ 1,
104 EffectStringFieldId
= ParameterValueSourceFieldId
+ 1,
105 CompilerOptionsFieldId
= EffectStringFieldId
+ 1,
106 VariablesFieldId
= CompilerOptionsFieldId
+ 1,
107 SelectedTechniqueFieldId
= VariablesFieldId
+ 1,
108 StateVariablesFieldId
= SelectedTechniqueFieldId
+ 1,
109 TechniquesFieldId
= StateVariablesFieldId
+ 1,
110 TexturesFieldId
= TechniquesFieldId
+ 1,
111 GLIdFieldId
= TexturesFieldId
+ 1,
112 NextFieldId
= GLIdFieldId
+ 1
115 static const OSG::BitVector TreatTechniquesAsVariantsFieldMask
=
116 (TypeTraits
<BitVector
>::One
<< TreatTechniquesAsVariantsFieldId
);
117 static const OSG::BitVector EffectFileFieldMask
=
118 (TypeTraits
<BitVector
>::One
<< EffectFileFieldId
);
119 static const OSG::BitVector ParameterValueSourceFieldMask
=
120 (TypeTraits
<BitVector
>::One
<< ParameterValueSourceFieldId
);
121 static const OSG::BitVector EffectStringFieldMask
=
122 (TypeTraits
<BitVector
>::One
<< EffectStringFieldId
);
123 static const OSG::BitVector CompilerOptionsFieldMask
=
124 (TypeTraits
<BitVector
>::One
<< CompilerOptionsFieldId
);
125 static const OSG::BitVector VariablesFieldMask
=
126 (TypeTraits
<BitVector
>::One
<< VariablesFieldId
);
127 static const OSG::BitVector SelectedTechniqueFieldMask
=
128 (TypeTraits
<BitVector
>::One
<< SelectedTechniqueFieldId
);
129 static const OSG::BitVector StateVariablesFieldMask
=
130 (TypeTraits
<BitVector
>::One
<< StateVariablesFieldId
);
131 static const OSG::BitVector TechniquesFieldMask
=
132 (TypeTraits
<BitVector
>::One
<< TechniquesFieldId
);
133 static const OSG::BitVector TexturesFieldMask
=
134 (TypeTraits
<BitVector
>::One
<< TexturesFieldId
);
135 static const OSG::BitVector GLIdFieldMask
=
136 (TypeTraits
<BitVector
>::One
<< GLIdFieldId
);
137 static const OSG::BitVector NextFieldMask
=
138 (TypeTraits
<BitVector
>::One
<< NextFieldId
);
140 typedef SFBool SFTreatTechniquesAsVariantsType
;
141 typedef SFString SFEffectFileType
;
142 typedef SFUInt8 SFParameterValueSourceType
;
143 typedef SFString SFEffectStringType
;
144 typedef MFString MFCompilerOptionsType
;
145 typedef SFUnrecChildShaderProgramVariablesPtr SFVariablesType
;
146 typedef SFString SFSelectedTechniqueType
;
147 typedef SFUInt32 SFStateVariablesType
;
148 typedef MFUnrecCgFXTechniquePtr MFTechniquesType
;
149 typedef MFUnrecTextureObjChunkPtr MFTexturesType
;
150 typedef SFGLenum SFGLIdType
;
152 /*---------------------------------------------------------------------*/
153 /*! \name Class Get */
156 static FieldContainerType
&getClassType (void);
157 static UInt32
getClassTypeId (void);
158 static UInt16
getClassGroupId(void);
161 /*---------------------------------------------------------------------*/
162 /*! \name FieldContainer Get */
165 virtual FieldContainerType
&getType (void);
166 virtual const FieldContainerType
&getType (void) const;
168 virtual UInt32
getContainerSize(void) const;
171 /*---------------------------------------------------------------------*/
172 /*! \name Field Get */
176 SFBool
*editSFTreatTechniquesAsVariants(void);
177 const SFBool
*getSFTreatTechniquesAsVariants (void) const;
179 SFString
*editSFEffectFile (void);
180 const SFString
*getSFEffectFile (void) const;
182 SFUInt8
*editSFParameterValueSource(void);
183 const SFUInt8
*getSFParameterValueSource (void) const;
185 SFString
*editSFEffectString (void);
186 const SFString
*getSFEffectString (void) const;
188 MFString
*editMFCompilerOptions(void);
189 const MFString
*getMFCompilerOptions (void) const;
191 SFGLenum
*editSFGLId (void);
192 const SFGLenum
*getSFGLId (void) const;
195 bool &editTreatTechniquesAsVariants(void);
196 bool getTreatTechniquesAsVariants (void) const;
198 std::string
&editEffectFile (void);
199 const std::string
&getEffectFile (void) const;
201 UInt8
&editParameterValueSource(void);
202 UInt8
getParameterValueSource (void) const;
204 std::string
&editEffectString (void);
205 const std::string
&getEffectString (void) const;
207 MFString ::reference
editCompilerOptions(const UInt32 index
);
208 const std::string
&getCompilerOptions (const UInt32 index
) const;
210 GLenum
&editGLId (void);
211 const GLenum
&getGLId (void) const;
214 /*---------------------------------------------------------------------*/
215 /*! \name Field Set */
218 void setTreatTechniquesAsVariants(const bool value
);
219 void setEffectFile (const std::string
&value
);
220 void setParameterValueSource(const UInt8 value
);
221 void setEffectString (const std::string
&value
);
222 void setGLId (const GLenum
&value
);
225 /*---------------------------------------------------------------------*/
226 /*! \name Ptr Field Set */
230 /*---------------------------------------------------------------------*/
231 /*! \name Ptr MField Set */
235 /*---------------------------------------------------------------------*/
236 /*! \name Binary Access */
239 virtual SizeT
getBinSize (ConstFieldMaskArg whichField
);
240 virtual void copyToBin (BinaryDataHandler
&pMem
,
241 ConstFieldMaskArg whichField
);
242 virtual void copyFromBin(BinaryDataHandler
&pMem
,
243 ConstFieldMaskArg whichField
);
247 /*---------------------------------------------------------------------*/
248 /*! \name Construction */
251 static CgFXMaterialTransitPtr
create (void);
252 static CgFXMaterial
*createEmpty (void);
254 static CgFXMaterialTransitPtr
createLocal (
255 BitVector bFlags
= FCLocal::All
);
257 static CgFXMaterial
*createEmptyLocal(
258 BitVector bFlags
= FCLocal::All
);
260 static CgFXMaterialTransitPtr
createDependent (BitVector bFlags
);
263 /*---------------------------------------------------------------------*/
267 virtual FieldContainerTransitPtr
shallowCopy (void) const;
268 virtual FieldContainerTransitPtr
shallowCopyLocal(
269 BitVector bFlags
= FCLocal::All
) const;
270 virtual FieldContainerTransitPtr
shallowCopyDependent(
271 BitVector bFlags
) const;
274 /*========================= PROTECTED ===============================*/
278 static TypeObject _type
;
280 static void classDescInserter(TypeObject
&oType
);
281 static const Char8
*getClassname (void );
283 /*---------------------------------------------------------------------*/
287 SFBool _sfTreatTechniquesAsVariants
;
288 SFString _sfEffectFile
;
289 SFUInt8 _sfParameterValueSource
;
290 SFString _sfEffectString
;
291 MFString _mfCompilerOptions
;
292 SFUnrecChildShaderProgramVariablesPtr _sfVariables
;
293 SFString _sfSelectedTechnique
;
294 SFUInt32 _sfStateVariables
;
295 MFUnrecCgFXTechniquePtr _mfTechniques
;
296 MFUnrecTextureObjChunkPtr _mfTextures
;
300 /*---------------------------------------------------------------------*/
301 /*! \name Constructors */
304 CgFXMaterialBase(void);
305 CgFXMaterialBase(const CgFXMaterialBase
&source
);
308 /*---------------------------------------------------------------------*/
309 /*! \name Destructors */
312 virtual ~CgFXMaterialBase(void);
315 /*---------------------------------------------------------------------*/
316 /*! \name onCreate */
319 void onCreate(const CgFXMaterial
*source
= NULL
);
322 /*---------------------------------------------------------------------*/
323 /*! \name Child linking */
326 virtual bool unlinkChild(FieldContainer
* const pChild
,
327 UInt16
const childFieldId
);
330 /*---------------------------------------------------------------------*/
331 /*! \name Generic Field Access */
334 GetFieldHandlePtr
getHandleTreatTechniquesAsVariants (void) const;
335 EditFieldHandlePtr
editHandleTreatTechniquesAsVariants(void);
336 GetFieldHandlePtr
getHandleEffectFile (void) const;
337 EditFieldHandlePtr
editHandleEffectFile (void);
338 GetFieldHandlePtr
getHandleParameterValueSource (void) const;
339 EditFieldHandlePtr
editHandleParameterValueSource(void);
340 GetFieldHandlePtr
getHandleEffectString (void) const;
341 EditFieldHandlePtr
editHandleEffectString (void);
342 GetFieldHandlePtr
getHandleCompilerOptions (void) const;
343 EditFieldHandlePtr
editHandleCompilerOptions(void);
344 GetFieldHandlePtr
getHandleVariables (void) const;
345 EditFieldHandlePtr
editHandleVariables (void);
346 GetFieldHandlePtr
getHandleSelectedTechnique (void) const;
347 EditFieldHandlePtr
editHandleSelectedTechnique(void);
348 GetFieldHandlePtr
getHandleStateVariables (void) const;
349 EditFieldHandlePtr
editHandleStateVariables (void);
350 GetFieldHandlePtr
getHandleTechniques (void) const;
351 EditFieldHandlePtr
editHandleTechniques (void);
352 GetFieldHandlePtr
getHandleTextures (void) const;
353 EditFieldHandlePtr
editHandleTextures (void);
354 GetFieldHandlePtr
getHandleGLId (void) const;
355 EditFieldHandlePtr
editHandleGLId (void);
358 /*---------------------------------------------------------------------*/
359 /*! \name Field Get */
362 const SFUnrecChildShaderProgramVariablesPtr
*getSFVariables (void) const;
363 SFUnrecChildShaderProgramVariablesPtr
*editSFVariables (void);
365 SFString
*editSFSelectedTechnique(void);
366 const SFString
*getSFSelectedTechnique (void) const;
368 SFUInt32
*editSFStateVariables (void);
369 const SFUInt32
*getSFStateVariables (void) const;
370 const MFUnrecCgFXTechniquePtr
*getMFTechniques (void) const;
371 MFUnrecCgFXTechniquePtr
*editMFTechniques (void);
372 const MFUnrecTextureObjChunkPtr
*getMFTextures (void) const;
373 MFUnrecTextureObjChunkPtr
*editMFTextures (void);
376 ShaderProgramVariables
* getVariables (void) const;
378 std::string
&editSelectedTechnique(void);
379 const std::string
&getSelectedTechnique (void) const;
381 UInt32
&editStateVariables (void);
382 UInt32
getStateVariables (void) const;
384 CgFXTechnique
* getTechniques (const UInt32 index
) const;
386 TextureObjChunk
* getTextures (const UInt32 index
) const;
389 /*---------------------------------------------------------------------*/
390 /*! \name Field Set */
393 void setVariables (ShaderProgramVariables
* const value
);
394 void setSelectedTechnique(const std::string
&value
);
395 void setStateVariables (const UInt32 value
);
398 /*---------------------------------------------------------------------*/
399 /*! \name Ptr MField Set */
402 void pushToTechniques (CgFXTechnique
* const value
);
403 void assignTechniques (const MFUnrecCgFXTechniquePtr
&value
);
404 void removeFromTechniques (UInt32 uiIndex
);
405 void removeObjFromTechniques(CgFXTechnique
* const value
);
406 void clearTechniques (void );
408 void pushToTextures (TextureObjChunk
* const value
);
409 void assignTextures (const MFUnrecTextureObjChunkPtr
&value
);
410 void removeFromTextures (UInt32 uiIndex
);
411 void removeObjFromTextures(TextureObjChunk
* const value
);
412 void clearTextures (void );
415 /*---------------------------------------------------------------------*/
419 #ifdef OSG_MT_CPTR_ASPECT
420 virtual void execSyncV( FieldContainer
&oFrom
,
421 ConstFieldMaskArg whichField
,
422 AspectOffsetStore
&oOffsets
,
423 ConstFieldMaskArg syncMode
,
424 const UInt32 uiSyncInfo
);
426 void execSync ( CgFXMaterialBase
*pFrom
,
427 ConstFieldMaskArg whichField
,
428 AspectOffsetStore
&oOffsets
,
429 ConstFieldMaskArg syncMode
,
430 const UInt32 uiSyncInfo
);
434 /*---------------------------------------------------------------------*/
439 /*---------------------------------------------------------------------*/
440 /*! \name Aspect Create */
443 #ifdef OSG_MT_CPTR_ASPECT
444 virtual FieldContainer
*createAspectCopy(
445 const FieldContainer
*pRefAspect
) const;
449 /*---------------------------------------------------------------------*/
453 /*---------------------------------------------------------------------*/
457 virtual void resolveLinks(void);
460 /*========================== PRIVATE ================================*/
463 /*---------------------------------------------------------------------*/
465 // prohibit default functions (move to 'public' if you need one)
466 void operator =(const CgFXMaterialBase
&source
);
469 typedef CgFXMaterialBase
*CgFXMaterialBaseP
;
473 #endif /* _OSGCGFXMATERIALBASE_H_ */