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 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
66 #include "OSGMaterialBase.h"
67 #include "OSGMaterial.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::Material
78 The material base class.
81 The Material has two interfaces to return a State that represents it.
82 OSG::Material::makeState() creates a new OSG::State and returns it. This is
83 ok for rare use, but for every frame this is going to be too expensive. For
84 these cases OSG::Material::rebuildState() and OSG::Material::getState() are
85 used, which modify and return an internal copy of the State.
87 The other method to implement is OSG::Material::isTransparent(), to identify
88 transparent materials to be rendered after the opaque ones.
92 /***************************************************************************\
93 * Field Documentation *
94 \***************************************************************************/
96 /*! \var Int32 MaterialBase::_sfSortKey
100 /*! \var Int32 MaterialBase::_sfTransparencyMode
101 Set the transparency mode, possible values are TransparencyAutoDetection,
102 TransparencyForceTransparent and TransparencyForceOpaque
106 /***************************************************************************\
107 * FieldType/FieldTrait Instantiation *
108 \***************************************************************************/
110 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
111 PointerType FieldTraits
<Material
*, nsOSG
>::_type(
114 Material::getClassType(),
118 OSG_FIELDTRAITS_GETTYPE_NS(Material
*, nsOSG
)
120 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
124 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
128 /***************************************************************************\
129 * Field Description *
130 \***************************************************************************/
132 void MaterialBase::classDescInserter(TypeObject
&oType
)
134 FieldDescriptionBase
*pDesc
= NULL
;
137 pDesc
= new SFInt32::Description(
138 SFInt32::getClassType(),
141 SortKeyFieldId
, SortKeyFieldMask
,
143 (Field::SFDefaultFlags
| Field::FStdAccess
),
144 static_cast<FieldEditMethodSig
>(&Material::editHandleSortKey
),
145 static_cast<FieldGetMethodSig
>(&Material::getHandleSortKey
));
147 oType
.addInitialDesc(pDesc
);
149 pDesc
= new SFInt32::Description(
150 SFInt32::getClassType(),
152 "Set the transparency mode, possible values are TransparencyAutoDetection,\n"
153 "TransparencyForceTransparent and TransparencyForceOpaque \n",
154 TransparencyModeFieldId
, TransparencyModeFieldMask
,
156 (Field::SFDefaultFlags
| Field::FStdAccess
),
157 static_cast<FieldEditMethodSig
>(&Material::editHandleTransparencyMode
),
158 static_cast<FieldGetMethodSig
>(&Material::getHandleTransparencyMode
));
160 oType
.addInitialDesc(pDesc
);
164 MaterialBase::TypeObject
MaterialBase::_type(
165 MaterialBase::getClassname(),
166 Inherited::getClassname(),
170 reinterpret_cast<InitContainerF
>(&Material::initMethod
),
171 reinterpret_cast<ExitContainerF
>(&Material::exitMethod
),
172 reinterpret_cast<InitalInsertDescFunc
>(
173 reinterpret_cast<void *>(&Material::classDescInserter
)),
176 "<?xml version=\"1.0\"?>\n"
179 " name=\"Material\"\n"
180 " parent=\"Attachment\"\n"
181 " library=\"System\"\n"
182 " structure=\"abstract\"\n"
183 " pointerfieldtypes=\"both\"\n"
184 " systemcomponent=\"true\"\n"
185 " parentsystemcomponent=\"true\"\n"
186 " decoratable=\"false\"\n"
187 " useLocalIncludes=\"false\"\n"
188 " docGroupBase=\"GrpSystemMaterial\"\n"
191 " The material base class.\n"
194 " The Material has two interfaces to return a State that represents it.\n"
195 " OSG::Material::makeState() creates a new OSG::State and returns it. This is \n"
196 " ok for rare use, but for every frame this is going to be too expensive. For \n"
197 " these cases OSG::Material::rebuildState() and OSG::Material::getState() are \n"
198 " used, which modify and return an internal copy of the State. \n"
200 " The other method to implement is OSG::Material::isTransparent(), to identify\n"
201 " transparent materials to be rendered after the opaque ones.\n"
204 "\t name=\"sortKey\"\n"
205 "\t type=\"Int32\"\n"
206 "\t cardinality=\"single\"\n"
207 "\t visibility=\"external\"\n"
208 "\t defaultValue=\"0\"\n"
209 "\t access=\"public\"\n"
213 "\t name=\"transparencyMode\"\n"
214 "\t type=\"Int32\"\n"
215 "\t cardinality=\"single\"\n"
216 "\t visibility=\"external\"\n"
217 "\t defaultValue=\"0\"\n"
218 "\t access=\"public\"\n"
220 "\tSet the transparency mode, possible values are TransparencyAutoDetection,\n"
221 "\tTransparencyForceTransparent and TransparencyForceOpaque \n"
223 "</FieldContainer>\n",
224 "The material base class.\n"
227 "The Material has two interfaces to return a State that represents it.\n"
228 "OSG::Material::makeState() creates a new OSG::State and returns it. This is \n"
229 "ok for rare use, but for every frame this is going to be too expensive. For \n"
230 "these cases OSG::Material::rebuildState() and OSG::Material::getState() are \n"
231 "used, which modify and return an internal copy of the State. \n"
233 "The other method to implement is OSG::Material::isTransparent(), to identify\n"
234 "transparent materials to be rendered after the opaque ones.\n"
238 /*------------------------------ get -----------------------------------*/
240 FieldContainerType
&MaterialBase::getType(void)
245 const FieldContainerType
&MaterialBase::getType(void) const
250 UInt32
MaterialBase::getContainerSize(void) const
252 return sizeof(Material
);
255 /*------------------------- decorator get ------------------------------*/
258 SFInt32
*MaterialBase::editSFSortKey(void)
260 editSField(SortKeyFieldMask
);
265 const SFInt32
*MaterialBase::getSFSortKey(void) const
271 SFInt32
*MaterialBase::editSFTransparencyMode(void)
273 editSField(TransparencyModeFieldMask
);
275 return &_sfTransparencyMode
;
278 const SFInt32
*MaterialBase::getSFTransparencyMode(void) const
280 return &_sfTransparencyMode
;
288 /*------------------------------ access -----------------------------------*/
290 SizeT
MaterialBase::getBinSize(ConstFieldMaskArg whichField
)
292 SizeT returnValue
= Inherited::getBinSize(whichField
);
294 if(FieldBits::NoField
!= (SortKeyFieldMask
& whichField
))
296 returnValue
+= _sfSortKey
.getBinSize();
298 if(FieldBits::NoField
!= (TransparencyModeFieldMask
& whichField
))
300 returnValue
+= _sfTransparencyMode
.getBinSize();
306 void MaterialBase::copyToBin(BinaryDataHandler
&pMem
,
307 ConstFieldMaskArg whichField
)
309 Inherited::copyToBin(pMem
, whichField
);
311 if(FieldBits::NoField
!= (SortKeyFieldMask
& whichField
))
313 _sfSortKey
.copyToBin(pMem
);
315 if(FieldBits::NoField
!= (TransparencyModeFieldMask
& whichField
))
317 _sfTransparencyMode
.copyToBin(pMem
);
321 void MaterialBase::copyFromBin(BinaryDataHandler
&pMem
,
322 ConstFieldMaskArg whichField
)
324 Inherited::copyFromBin(pMem
, whichField
);
326 if(FieldBits::NoField
!= (SortKeyFieldMask
& whichField
))
328 editSField(SortKeyFieldMask
);
329 _sfSortKey
.copyFromBin(pMem
);
331 if(FieldBits::NoField
!= (TransparencyModeFieldMask
& whichField
))
333 editSField(TransparencyModeFieldMask
);
334 _sfTransparencyMode
.copyFromBin(pMem
);
341 /*------------------------- constructors ----------------------------------*/
343 MaterialBase::MaterialBase(void) :
345 _sfSortKey (Int32(0)),
346 _sfTransparencyMode (Int32(0))
350 MaterialBase::MaterialBase(const MaterialBase
&source
) :
352 _sfSortKey (source
._sfSortKey
),
353 _sfTransparencyMode (source
._sfTransparencyMode
)
358 /*-------------------------- destructors ----------------------------------*/
360 MaterialBase::~MaterialBase(void)
365 GetFieldHandlePtr
MaterialBase::getHandleSortKey (void) const
367 SFInt32::GetHandlePtr
returnValue(
368 new SFInt32::GetHandle(
370 this->getType().getFieldDesc(SortKeyFieldId
),
371 const_cast<MaterialBase
*>(this)));
376 EditFieldHandlePtr
MaterialBase::editHandleSortKey (void)
378 SFInt32::EditHandlePtr
returnValue(
379 new SFInt32::EditHandle(
381 this->getType().getFieldDesc(SortKeyFieldId
),
385 editSField(SortKeyFieldMask
);
390 GetFieldHandlePtr
MaterialBase::getHandleTransparencyMode (void) const
392 SFInt32::GetHandlePtr
returnValue(
393 new SFInt32::GetHandle(
394 &_sfTransparencyMode
,
395 this->getType().getFieldDesc(TransparencyModeFieldId
),
396 const_cast<MaterialBase
*>(this)));
401 EditFieldHandlePtr
MaterialBase::editHandleTransparencyMode(void)
403 SFInt32::EditHandlePtr
returnValue(
404 new SFInt32::EditHandle(
405 &_sfTransparencyMode
,
406 this->getType().getFieldDesc(TransparencyModeFieldId
),
410 editSField(TransparencyModeFieldMask
);
416 #ifdef OSG_MT_CPTR_ASPECT
417 void MaterialBase::execSyncV( FieldContainer
&oFrom
,
418 ConstFieldMaskArg whichField
,
419 AspectOffsetStore
&oOffsets
,
420 ConstFieldMaskArg syncMode
,
421 const UInt32 uiSyncInfo
)
423 Material
*pThis
= static_cast<Material
*>(this);
425 pThis
->execSync(static_cast<Material
*>(&oFrom
),
435 void MaterialBase::resolveLinks(void)
437 Inherited::resolveLinks();