changed: gcc8 base update
[opensg.git] / Source / System / Material / Base / OSGSimpleMaterialBase.cpp
blobae649da6b0582cc8cae06ccab97499dbbfe8992c
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 SimpleMaterial!
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"
64 #include "OSGGL.h" // ColorMaterial default header
67 #include "OSGSimpleMaterialBase.h"
68 #include "OSGSimpleMaterial.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::SimpleMaterial
79 The simple material class. See \ref PageSystemMaterialSimpleMaterial for a
80 description.
82 This material wraps the standard calls to glMaterial() in
83 OSG::SimpleMaterial::_sfAmbient, OSG::SimpleMaterial::_sfDiffuse,
84 OSG::SimpleMaterial::_sfEmission, OSG::SimpleMaterial::_sfSpecular,
85 OSG::SimpleMaterial::_sfShininess. In addition it supports transparency
86 (OSG::SimpleMaterial::_sfTransparency), can switch lighting
87 (OSG::SimpleMaterial::_sfLit) and the color material
88 (OSG::SimpleMaterial::_sfColorMaterial).
91 /***************************************************************************\
92 * Field Documentation *
93 \***************************************************************************/
95 /*! \var Color3f SimpleMaterialBase::_sfAmbient
96 The ambient color for the material.
99 /*! \var Color3f SimpleMaterialBase::_sfDiffuse
100 The diffuse color for the material.
103 /*! \var Color3f SimpleMaterialBase::_sfSpecular
104 The color used for the specular highlight on the object.
107 /*! \var Real32 SimpleMaterialBase::_sfShininess
108 The shininess value to use when lighting the object. Higher values equal smaller and brighter highlights.
111 /*! \var Color3f SimpleMaterialBase::_sfEmission
115 /*! \var Real32 SimpleMaterialBase::_sfTransparency
116 Defines how transparent objects are rendered with this material.
119 /*! \var bool SimpleMaterialBase::_sfLit
123 /*! \var GLenum SimpleMaterialBase::_sfColorMaterial
124 Defines which color material mode this material affects.
128 /***************************************************************************\
129 * FieldType/FieldTrait Instantiation *
130 \***************************************************************************/
132 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
133 PointerType FieldTraits<SimpleMaterial *, nsOSG>::_type(
134 "SimpleMaterialPtr",
135 "ChunkMaterialPtr",
136 SimpleMaterial::getClassType(),
137 nsOSG);
138 #endif
140 OSG_FIELDTRAITS_GETTYPE_NS(SimpleMaterial *, nsOSG)
142 /***************************************************************************\
143 * Field Description *
144 \***************************************************************************/
146 void SimpleMaterialBase::classDescInserter(TypeObject &oType)
148 FieldDescriptionBase *pDesc = NULL;
151 pDesc = new SFColor3f::Description(
152 SFColor3f::getClassType(),
153 "ambient",
154 "The ambient color for the material.\n",
155 AmbientFieldId, AmbientFieldMask,
156 false,
157 (Field::SFDefaultFlags | Field::FStdAccess),
158 static_cast<FieldEditMethodSig>(&SimpleMaterial::editHandleAmbient),
159 static_cast<FieldGetMethodSig >(&SimpleMaterial::getHandleAmbient));
161 oType.addInitialDesc(pDesc);
163 pDesc = new SFColor3f::Description(
164 SFColor3f::getClassType(),
165 "diffuse",
166 "The diffuse color for the material.\n",
167 DiffuseFieldId, DiffuseFieldMask,
168 false,
169 (Field::SFDefaultFlags | Field::FStdAccess),
170 static_cast<FieldEditMethodSig>(&SimpleMaterial::editHandleDiffuse),
171 static_cast<FieldGetMethodSig >(&SimpleMaterial::getHandleDiffuse));
173 oType.addInitialDesc(pDesc);
175 pDesc = new SFColor3f::Description(
176 SFColor3f::getClassType(),
177 "specular",
178 "The color used for the specular highlight on the object.\n",
179 SpecularFieldId, SpecularFieldMask,
180 false,
181 (Field::SFDefaultFlags | Field::FStdAccess),
182 static_cast<FieldEditMethodSig>(&SimpleMaterial::editHandleSpecular),
183 static_cast<FieldGetMethodSig >(&SimpleMaterial::getHandleSpecular));
185 oType.addInitialDesc(pDesc);
187 pDesc = new SFReal32::Description(
188 SFReal32::getClassType(),
189 "shininess",
190 "The shininess value to use when lighting the object. Higher values equal smaller and brighter highlights.\n",
191 ShininessFieldId, ShininessFieldMask,
192 false,
193 (Field::SFDefaultFlags | Field::FStdAccess),
194 static_cast<FieldEditMethodSig>(&SimpleMaterial::editHandleShininess),
195 static_cast<FieldGetMethodSig >(&SimpleMaterial::getHandleShininess));
197 oType.addInitialDesc(pDesc);
199 pDesc = new SFColor3f::Description(
200 SFColor3f::getClassType(),
201 "emission",
203 EmissionFieldId, EmissionFieldMask,
204 false,
205 (Field::SFDefaultFlags | Field::FStdAccess),
206 static_cast<FieldEditMethodSig>(&SimpleMaterial::editHandleEmission),
207 static_cast<FieldGetMethodSig >(&SimpleMaterial::getHandleEmission));
209 oType.addInitialDesc(pDesc);
211 pDesc = new SFReal32::Description(
212 SFReal32::getClassType(),
213 "transparency",
214 "Defines how transparent objects are rendered with this material.\n",
215 TransparencyFieldId, TransparencyFieldMask,
216 false,
217 (Field::SFDefaultFlags | Field::FStdAccess),
218 static_cast<FieldEditMethodSig>(&SimpleMaterial::editHandleTransparency),
219 static_cast<FieldGetMethodSig >(&SimpleMaterial::getHandleTransparency));
221 oType.addInitialDesc(pDesc);
223 pDesc = new SFBool::Description(
224 SFBool::getClassType(),
225 "lit",
227 LitFieldId, LitFieldMask,
228 false,
229 (Field::SFDefaultFlags | Field::FStdAccess),
230 static_cast<FieldEditMethodSig>(&SimpleMaterial::editHandleLit),
231 static_cast<FieldGetMethodSig >(&SimpleMaterial::getHandleLit));
233 oType.addInitialDesc(pDesc);
235 pDesc = new SFGLenum::Description(
236 SFGLenum::getClassType(),
237 "colorMaterial",
238 "Defines which color material mode this material affects.\n",
239 ColorMaterialFieldId, ColorMaterialFieldMask,
240 false,
241 (Field::SFDefaultFlags | Field::FStdAccess),
242 static_cast<FieldEditMethodSig>(&SimpleMaterial::editHandleColorMaterial),
243 static_cast<FieldGetMethodSig >(&SimpleMaterial::getHandleColorMaterial));
245 oType.addInitialDesc(pDesc);
249 SimpleMaterialBase::TypeObject SimpleMaterialBase::_type(
250 SimpleMaterialBase::getClassname(),
251 Inherited::getClassname(),
252 "NULL",
253 nsOSG, //Namespace
254 reinterpret_cast<PrototypeCreateF>(&SimpleMaterialBase::createEmptyLocal),
255 reinterpret_cast<InitContainerF>(&SimpleMaterial::initMethod),
256 reinterpret_cast<ExitContainerF>(&SimpleMaterial::exitMethod),
257 reinterpret_cast<InitalInsertDescFunc>(
258 reinterpret_cast<void *>(&SimpleMaterial::classDescInserter)),
259 false,
261 "<?xml version=\"1.0\" ?>\n"
262 "\n"
263 "<FieldContainer\n"
264 " name=\"SimpleMaterial\"\n"
265 " parent=\"ChunkMaterial\"\n"
266 " library=\"System\"\n"
267 " structure=\"concrete\"\n"
268 " pointerfieldtypes=\"none\"\n"
269 " systemcomponent=\"true\"\n"
270 " parentsystemcomponent=\"true\"\n"
271 " docGroupBase=\"GrpSystemMaterial\"\n"
272 " >\n"
273 "\n"
274 " The simple material class. See \\ref PageSystemMaterialSimpleMaterial for a\n"
275 " description.\n"
276 "\n"
277 " This material wraps the standard calls to glMaterial() in\n"
278 " OSG::SimpleMaterial::_sfAmbient, OSG::SimpleMaterial::_sfDiffuse, \n"
279 " OSG::SimpleMaterial::_sfEmission, OSG::SimpleMaterial::_sfSpecular, \n"
280 " OSG::SimpleMaterial::_sfShininess. In addition it supports transparency \n"
281 " (OSG::SimpleMaterial::_sfTransparency), can switch lighting \n"
282 " (OSG::SimpleMaterial::_sfLit) and the color material \n"
283 " (OSG::SimpleMaterial::_sfColorMaterial).\n"
284 " <Field\n"
285 "\t name=\"ambient\"\n"
286 "\t type=\"Color3f\"\n"
287 "\t cardinality=\"single\"\n"
288 "\t visibility=\"external\"\n"
289 "\t defaultValue=\"0.f,0.f,0.f\"\n"
290 "\t >\n"
291 " The ambient color for the material.\n"
292 " </Field>\n"
293 " <Field\n"
294 "\t name=\"diffuse\"\n"
295 "\t type=\"Color3f\"\n"
296 "\t cardinality=\"single\"\n"
297 "\t visibility=\"external\"\n"
298 "\t defaultValue=\"0.f,0.f,0.f\"\n"
299 "\t >\n"
300 " The diffuse color for the material.\n"
301 " </Field>\n"
302 " <Field\n"
303 "\t name=\"specular\"\n"
304 "\t type=\"Color3f\"\n"
305 "\t cardinality=\"single\"\n"
306 "\t visibility=\"external\"\n"
307 "\t defaultValue=\"0.f,0.f,0.f\"\n"
308 "\t >\n"
309 " The color used for the specular highlight on the object.\n"
310 " </Field>\n"
311 " <Field\n"
312 "\t name=\"shininess\"\n"
313 "\t type=\"Real32\"\n"
314 "\t cardinality=\"single\"\n"
315 "\t visibility=\"external\"\n"
316 "\t defaultValue=\"1.f\"\n"
317 " min_value=\"0.0\"\n"
318 " max_value=\"128.0\"\n"
319 "\t >\n"
320 " The shininess value to use when lighting the object. Higher values equal smaller and brighter highlights.\n"
321 " </Field>\n"
322 " <Field\n"
323 "\t name=\"emission\"\n"
324 "\t type=\"Color3f\"\n"
325 "\t cardinality=\"single\"\n"
326 "\t visibility=\"external\"\n"
327 "\t defaultValue=\"0.f,0.f,0.f\"\n"
328 "\t >\n"
329 " </Field>\n"
330 " <Field\n"
331 "\t name=\"transparency\"\n"
332 "\t type=\"Real32\"\n"
333 "\t cardinality=\"single\"\n"
334 "\t visibility=\"external\"\n"
335 "\t defaultValue=\"0.f\"\n"
336 " min_value=\"0.0\"\n"
337 " max_value=\"1.0\"\n"
338 "\t >\n"
339 " Defines how transparent objects are rendered with this material.\n"
340 " </Field>\n"
341 " <Field\n"
342 "\t name=\"lit\"\n"
343 "\t type=\"bool\"\n"
344 "\t cardinality=\"single\"\n"
345 "\t visibility=\"external\"\n"
346 "\t defaultValue=\"true\"\n"
347 "\t >\n"
348 " </Field>\n"
349 " <Field\n"
350 "\t name=\"colorMaterial\"\n"
351 "\t type=\"GLenum\"\n"
352 "\t cardinality=\"single\"\n"
353 "\t visibility=\"external\"\n"
354 "\t defaultValue=\"GL_DIFFUSE\"\n"
355 "\t defaultHeader=\"&quot;OSGGL.h&quot;\"\n"
356 " potential_values=\"GL_AMBIENT,GL_DIFFUSE,GL_SPECULAR,GL_AMBIENT_AND_DIFFUSE,GL_EMISSION\"\n"
357 "\t >\n"
358 " Defines which color material mode this material affects.\n"
359 " </Field>\n"
360 "</FieldContainer>\n"
361 "\n"
362 "\n",
363 "The simple material class. See \\ref PageSystemMaterialSimpleMaterial for a\n"
364 "description.\n"
365 "\n"
366 "This material wraps the standard calls to glMaterial() in\n"
367 "OSG::SimpleMaterial::_sfAmbient, OSG::SimpleMaterial::_sfDiffuse, \n"
368 "OSG::SimpleMaterial::_sfEmission, OSG::SimpleMaterial::_sfSpecular, \n"
369 "OSG::SimpleMaterial::_sfShininess. In addition it supports transparency \n"
370 "(OSG::SimpleMaterial::_sfTransparency), can switch lighting \n"
371 "(OSG::SimpleMaterial::_sfLit) and the color material \n"
372 "(OSG::SimpleMaterial::_sfColorMaterial).\n"
375 /*------------------------------ get -----------------------------------*/
377 FieldContainerType &SimpleMaterialBase::getType(void)
379 return _type;
382 const FieldContainerType &SimpleMaterialBase::getType(void) const
384 return _type;
387 UInt32 SimpleMaterialBase::getContainerSize(void) const
389 return sizeof(SimpleMaterial);
392 /*------------------------- decorator get ------------------------------*/
395 SFColor3f *SimpleMaterialBase::editSFAmbient(void)
397 editSField(AmbientFieldMask);
399 return &_sfAmbient;
402 const SFColor3f *SimpleMaterialBase::getSFAmbient(void) const
404 return &_sfAmbient;
408 SFColor3f *SimpleMaterialBase::editSFDiffuse(void)
410 editSField(DiffuseFieldMask);
412 return &_sfDiffuse;
415 const SFColor3f *SimpleMaterialBase::getSFDiffuse(void) const
417 return &_sfDiffuse;
421 SFColor3f *SimpleMaterialBase::editSFSpecular(void)
423 editSField(SpecularFieldMask);
425 return &_sfSpecular;
428 const SFColor3f *SimpleMaterialBase::getSFSpecular(void) const
430 return &_sfSpecular;
434 SFReal32 *SimpleMaterialBase::editSFShininess(void)
436 editSField(ShininessFieldMask);
438 return &_sfShininess;
441 const SFReal32 *SimpleMaterialBase::getSFShininess(void) const
443 return &_sfShininess;
447 SFColor3f *SimpleMaterialBase::editSFEmission(void)
449 editSField(EmissionFieldMask);
451 return &_sfEmission;
454 const SFColor3f *SimpleMaterialBase::getSFEmission(void) const
456 return &_sfEmission;
460 SFReal32 *SimpleMaterialBase::editSFTransparency(void)
462 editSField(TransparencyFieldMask);
464 return &_sfTransparency;
467 const SFReal32 *SimpleMaterialBase::getSFTransparency(void) const
469 return &_sfTransparency;
473 SFBool *SimpleMaterialBase::editSFLit(void)
475 editSField(LitFieldMask);
477 return &_sfLit;
480 const SFBool *SimpleMaterialBase::getSFLit(void) const
482 return &_sfLit;
486 SFGLenum *SimpleMaterialBase::editSFColorMaterial(void)
488 editSField(ColorMaterialFieldMask);
490 return &_sfColorMaterial;
493 const SFGLenum *SimpleMaterialBase::getSFColorMaterial(void) const
495 return &_sfColorMaterial;
503 /*------------------------------ access -----------------------------------*/
505 SizeT SimpleMaterialBase::getBinSize(ConstFieldMaskArg whichField)
507 SizeT returnValue = Inherited::getBinSize(whichField);
509 if(FieldBits::NoField != (AmbientFieldMask & whichField))
511 returnValue += _sfAmbient.getBinSize();
513 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
515 returnValue += _sfDiffuse.getBinSize();
517 if(FieldBits::NoField != (SpecularFieldMask & whichField))
519 returnValue += _sfSpecular.getBinSize();
521 if(FieldBits::NoField != (ShininessFieldMask & whichField))
523 returnValue += _sfShininess.getBinSize();
525 if(FieldBits::NoField != (EmissionFieldMask & whichField))
527 returnValue += _sfEmission.getBinSize();
529 if(FieldBits::NoField != (TransparencyFieldMask & whichField))
531 returnValue += _sfTransparency.getBinSize();
533 if(FieldBits::NoField != (LitFieldMask & whichField))
535 returnValue += _sfLit.getBinSize();
537 if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
539 returnValue += _sfColorMaterial.getBinSize();
542 return returnValue;
545 void SimpleMaterialBase::copyToBin(BinaryDataHandler &pMem,
546 ConstFieldMaskArg whichField)
548 Inherited::copyToBin(pMem, whichField);
550 if(FieldBits::NoField != (AmbientFieldMask & whichField))
552 _sfAmbient.copyToBin(pMem);
554 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
556 _sfDiffuse.copyToBin(pMem);
558 if(FieldBits::NoField != (SpecularFieldMask & whichField))
560 _sfSpecular.copyToBin(pMem);
562 if(FieldBits::NoField != (ShininessFieldMask & whichField))
564 _sfShininess.copyToBin(pMem);
566 if(FieldBits::NoField != (EmissionFieldMask & whichField))
568 _sfEmission.copyToBin(pMem);
570 if(FieldBits::NoField != (TransparencyFieldMask & whichField))
572 _sfTransparency.copyToBin(pMem);
574 if(FieldBits::NoField != (LitFieldMask & whichField))
576 _sfLit.copyToBin(pMem);
578 if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
580 _sfColorMaterial.copyToBin(pMem);
584 void SimpleMaterialBase::copyFromBin(BinaryDataHandler &pMem,
585 ConstFieldMaskArg whichField)
587 Inherited::copyFromBin(pMem, whichField);
589 if(FieldBits::NoField != (AmbientFieldMask & whichField))
591 editSField(AmbientFieldMask);
592 _sfAmbient.copyFromBin(pMem);
594 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
596 editSField(DiffuseFieldMask);
597 _sfDiffuse.copyFromBin(pMem);
599 if(FieldBits::NoField != (SpecularFieldMask & whichField))
601 editSField(SpecularFieldMask);
602 _sfSpecular.copyFromBin(pMem);
604 if(FieldBits::NoField != (ShininessFieldMask & whichField))
606 editSField(ShininessFieldMask);
607 _sfShininess.copyFromBin(pMem);
609 if(FieldBits::NoField != (EmissionFieldMask & whichField))
611 editSField(EmissionFieldMask);
612 _sfEmission.copyFromBin(pMem);
614 if(FieldBits::NoField != (TransparencyFieldMask & whichField))
616 editSField(TransparencyFieldMask);
617 _sfTransparency.copyFromBin(pMem);
619 if(FieldBits::NoField != (LitFieldMask & whichField))
621 editSField(LitFieldMask);
622 _sfLit.copyFromBin(pMem);
624 if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
626 editSField(ColorMaterialFieldMask);
627 _sfColorMaterial.copyFromBin(pMem);
631 //! create a new instance of the class
632 SimpleMaterialTransitPtr SimpleMaterialBase::createLocal(BitVector bFlags)
634 SimpleMaterialTransitPtr fc;
636 if(getClassType().getPrototype() != NULL)
638 FieldContainerTransitPtr tmpPtr =
639 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
641 fc = dynamic_pointer_cast<SimpleMaterial>(tmpPtr);
644 return fc;
647 //! create a new instance of the class, copy the container flags
648 SimpleMaterialTransitPtr SimpleMaterialBase::createDependent(BitVector bFlags)
650 SimpleMaterialTransitPtr fc;
652 if(getClassType().getPrototype() != NULL)
654 FieldContainerTransitPtr tmpPtr =
655 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
657 fc = dynamic_pointer_cast<SimpleMaterial>(tmpPtr);
660 return fc;
663 //! create a new instance of the class
664 SimpleMaterialTransitPtr SimpleMaterialBase::create(void)
666 SimpleMaterialTransitPtr fc;
668 if(getClassType().getPrototype() != NULL)
670 FieldContainerTransitPtr tmpPtr =
671 getClassType().getPrototype()-> shallowCopy();
673 fc = dynamic_pointer_cast<SimpleMaterial>(tmpPtr);
676 return fc;
679 SimpleMaterial *SimpleMaterialBase::createEmptyLocal(BitVector bFlags)
681 SimpleMaterial *returnValue;
683 newPtr<SimpleMaterial>(returnValue, bFlags);
685 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
687 return returnValue;
690 //! create an empty new instance of the class, do not copy the prototype
691 SimpleMaterial *SimpleMaterialBase::createEmpty(void)
693 SimpleMaterial *returnValue;
695 newPtr<SimpleMaterial>(returnValue, Thread::getCurrentLocalFlags());
697 returnValue->_pFieldFlags->_bNamespaceMask &=
698 ~Thread::getCurrentLocalFlags();
700 return returnValue;
704 FieldContainerTransitPtr SimpleMaterialBase::shallowCopyLocal(
705 BitVector bFlags) const
707 SimpleMaterial *tmpPtr;
709 newPtr(tmpPtr, dynamic_cast<const SimpleMaterial *>(this), bFlags);
711 FieldContainerTransitPtr returnValue(tmpPtr);
713 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
715 return returnValue;
718 FieldContainerTransitPtr SimpleMaterialBase::shallowCopyDependent(
719 BitVector bFlags) const
721 SimpleMaterial *tmpPtr;
723 newPtr(tmpPtr, dynamic_cast<const SimpleMaterial *>(this), ~bFlags);
725 FieldContainerTransitPtr returnValue(tmpPtr);
727 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
729 return returnValue;
732 FieldContainerTransitPtr SimpleMaterialBase::shallowCopy(void) const
734 SimpleMaterial *tmpPtr;
736 newPtr(tmpPtr,
737 dynamic_cast<const SimpleMaterial *>(this),
738 Thread::getCurrentLocalFlags());
740 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
742 FieldContainerTransitPtr returnValue(tmpPtr);
744 return returnValue;
750 /*------------------------- constructors ----------------------------------*/
752 SimpleMaterialBase::SimpleMaterialBase(void) :
753 Inherited(),
754 _sfAmbient (Color3f(0.f,0.f,0.f)),
755 _sfDiffuse (Color3f(0.f,0.f,0.f)),
756 _sfSpecular (Color3f(0.f,0.f,0.f)),
757 _sfShininess (Real32(1.f)),
758 _sfEmission (Color3f(0.f,0.f,0.f)),
759 _sfTransparency (Real32(0.f)),
760 _sfLit (bool(true)),
761 _sfColorMaterial (GLenum(GL_DIFFUSE))
765 SimpleMaterialBase::SimpleMaterialBase(const SimpleMaterialBase &source) :
766 Inherited(source),
767 _sfAmbient (source._sfAmbient ),
768 _sfDiffuse (source._sfDiffuse ),
769 _sfSpecular (source._sfSpecular ),
770 _sfShininess (source._sfShininess ),
771 _sfEmission (source._sfEmission ),
772 _sfTransparency (source._sfTransparency ),
773 _sfLit (source._sfLit ),
774 _sfColorMaterial (source._sfColorMaterial )
779 /*-------------------------- destructors ----------------------------------*/
781 SimpleMaterialBase::~SimpleMaterialBase(void)
786 GetFieldHandlePtr SimpleMaterialBase::getHandleAmbient (void) const
788 SFColor3f::GetHandlePtr returnValue(
789 new SFColor3f::GetHandle(
790 &_sfAmbient,
791 this->getType().getFieldDesc(AmbientFieldId),
792 const_cast<SimpleMaterialBase *>(this)));
794 return returnValue;
797 EditFieldHandlePtr SimpleMaterialBase::editHandleAmbient (void)
799 SFColor3f::EditHandlePtr returnValue(
800 new SFColor3f::EditHandle(
801 &_sfAmbient,
802 this->getType().getFieldDesc(AmbientFieldId),
803 this));
806 editSField(AmbientFieldMask);
808 return returnValue;
811 GetFieldHandlePtr SimpleMaterialBase::getHandleDiffuse (void) const
813 SFColor3f::GetHandlePtr returnValue(
814 new SFColor3f::GetHandle(
815 &_sfDiffuse,
816 this->getType().getFieldDesc(DiffuseFieldId),
817 const_cast<SimpleMaterialBase *>(this)));
819 return returnValue;
822 EditFieldHandlePtr SimpleMaterialBase::editHandleDiffuse (void)
824 SFColor3f::EditHandlePtr returnValue(
825 new SFColor3f::EditHandle(
826 &_sfDiffuse,
827 this->getType().getFieldDesc(DiffuseFieldId),
828 this));
831 editSField(DiffuseFieldMask);
833 return returnValue;
836 GetFieldHandlePtr SimpleMaterialBase::getHandleSpecular (void) const
838 SFColor3f::GetHandlePtr returnValue(
839 new SFColor3f::GetHandle(
840 &_sfSpecular,
841 this->getType().getFieldDesc(SpecularFieldId),
842 const_cast<SimpleMaterialBase *>(this)));
844 return returnValue;
847 EditFieldHandlePtr SimpleMaterialBase::editHandleSpecular (void)
849 SFColor3f::EditHandlePtr returnValue(
850 new SFColor3f::EditHandle(
851 &_sfSpecular,
852 this->getType().getFieldDesc(SpecularFieldId),
853 this));
856 editSField(SpecularFieldMask);
858 return returnValue;
861 GetFieldHandlePtr SimpleMaterialBase::getHandleShininess (void) const
863 SFReal32::GetHandlePtr returnValue(
864 new SFReal32::GetHandle(
865 &_sfShininess,
866 this->getType().getFieldDesc(ShininessFieldId),
867 const_cast<SimpleMaterialBase *>(this)));
869 return returnValue;
872 EditFieldHandlePtr SimpleMaterialBase::editHandleShininess (void)
874 SFReal32::EditHandlePtr returnValue(
875 new SFReal32::EditHandle(
876 &_sfShininess,
877 this->getType().getFieldDesc(ShininessFieldId),
878 this));
881 editSField(ShininessFieldMask);
883 return returnValue;
886 GetFieldHandlePtr SimpleMaterialBase::getHandleEmission (void) const
888 SFColor3f::GetHandlePtr returnValue(
889 new SFColor3f::GetHandle(
890 &_sfEmission,
891 this->getType().getFieldDesc(EmissionFieldId),
892 const_cast<SimpleMaterialBase *>(this)));
894 return returnValue;
897 EditFieldHandlePtr SimpleMaterialBase::editHandleEmission (void)
899 SFColor3f::EditHandlePtr returnValue(
900 new SFColor3f::EditHandle(
901 &_sfEmission,
902 this->getType().getFieldDesc(EmissionFieldId),
903 this));
906 editSField(EmissionFieldMask);
908 return returnValue;
911 GetFieldHandlePtr SimpleMaterialBase::getHandleTransparency (void) const
913 SFReal32::GetHandlePtr returnValue(
914 new SFReal32::GetHandle(
915 &_sfTransparency,
916 this->getType().getFieldDesc(TransparencyFieldId),
917 const_cast<SimpleMaterialBase *>(this)));
919 return returnValue;
922 EditFieldHandlePtr SimpleMaterialBase::editHandleTransparency (void)
924 SFReal32::EditHandlePtr returnValue(
925 new SFReal32::EditHandle(
926 &_sfTransparency,
927 this->getType().getFieldDesc(TransparencyFieldId),
928 this));
931 editSField(TransparencyFieldMask);
933 return returnValue;
936 GetFieldHandlePtr SimpleMaterialBase::getHandleLit (void) const
938 SFBool::GetHandlePtr returnValue(
939 new SFBool::GetHandle(
940 &_sfLit,
941 this->getType().getFieldDesc(LitFieldId),
942 const_cast<SimpleMaterialBase *>(this)));
944 return returnValue;
947 EditFieldHandlePtr SimpleMaterialBase::editHandleLit (void)
949 SFBool::EditHandlePtr returnValue(
950 new SFBool::EditHandle(
951 &_sfLit,
952 this->getType().getFieldDesc(LitFieldId),
953 this));
956 editSField(LitFieldMask);
958 return returnValue;
961 GetFieldHandlePtr SimpleMaterialBase::getHandleColorMaterial (void) const
963 SFGLenum::GetHandlePtr returnValue(
964 new SFGLenum::GetHandle(
965 &_sfColorMaterial,
966 this->getType().getFieldDesc(ColorMaterialFieldId),
967 const_cast<SimpleMaterialBase *>(this)));
969 return returnValue;
972 EditFieldHandlePtr SimpleMaterialBase::editHandleColorMaterial (void)
974 SFGLenum::EditHandlePtr returnValue(
975 new SFGLenum::EditHandle(
976 &_sfColorMaterial,
977 this->getType().getFieldDesc(ColorMaterialFieldId),
978 this));
981 editSField(ColorMaterialFieldMask);
983 return returnValue;
987 #ifdef OSG_MT_CPTR_ASPECT
988 void SimpleMaterialBase::execSyncV( FieldContainer &oFrom,
989 ConstFieldMaskArg whichField,
990 AspectOffsetStore &oOffsets,
991 ConstFieldMaskArg syncMode,
992 const UInt32 uiSyncInfo)
994 SimpleMaterial *pThis = static_cast<SimpleMaterial *>(this);
996 pThis->execSync(static_cast<SimpleMaterial *>(&oFrom),
997 whichField,
998 oOffsets,
999 syncMode,
1000 uiSyncInfo);
1002 #endif
1005 #ifdef OSG_MT_CPTR_ASPECT
1006 FieldContainer *SimpleMaterialBase::createAspectCopy(
1007 const FieldContainer *pRefAspect) const
1009 SimpleMaterial *returnValue;
1011 newAspectCopy(returnValue,
1012 dynamic_cast<const SimpleMaterial *>(pRefAspect),
1013 dynamic_cast<const SimpleMaterial *>(this));
1015 return returnValue;
1017 #endif
1019 void SimpleMaterialBase::resolveLinks(void)
1021 Inherited::resolveLinks();
1027 OSG_END_NAMESPACE