changed: gcc8 base update
[opensg.git] / Source / System / Material / Base / OSGMaterialBase.cpp
blob085ed0464bfec7dec6481dadf85c0421abf7f3cd
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class Material!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
66 #include "OSGMaterialBase.h"
67 #include "OSGMaterial.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::Material
78 The material base class.
80 \ext
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.
89 \endext
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(
112 "MaterialPtr",
113 "AttachmentPtr",
114 Material::getClassType(),
115 nsOSG);
116 #endif
118 OSG_FIELDTRAITS_GETTYPE_NS(Material *, nsOSG)
120 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
121 Material *,
122 nsOSG)
124 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
125 Material *,
126 nsOSG)
128 /***************************************************************************\
129 * Field Description *
130 \***************************************************************************/
132 void MaterialBase::classDescInserter(TypeObject &oType)
134 FieldDescriptionBase *pDesc = NULL;
137 pDesc = new SFInt32::Description(
138 SFInt32::getClassType(),
139 "sortKey",
141 SortKeyFieldId, SortKeyFieldMask,
142 false,
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(),
151 "transparencyMode",
152 "Set the transparency mode, possible values are TransparencyAutoDetection,\n"
153 "TransparencyForceTransparent and TransparencyForceOpaque \n",
154 TransparencyModeFieldId, TransparencyModeFieldMask,
155 false,
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(),
167 "Material",
168 nsOSG, //Namespace
169 NULL,
170 reinterpret_cast<InitContainerF>(&Material::initMethod),
171 reinterpret_cast<ExitContainerF>(&Material::exitMethod),
172 reinterpret_cast<InitalInsertDescFunc>(
173 reinterpret_cast<void *>(&Material::classDescInserter)),
174 false,
176 "<?xml version=\"1.0\"?>\n"
177 "\n"
178 "<FieldContainer\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"
189 " >\n"
190 " \n"
191 " The material base class.\n"
192 " \n"
193 " \\ext\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"
199 " \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"
202 " \\endext\n"
203 " <Field\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"
210 "\t >\n"
211 " </Field>\n"
212 " <Field\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"
219 "\t >\n"
220 "\tSet the transparency mode, possible values are TransparencyAutoDetection,\n"
221 "\tTransparencyForceTransparent and TransparencyForceOpaque \n"
222 " </Field>\n"
223 "</FieldContainer>\n",
224 "The material base class.\n"
225 "\n"
226 "\\ext\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"
232 "\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"
235 "\\endext\n"
238 /*------------------------------ get -----------------------------------*/
240 FieldContainerType &MaterialBase::getType(void)
242 return _type;
245 const FieldContainerType &MaterialBase::getType(void) const
247 return _type;
250 UInt32 MaterialBase::getContainerSize(void) const
252 return sizeof(Material);
255 /*------------------------- decorator get ------------------------------*/
258 SFInt32 *MaterialBase::editSFSortKey(void)
260 editSField(SortKeyFieldMask);
262 return &_sfSortKey;
265 const SFInt32 *MaterialBase::getSFSortKey(void) const
267 return &_sfSortKey;
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();
303 return returnValue;
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) :
344 Inherited(),
345 _sfSortKey (Int32(0)),
346 _sfTransparencyMode (Int32(0))
350 MaterialBase::MaterialBase(const MaterialBase &source) :
351 Inherited(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(
369 &_sfSortKey,
370 this->getType().getFieldDesc(SortKeyFieldId),
371 const_cast<MaterialBase *>(this)));
373 return returnValue;
376 EditFieldHandlePtr MaterialBase::editHandleSortKey (void)
378 SFInt32::EditHandlePtr returnValue(
379 new SFInt32::EditHandle(
380 &_sfSortKey,
381 this->getType().getFieldDesc(SortKeyFieldId),
382 this));
385 editSField(SortKeyFieldMask);
387 return returnValue;
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)));
398 return returnValue;
401 EditFieldHandlePtr MaterialBase::editHandleTransparencyMode(void)
403 SFInt32::EditHandlePtr returnValue(
404 new SFInt32::EditHandle(
405 &_sfTransparencyMode,
406 this->getType().getFieldDesc(TransparencyModeFieldId),
407 this));
410 editSField(TransparencyModeFieldMask);
412 return returnValue;
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),
426 whichField,
427 oOffsets,
428 syncMode,
429 uiSyncInfo);
431 #endif
435 void MaterialBase::resolveLinks(void)
437 Inherited::resolveLinks();
443 OSG_END_NAMESPACE