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 **
48 ** class MaterialChunk!
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"
64 #include "OSGGL.h" // ColorMaterial default header
65 #include "OSGGL.h" // BackColorMaterial default header
68 #include "OSGMaterialChunkBase.h"
69 #include "OSGMaterialChunk.h"
71 #include <boost/bind.hpp>
75 /***************************************************************************\
77 \***************************************************************************/
79 /*! \class OSG::MaterialChunk
80 See \ref PageSystemMaterialChunk for details.
82 This chunk wraps glMaterial() (OSG::MaterialChunk::_sfDiffuse,
83 OSG::MaterialChunk::_sfSpecular, OSG::MaterialChunk::_sfEmission,
84 OSG::MaterialChunk::_sfShininess, OSG::MaterialChunk::_sfAmbient),
85 glEnable(GL_LIGHTING)(OSG::MaterialChunk::_sfLit) and glColorMaterial()
86 (OSG::MaterialChunk::_sfColorMaterial).
89 /***************************************************************************\
90 * Field Documentation *
91 \***************************************************************************/
93 /*! \var Color4f MaterialChunkBase::_sfDiffuse
97 /*! \var Color4f MaterialChunkBase::_sfAmbient
101 /*! \var Color4f MaterialChunkBase::_sfSpecular
105 /*! \var Color4f MaterialChunkBase::_sfEmission
109 /*! \var Real32 MaterialChunkBase::_sfShininess
113 /*! \var bool MaterialChunkBase::_sfLit
114 Switch for using this material in lighting calculation.
115 If not set the diffuse color is used as is.
118 /*! \var GLenum MaterialChunkBase::_sfColorMaterial
119 The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.
122 /*! \var bool MaterialChunkBase::_sfBackMaterial
123 Switch for using separate material properties for front- and back-facing
124 polygons. If set to false the standard parameters will be used for front- and
128 /*! \var Color4f MaterialChunkBase::_sfBackDiffuse
132 /*! \var Color4f MaterialChunkBase::_sfBackAmbient
136 /*! \var Color4f MaterialChunkBase::_sfBackSpecular
140 /*! \var Color4f MaterialChunkBase::_sfBackEmission
144 /*! \var Real32 MaterialChunkBase::_sfBackShininess
148 /*! \var GLenum MaterialChunkBase::_sfBackColorMaterial
149 The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.
153 /***************************************************************************\
154 * FieldType/FieldTrait Instantiation *
155 \***************************************************************************/
157 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
158 PointerType FieldTraits
<MaterialChunk
*, nsOSG
>::_type(
161 MaterialChunk::getClassType(),
165 OSG_FIELDTRAITS_GETTYPE_NS(MaterialChunk
*, nsOSG
)
167 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
171 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
175 /***************************************************************************\
176 * Field Description *
177 \***************************************************************************/
179 void MaterialChunkBase::classDescInserter(TypeObject
&oType
)
181 FieldDescriptionBase
*pDesc
= NULL
;
184 pDesc
= new SFColor4f::Description(
185 SFColor4f::getClassType(),
188 DiffuseFieldId
, DiffuseFieldMask
,
190 (Field::SFDefaultFlags
| Field::FStdAccess
),
191 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleDiffuse
),
192 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleDiffuse
));
194 oType
.addInitialDesc(pDesc
);
196 pDesc
= new SFColor4f::Description(
197 SFColor4f::getClassType(),
200 AmbientFieldId
, AmbientFieldMask
,
202 (Field::SFDefaultFlags
| Field::FStdAccess
),
203 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleAmbient
),
204 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleAmbient
));
206 oType
.addInitialDesc(pDesc
);
208 pDesc
= new SFColor4f::Description(
209 SFColor4f::getClassType(),
212 SpecularFieldId
, SpecularFieldMask
,
214 (Field::SFDefaultFlags
| Field::FStdAccess
),
215 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleSpecular
),
216 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleSpecular
));
218 oType
.addInitialDesc(pDesc
);
220 pDesc
= new SFColor4f::Description(
221 SFColor4f::getClassType(),
224 EmissionFieldId
, EmissionFieldMask
,
226 (Field::SFDefaultFlags
| Field::FStdAccess
),
227 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleEmission
),
228 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleEmission
));
230 oType
.addInitialDesc(pDesc
);
232 pDesc
= new SFReal32::Description(
233 SFReal32::getClassType(),
236 ShininessFieldId
, ShininessFieldMask
,
238 (Field::SFDefaultFlags
| Field::FStdAccess
),
239 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleShininess
),
240 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleShininess
));
242 oType
.addInitialDesc(pDesc
);
244 pDesc
= new SFBool::Description(
245 SFBool::getClassType(),
247 "Switch for using this material in lighting calculation. \n"
248 "If not set the diffuse color is used as is.\n",
249 LitFieldId
, LitFieldMask
,
251 (Field::SFDefaultFlags
| Field::FStdAccess
),
252 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleLit
),
253 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleLit
));
255 oType
.addInitialDesc(pDesc
);
257 pDesc
= new SFGLenum::Description(
258 SFGLenum::getClassType(),
260 "The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.\n",
261 ColorMaterialFieldId
, ColorMaterialFieldMask
,
263 (Field::SFDefaultFlags
| Field::FStdAccess
),
264 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleColorMaterial
),
265 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleColorMaterial
));
267 oType
.addInitialDesc(pDesc
);
269 pDesc
= new SFBool::Description(
270 SFBool::getClassType(),
272 "Switch for using separate material properties for front- and back-facing\n"
273 "polygons. If set to false the standard parameters will be used for front- and \n"
275 BackMaterialFieldId
, BackMaterialFieldMask
,
277 (Field::SFDefaultFlags
| Field::FStdAccess
),
278 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleBackMaterial
),
279 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleBackMaterial
));
281 oType
.addInitialDesc(pDesc
);
283 pDesc
= new SFColor4f::Description(
284 SFColor4f::getClassType(),
287 BackDiffuseFieldId
, BackDiffuseFieldMask
,
289 (Field::SFDefaultFlags
| Field::FStdAccess
),
290 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleBackDiffuse
),
291 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleBackDiffuse
));
293 oType
.addInitialDesc(pDesc
);
295 pDesc
= new SFColor4f::Description(
296 SFColor4f::getClassType(),
299 BackAmbientFieldId
, BackAmbientFieldMask
,
301 (Field::SFDefaultFlags
| Field::FStdAccess
),
302 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleBackAmbient
),
303 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleBackAmbient
));
305 oType
.addInitialDesc(pDesc
);
307 pDesc
= new SFColor4f::Description(
308 SFColor4f::getClassType(),
311 BackSpecularFieldId
, BackSpecularFieldMask
,
313 (Field::SFDefaultFlags
| Field::FStdAccess
),
314 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleBackSpecular
),
315 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleBackSpecular
));
317 oType
.addInitialDesc(pDesc
);
319 pDesc
= new SFColor4f::Description(
320 SFColor4f::getClassType(),
323 BackEmissionFieldId
, BackEmissionFieldMask
,
325 (Field::SFDefaultFlags
| Field::FStdAccess
),
326 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleBackEmission
),
327 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleBackEmission
));
329 oType
.addInitialDesc(pDesc
);
331 pDesc
= new SFReal32::Description(
332 SFReal32::getClassType(),
335 BackShininessFieldId
, BackShininessFieldMask
,
337 (Field::SFDefaultFlags
| Field::FStdAccess
),
338 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleBackShininess
),
339 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleBackShininess
));
341 oType
.addInitialDesc(pDesc
);
343 pDesc
= new SFGLenum::Description(
344 SFGLenum::getClassType(),
346 "The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.\n",
347 BackColorMaterialFieldId
, BackColorMaterialFieldMask
,
349 (Field::SFDefaultFlags
| Field::FStdAccess
),
350 static_cast<FieldEditMethodSig
>(&MaterialChunk::editHandleBackColorMaterial
),
351 static_cast<FieldGetMethodSig
>(&MaterialChunk::getHandleBackColorMaterial
));
353 oType
.addInitialDesc(pDesc
);
357 MaterialChunkBase::TypeObject
MaterialChunkBase::_type(
358 MaterialChunkBase::getClassname(),
359 Inherited::getClassname(),
362 reinterpret_cast<PrototypeCreateF
>(&MaterialChunkBase::createEmptyLocal
),
363 reinterpret_cast<InitContainerF
>(&MaterialChunk::initMethod
),
364 reinterpret_cast<ExitContainerF
>(&MaterialChunk::exitMethod
),
365 reinterpret_cast<InitalInsertDescFunc
>(
366 reinterpret_cast<void *>(&MaterialChunk::classDescInserter
)),
369 "<?xml version=\"1.0\" ?>\n"
372 " name=\"MaterialChunk\"\n"
373 " parent=\"StateChunk\"\n"
374 " library=\"System\"\n"
375 " structure=\"concrete\"\n"
376 " pointerfieldtypes=\"both\"\n"
377 " systemcomponent=\"true\"\n"
378 " parentsystemcomponent=\"true\"\n"
379 " docGroupBase=\"GrpSystemState\"\n"
381 "See \\ref PageSystemMaterialChunk for details.\n"
383 "This chunk wraps glMaterial() (OSG::MaterialChunk::_sfDiffuse,\n"
384 "OSG::MaterialChunk::_sfSpecular, OSG::MaterialChunk::_sfEmission,\n"
385 "OSG::MaterialChunk::_sfShininess, OSG::MaterialChunk::_sfAmbient),\n"
386 "glEnable(GL_LIGHTING)(OSG::MaterialChunk::_sfLit) and glColorMaterial()\n"
387 "(OSG::MaterialChunk::_sfColorMaterial).\n"
389 "\t\tname=\"diffuse\"\n"
390 "\t\ttype=\"Color4f\"\n"
391 "\t\tcardinality=\"single\"\n"
392 "\t\tvisibility=\"external\"\n"
393 "\t\tdefaultValue=\"1.f,1.f,1.f,1.f\"\n"
397 "\t\tname=\"ambient\"\n"
398 "\t\ttype=\"Color4f\"\n"
399 "\t\tcardinality=\"single\"\n"
400 "\t\tvisibility=\"external\"\n"
401 "\t\tdefaultValue=\".2f,.2f,.2f,1.f\"\n"
405 "\t\tname=\"specular\"\n"
406 "\t\ttype=\"Color4f\"\n"
407 "\t\tcardinality=\"single\"\n"
408 "\t\tvisibility=\"external\"\n"
409 "\t\tdefaultValue=\".5f,.5f,.5f,1.f\"\n"
413 "\t\tname=\"emission\"\n"
414 "\t\ttype=\"Color4f\"\n"
415 "\t\tcardinality=\"single\"\n"
416 "\t\tvisibility=\"external\"\n"
417 "\t\tdefaultValue=\"0.f,0.f,0.f,1.f\"\n"
421 "\t\tname=\"shininess\"\n"
422 "\t\ttype=\"Real32\"\n"
423 "\t\tcardinality=\"single\"\n"
424 "\t\tvisibility=\"external\"\n"
425 "\t\tdefaultValue=\"10.f\"\n"
430 "\t\ttype=\"bool\"\n"
431 "\t\tcardinality=\"single\"\n"
432 "\t\tvisibility=\"external\"\n"
433 "\t\tdefaultValue=\"true\"\n"
435 " Switch for using this material in lighting calculation. \n"
436 " If not set the diffuse color is used as is.\n"
439 "\t\tname=\"colorMaterial\"\n"
440 "\t\ttype=\"GLenum\"\n"
441 "\t\tcardinality=\"single\"\n"
442 "\t\tvisibility=\"external\"\n"
443 "\t\tdefaultValue=\"GL_DIFFUSE\"\n"
444 "\t\tdefaultHeader=\""OSGGL.h"\"\n"
446 " The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.\n"
449 "\t\tname=\"backMaterial\"\n"
450 "\t\ttype=\"bool\"\n"
451 "\t\tcardinality=\"single\"\n"
452 "\t\tvisibility=\"external\"\n"
453 "\t\tdefaultValue=\"false\"\n"
455 " Switch for using separate material properties for front- and back-facing\n"
456 " polygons. If set to false the standard parameters will be used for front- and \n"
460 "\t\tname=\"backDiffuse\"\n"
461 "\t\ttype=\"Color4f\"\n"
462 "\t\tcardinality=\"single\"\n"
463 "\t\tvisibility=\"external\"\n"
464 "\t\tdefaultValue=\"1.f,1.f,1.f,0.f\"\n"
468 "\t\tname=\"backAmbient\"\n"
469 "\t\ttype=\"Color4f\"\n"
470 "\t\tcardinality=\"single\"\n"
471 "\t\tvisibility=\"external\"\n"
472 "\t\tdefaultValue=\".2f,.2f,.2f,0.f\"\n"
476 "\t\tname=\"backSpecular\"\n"
477 "\t\ttype=\"Color4f\"\n"
478 "\t\tcardinality=\"single\"\n"
479 "\t\tvisibility=\"external\"\n"
480 "\t\tdefaultValue=\".5f,.5f,.5f,0.f\"\n"
484 "\t\tname=\"backEmission\"\n"
485 "\t\ttype=\"Color4f\"\n"
486 "\t\tcardinality=\"single\"\n"
487 "\t\tvisibility=\"external\"\n"
488 "\t\tdefaultValue=\"0.f,0.f,0.f,0.f\"\n"
492 "\t\tname=\"backShininess\"\n"
493 "\t\ttype=\"Real32\"\n"
494 "\t\tcardinality=\"single\"\n"
495 "\t\tvisibility=\"external\"\n"
496 "\t\tdefaultValue=\"10.f\"\n"
500 "\t\tname=\"backColorMaterial\"\n"
501 "\t\ttype=\"GLenum\"\n"
502 "\t\tcardinality=\"single\"\n"
503 "\t\tvisibility=\"external\"\n"
504 "\t\tdefaultValue=\"GL_DIFFUSE\"\n"
505 "\t\tdefaultHeader=\""OSGGL.h"\"\n"
507 " The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.\n"
509 "</FieldContainer>\n",
510 "See \\ref PageSystemMaterialChunk for details.\n"
512 "This chunk wraps glMaterial() (OSG::MaterialChunk::_sfDiffuse,\n"
513 "OSG::MaterialChunk::_sfSpecular, OSG::MaterialChunk::_sfEmission,\n"
514 "OSG::MaterialChunk::_sfShininess, OSG::MaterialChunk::_sfAmbient),\n"
515 "glEnable(GL_LIGHTING)(OSG::MaterialChunk::_sfLit) and glColorMaterial()\n"
516 "(OSG::MaterialChunk::_sfColorMaterial).\n"
519 /*------------------------------ get -----------------------------------*/
521 FieldContainerType
&MaterialChunkBase::getType(void)
526 const FieldContainerType
&MaterialChunkBase::getType(void) const
531 UInt32
MaterialChunkBase::getContainerSize(void) const
533 return sizeof(MaterialChunk
);
536 /*------------------------- decorator get ------------------------------*/
539 SFColor4f
*MaterialChunkBase::editSFDiffuse(void)
541 editSField(DiffuseFieldMask
);
546 const SFColor4f
*MaterialChunkBase::getSFDiffuse(void) const
552 SFColor4f
*MaterialChunkBase::editSFAmbient(void)
554 editSField(AmbientFieldMask
);
559 const SFColor4f
*MaterialChunkBase::getSFAmbient(void) const
565 SFColor4f
*MaterialChunkBase::editSFSpecular(void)
567 editSField(SpecularFieldMask
);
572 const SFColor4f
*MaterialChunkBase::getSFSpecular(void) const
578 SFColor4f
*MaterialChunkBase::editSFEmission(void)
580 editSField(EmissionFieldMask
);
585 const SFColor4f
*MaterialChunkBase::getSFEmission(void) const
591 SFReal32
*MaterialChunkBase::editSFShininess(void)
593 editSField(ShininessFieldMask
);
595 return &_sfShininess
;
598 const SFReal32
*MaterialChunkBase::getSFShininess(void) const
600 return &_sfShininess
;
604 SFBool
*MaterialChunkBase::editSFLit(void)
606 editSField(LitFieldMask
);
611 const SFBool
*MaterialChunkBase::getSFLit(void) const
617 SFGLenum
*MaterialChunkBase::editSFColorMaterial(void)
619 editSField(ColorMaterialFieldMask
);
621 return &_sfColorMaterial
;
624 const SFGLenum
*MaterialChunkBase::getSFColorMaterial(void) const
626 return &_sfColorMaterial
;
630 SFBool
*MaterialChunkBase::editSFBackMaterial(void)
632 editSField(BackMaterialFieldMask
);
634 return &_sfBackMaterial
;
637 const SFBool
*MaterialChunkBase::getSFBackMaterial(void) const
639 return &_sfBackMaterial
;
643 SFColor4f
*MaterialChunkBase::editSFBackDiffuse(void)
645 editSField(BackDiffuseFieldMask
);
647 return &_sfBackDiffuse
;
650 const SFColor4f
*MaterialChunkBase::getSFBackDiffuse(void) const
652 return &_sfBackDiffuse
;
656 SFColor4f
*MaterialChunkBase::editSFBackAmbient(void)
658 editSField(BackAmbientFieldMask
);
660 return &_sfBackAmbient
;
663 const SFColor4f
*MaterialChunkBase::getSFBackAmbient(void) const
665 return &_sfBackAmbient
;
669 SFColor4f
*MaterialChunkBase::editSFBackSpecular(void)
671 editSField(BackSpecularFieldMask
);
673 return &_sfBackSpecular
;
676 const SFColor4f
*MaterialChunkBase::getSFBackSpecular(void) const
678 return &_sfBackSpecular
;
682 SFColor4f
*MaterialChunkBase::editSFBackEmission(void)
684 editSField(BackEmissionFieldMask
);
686 return &_sfBackEmission
;
689 const SFColor4f
*MaterialChunkBase::getSFBackEmission(void) const
691 return &_sfBackEmission
;
695 SFReal32
*MaterialChunkBase::editSFBackShininess(void)
697 editSField(BackShininessFieldMask
);
699 return &_sfBackShininess
;
702 const SFReal32
*MaterialChunkBase::getSFBackShininess(void) const
704 return &_sfBackShininess
;
708 SFGLenum
*MaterialChunkBase::editSFBackColorMaterial(void)
710 editSField(BackColorMaterialFieldMask
);
712 return &_sfBackColorMaterial
;
715 const SFGLenum
*MaterialChunkBase::getSFBackColorMaterial(void) const
717 return &_sfBackColorMaterial
;
725 /*------------------------------ access -----------------------------------*/
727 SizeT
MaterialChunkBase::getBinSize(ConstFieldMaskArg whichField
)
729 SizeT returnValue
= Inherited::getBinSize(whichField
);
731 if(FieldBits::NoField
!= (DiffuseFieldMask
& whichField
))
733 returnValue
+= _sfDiffuse
.getBinSize();
735 if(FieldBits::NoField
!= (AmbientFieldMask
& whichField
))
737 returnValue
+= _sfAmbient
.getBinSize();
739 if(FieldBits::NoField
!= (SpecularFieldMask
& whichField
))
741 returnValue
+= _sfSpecular
.getBinSize();
743 if(FieldBits::NoField
!= (EmissionFieldMask
& whichField
))
745 returnValue
+= _sfEmission
.getBinSize();
747 if(FieldBits::NoField
!= (ShininessFieldMask
& whichField
))
749 returnValue
+= _sfShininess
.getBinSize();
751 if(FieldBits::NoField
!= (LitFieldMask
& whichField
))
753 returnValue
+= _sfLit
.getBinSize();
755 if(FieldBits::NoField
!= (ColorMaterialFieldMask
& whichField
))
757 returnValue
+= _sfColorMaterial
.getBinSize();
759 if(FieldBits::NoField
!= (BackMaterialFieldMask
& whichField
))
761 returnValue
+= _sfBackMaterial
.getBinSize();
763 if(FieldBits::NoField
!= (BackDiffuseFieldMask
& whichField
))
765 returnValue
+= _sfBackDiffuse
.getBinSize();
767 if(FieldBits::NoField
!= (BackAmbientFieldMask
& whichField
))
769 returnValue
+= _sfBackAmbient
.getBinSize();
771 if(FieldBits::NoField
!= (BackSpecularFieldMask
& whichField
))
773 returnValue
+= _sfBackSpecular
.getBinSize();
775 if(FieldBits::NoField
!= (BackEmissionFieldMask
& whichField
))
777 returnValue
+= _sfBackEmission
.getBinSize();
779 if(FieldBits::NoField
!= (BackShininessFieldMask
& whichField
))
781 returnValue
+= _sfBackShininess
.getBinSize();
783 if(FieldBits::NoField
!= (BackColorMaterialFieldMask
& whichField
))
785 returnValue
+= _sfBackColorMaterial
.getBinSize();
791 void MaterialChunkBase::copyToBin(BinaryDataHandler
&pMem
,
792 ConstFieldMaskArg whichField
)
794 Inherited::copyToBin(pMem
, whichField
);
796 if(FieldBits::NoField
!= (DiffuseFieldMask
& whichField
))
798 _sfDiffuse
.copyToBin(pMem
);
800 if(FieldBits::NoField
!= (AmbientFieldMask
& whichField
))
802 _sfAmbient
.copyToBin(pMem
);
804 if(FieldBits::NoField
!= (SpecularFieldMask
& whichField
))
806 _sfSpecular
.copyToBin(pMem
);
808 if(FieldBits::NoField
!= (EmissionFieldMask
& whichField
))
810 _sfEmission
.copyToBin(pMem
);
812 if(FieldBits::NoField
!= (ShininessFieldMask
& whichField
))
814 _sfShininess
.copyToBin(pMem
);
816 if(FieldBits::NoField
!= (LitFieldMask
& whichField
))
818 _sfLit
.copyToBin(pMem
);
820 if(FieldBits::NoField
!= (ColorMaterialFieldMask
& whichField
))
822 _sfColorMaterial
.copyToBin(pMem
);
824 if(FieldBits::NoField
!= (BackMaterialFieldMask
& whichField
))
826 _sfBackMaterial
.copyToBin(pMem
);
828 if(FieldBits::NoField
!= (BackDiffuseFieldMask
& whichField
))
830 _sfBackDiffuse
.copyToBin(pMem
);
832 if(FieldBits::NoField
!= (BackAmbientFieldMask
& whichField
))
834 _sfBackAmbient
.copyToBin(pMem
);
836 if(FieldBits::NoField
!= (BackSpecularFieldMask
& whichField
))
838 _sfBackSpecular
.copyToBin(pMem
);
840 if(FieldBits::NoField
!= (BackEmissionFieldMask
& whichField
))
842 _sfBackEmission
.copyToBin(pMem
);
844 if(FieldBits::NoField
!= (BackShininessFieldMask
& whichField
))
846 _sfBackShininess
.copyToBin(pMem
);
848 if(FieldBits::NoField
!= (BackColorMaterialFieldMask
& whichField
))
850 _sfBackColorMaterial
.copyToBin(pMem
);
854 void MaterialChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
855 ConstFieldMaskArg whichField
)
857 Inherited::copyFromBin(pMem
, whichField
);
859 if(FieldBits::NoField
!= (DiffuseFieldMask
& whichField
))
861 editSField(DiffuseFieldMask
);
862 _sfDiffuse
.copyFromBin(pMem
);
864 if(FieldBits::NoField
!= (AmbientFieldMask
& whichField
))
866 editSField(AmbientFieldMask
);
867 _sfAmbient
.copyFromBin(pMem
);
869 if(FieldBits::NoField
!= (SpecularFieldMask
& whichField
))
871 editSField(SpecularFieldMask
);
872 _sfSpecular
.copyFromBin(pMem
);
874 if(FieldBits::NoField
!= (EmissionFieldMask
& whichField
))
876 editSField(EmissionFieldMask
);
877 _sfEmission
.copyFromBin(pMem
);
879 if(FieldBits::NoField
!= (ShininessFieldMask
& whichField
))
881 editSField(ShininessFieldMask
);
882 _sfShininess
.copyFromBin(pMem
);
884 if(FieldBits::NoField
!= (LitFieldMask
& whichField
))
886 editSField(LitFieldMask
);
887 _sfLit
.copyFromBin(pMem
);
889 if(FieldBits::NoField
!= (ColorMaterialFieldMask
& whichField
))
891 editSField(ColorMaterialFieldMask
);
892 _sfColorMaterial
.copyFromBin(pMem
);
894 if(FieldBits::NoField
!= (BackMaterialFieldMask
& whichField
))
896 editSField(BackMaterialFieldMask
);
897 _sfBackMaterial
.copyFromBin(pMem
);
899 if(FieldBits::NoField
!= (BackDiffuseFieldMask
& whichField
))
901 editSField(BackDiffuseFieldMask
);
902 _sfBackDiffuse
.copyFromBin(pMem
);
904 if(FieldBits::NoField
!= (BackAmbientFieldMask
& whichField
))
906 editSField(BackAmbientFieldMask
);
907 _sfBackAmbient
.copyFromBin(pMem
);
909 if(FieldBits::NoField
!= (BackSpecularFieldMask
& whichField
))
911 editSField(BackSpecularFieldMask
);
912 _sfBackSpecular
.copyFromBin(pMem
);
914 if(FieldBits::NoField
!= (BackEmissionFieldMask
& whichField
))
916 editSField(BackEmissionFieldMask
);
917 _sfBackEmission
.copyFromBin(pMem
);
919 if(FieldBits::NoField
!= (BackShininessFieldMask
& whichField
))
921 editSField(BackShininessFieldMask
);
922 _sfBackShininess
.copyFromBin(pMem
);
924 if(FieldBits::NoField
!= (BackColorMaterialFieldMask
& whichField
))
926 editSField(BackColorMaterialFieldMask
);
927 _sfBackColorMaterial
.copyFromBin(pMem
);
931 //! create a new instance of the class
932 MaterialChunkTransitPtr
MaterialChunkBase::createLocal(BitVector bFlags
)
934 MaterialChunkTransitPtr fc
;
936 if(getClassType().getPrototype() != NULL
)
938 FieldContainerTransitPtr tmpPtr
=
939 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
941 fc
= dynamic_pointer_cast
<MaterialChunk
>(tmpPtr
);
947 //! create a new instance of the class, copy the container flags
948 MaterialChunkTransitPtr
MaterialChunkBase::createDependent(BitVector bFlags
)
950 MaterialChunkTransitPtr fc
;
952 if(getClassType().getPrototype() != NULL
)
954 FieldContainerTransitPtr tmpPtr
=
955 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
957 fc
= dynamic_pointer_cast
<MaterialChunk
>(tmpPtr
);
963 //! create a new instance of the class
964 MaterialChunkTransitPtr
MaterialChunkBase::create(void)
966 MaterialChunkTransitPtr fc
;
968 if(getClassType().getPrototype() != NULL
)
970 FieldContainerTransitPtr tmpPtr
=
971 getClassType().getPrototype()-> shallowCopy();
973 fc
= dynamic_pointer_cast
<MaterialChunk
>(tmpPtr
);
979 MaterialChunk
*MaterialChunkBase::createEmptyLocal(BitVector bFlags
)
981 MaterialChunk
*returnValue
;
983 newPtr
<MaterialChunk
>(returnValue
, bFlags
);
985 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
990 //! create an empty new instance of the class, do not copy the prototype
991 MaterialChunk
*MaterialChunkBase::createEmpty(void)
993 MaterialChunk
*returnValue
;
995 newPtr
<MaterialChunk
>(returnValue
, Thread::getCurrentLocalFlags());
997 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
998 ~Thread::getCurrentLocalFlags();
1004 FieldContainerTransitPtr
MaterialChunkBase::shallowCopyLocal(
1005 BitVector bFlags
) const
1007 MaterialChunk
*tmpPtr
;
1009 newPtr(tmpPtr
, dynamic_cast<const MaterialChunk
*>(this), bFlags
);
1011 FieldContainerTransitPtr
returnValue(tmpPtr
);
1013 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
1018 FieldContainerTransitPtr
MaterialChunkBase::shallowCopyDependent(
1019 BitVector bFlags
) const
1021 MaterialChunk
*tmpPtr
;
1023 newPtr(tmpPtr
, dynamic_cast<const MaterialChunk
*>(this), ~bFlags
);
1025 FieldContainerTransitPtr
returnValue(tmpPtr
);
1027 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
1032 FieldContainerTransitPtr
MaterialChunkBase::shallowCopy(void) const
1034 MaterialChunk
*tmpPtr
;
1037 dynamic_cast<const MaterialChunk
*>(this),
1038 Thread::getCurrentLocalFlags());
1040 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
1042 FieldContainerTransitPtr
returnValue(tmpPtr
);
1050 /*------------------------- constructors ----------------------------------*/
1052 MaterialChunkBase::MaterialChunkBase(void) :
1054 _sfDiffuse (Color4f(1.f
,1.f
,1.f
,1.f
)),
1055 _sfAmbient (Color4f(.2f
,.2f
,.2f
,1.f
)),
1056 _sfSpecular (Color4f(.5f
,.5f
,.5f
,1.f
)),
1057 _sfEmission (Color4f(0.f
,0.f
,0.f
,1.f
)),
1058 _sfShininess (Real32(10.f
)),
1059 _sfLit (bool(true)),
1060 _sfColorMaterial (GLenum(GL_DIFFUSE
)),
1061 _sfBackMaterial (bool(false)),
1062 _sfBackDiffuse (Color4f(1.f
,1.f
,1.f
,0.f
)),
1063 _sfBackAmbient (Color4f(.2f
,.2f
,.2f
,0.f
)),
1064 _sfBackSpecular (Color4f(.5f
,.5f
,.5f
,0.f
)),
1065 _sfBackEmission (Color4f(0.f
,0.f
,0.f
,0.f
)),
1066 _sfBackShininess (Real32(10.f
)),
1067 _sfBackColorMaterial (GLenum(GL_DIFFUSE
))
1071 MaterialChunkBase::MaterialChunkBase(const MaterialChunkBase
&source
) :
1073 _sfDiffuse (source
._sfDiffuse
),
1074 _sfAmbient (source
._sfAmbient
),
1075 _sfSpecular (source
._sfSpecular
),
1076 _sfEmission (source
._sfEmission
),
1077 _sfShininess (source
._sfShininess
),
1078 _sfLit (source
._sfLit
),
1079 _sfColorMaterial (source
._sfColorMaterial
),
1080 _sfBackMaterial (source
._sfBackMaterial
),
1081 _sfBackDiffuse (source
._sfBackDiffuse
),
1082 _sfBackAmbient (source
._sfBackAmbient
),
1083 _sfBackSpecular (source
._sfBackSpecular
),
1084 _sfBackEmission (source
._sfBackEmission
),
1085 _sfBackShininess (source
._sfBackShininess
),
1086 _sfBackColorMaterial (source
._sfBackColorMaterial
)
1091 /*-------------------------- destructors ----------------------------------*/
1093 MaterialChunkBase::~MaterialChunkBase(void)
1098 GetFieldHandlePtr
MaterialChunkBase::getHandleDiffuse (void) const
1100 SFColor4f::GetHandlePtr
returnValue(
1101 new SFColor4f::GetHandle(
1103 this->getType().getFieldDesc(DiffuseFieldId
),
1104 const_cast<MaterialChunkBase
*>(this)));
1109 EditFieldHandlePtr
MaterialChunkBase::editHandleDiffuse (void)
1111 SFColor4f::EditHandlePtr
returnValue(
1112 new SFColor4f::EditHandle(
1114 this->getType().getFieldDesc(DiffuseFieldId
),
1118 editSField(DiffuseFieldMask
);
1123 GetFieldHandlePtr
MaterialChunkBase::getHandleAmbient (void) const
1125 SFColor4f::GetHandlePtr
returnValue(
1126 new SFColor4f::GetHandle(
1128 this->getType().getFieldDesc(AmbientFieldId
),
1129 const_cast<MaterialChunkBase
*>(this)));
1134 EditFieldHandlePtr
MaterialChunkBase::editHandleAmbient (void)
1136 SFColor4f::EditHandlePtr
returnValue(
1137 new SFColor4f::EditHandle(
1139 this->getType().getFieldDesc(AmbientFieldId
),
1143 editSField(AmbientFieldMask
);
1148 GetFieldHandlePtr
MaterialChunkBase::getHandleSpecular (void) const
1150 SFColor4f::GetHandlePtr
returnValue(
1151 new SFColor4f::GetHandle(
1153 this->getType().getFieldDesc(SpecularFieldId
),
1154 const_cast<MaterialChunkBase
*>(this)));
1159 EditFieldHandlePtr
MaterialChunkBase::editHandleSpecular (void)
1161 SFColor4f::EditHandlePtr
returnValue(
1162 new SFColor4f::EditHandle(
1164 this->getType().getFieldDesc(SpecularFieldId
),
1168 editSField(SpecularFieldMask
);
1173 GetFieldHandlePtr
MaterialChunkBase::getHandleEmission (void) const
1175 SFColor4f::GetHandlePtr
returnValue(
1176 new SFColor4f::GetHandle(
1178 this->getType().getFieldDesc(EmissionFieldId
),
1179 const_cast<MaterialChunkBase
*>(this)));
1184 EditFieldHandlePtr
MaterialChunkBase::editHandleEmission (void)
1186 SFColor4f::EditHandlePtr
returnValue(
1187 new SFColor4f::EditHandle(
1189 this->getType().getFieldDesc(EmissionFieldId
),
1193 editSField(EmissionFieldMask
);
1198 GetFieldHandlePtr
MaterialChunkBase::getHandleShininess (void) const
1200 SFReal32::GetHandlePtr
returnValue(
1201 new SFReal32::GetHandle(
1203 this->getType().getFieldDesc(ShininessFieldId
),
1204 const_cast<MaterialChunkBase
*>(this)));
1209 EditFieldHandlePtr
MaterialChunkBase::editHandleShininess (void)
1211 SFReal32::EditHandlePtr
returnValue(
1212 new SFReal32::EditHandle(
1214 this->getType().getFieldDesc(ShininessFieldId
),
1218 editSField(ShininessFieldMask
);
1223 GetFieldHandlePtr
MaterialChunkBase::getHandleLit (void) const
1225 SFBool::GetHandlePtr
returnValue(
1226 new SFBool::GetHandle(
1228 this->getType().getFieldDesc(LitFieldId
),
1229 const_cast<MaterialChunkBase
*>(this)));
1234 EditFieldHandlePtr
MaterialChunkBase::editHandleLit (void)
1236 SFBool::EditHandlePtr
returnValue(
1237 new SFBool::EditHandle(
1239 this->getType().getFieldDesc(LitFieldId
),
1243 editSField(LitFieldMask
);
1248 GetFieldHandlePtr
MaterialChunkBase::getHandleColorMaterial (void) const
1250 SFGLenum::GetHandlePtr
returnValue(
1251 new SFGLenum::GetHandle(
1253 this->getType().getFieldDesc(ColorMaterialFieldId
),
1254 const_cast<MaterialChunkBase
*>(this)));
1259 EditFieldHandlePtr
MaterialChunkBase::editHandleColorMaterial (void)
1261 SFGLenum::EditHandlePtr
returnValue(
1262 new SFGLenum::EditHandle(
1264 this->getType().getFieldDesc(ColorMaterialFieldId
),
1268 editSField(ColorMaterialFieldMask
);
1273 GetFieldHandlePtr
MaterialChunkBase::getHandleBackMaterial (void) const
1275 SFBool::GetHandlePtr
returnValue(
1276 new SFBool::GetHandle(
1278 this->getType().getFieldDesc(BackMaterialFieldId
),
1279 const_cast<MaterialChunkBase
*>(this)));
1284 EditFieldHandlePtr
MaterialChunkBase::editHandleBackMaterial (void)
1286 SFBool::EditHandlePtr
returnValue(
1287 new SFBool::EditHandle(
1289 this->getType().getFieldDesc(BackMaterialFieldId
),
1293 editSField(BackMaterialFieldMask
);
1298 GetFieldHandlePtr
MaterialChunkBase::getHandleBackDiffuse (void) const
1300 SFColor4f::GetHandlePtr
returnValue(
1301 new SFColor4f::GetHandle(
1303 this->getType().getFieldDesc(BackDiffuseFieldId
),
1304 const_cast<MaterialChunkBase
*>(this)));
1309 EditFieldHandlePtr
MaterialChunkBase::editHandleBackDiffuse (void)
1311 SFColor4f::EditHandlePtr
returnValue(
1312 new SFColor4f::EditHandle(
1314 this->getType().getFieldDesc(BackDiffuseFieldId
),
1318 editSField(BackDiffuseFieldMask
);
1323 GetFieldHandlePtr
MaterialChunkBase::getHandleBackAmbient (void) const
1325 SFColor4f::GetHandlePtr
returnValue(
1326 new SFColor4f::GetHandle(
1328 this->getType().getFieldDesc(BackAmbientFieldId
),
1329 const_cast<MaterialChunkBase
*>(this)));
1334 EditFieldHandlePtr
MaterialChunkBase::editHandleBackAmbient (void)
1336 SFColor4f::EditHandlePtr
returnValue(
1337 new SFColor4f::EditHandle(
1339 this->getType().getFieldDesc(BackAmbientFieldId
),
1343 editSField(BackAmbientFieldMask
);
1348 GetFieldHandlePtr
MaterialChunkBase::getHandleBackSpecular (void) const
1350 SFColor4f::GetHandlePtr
returnValue(
1351 new SFColor4f::GetHandle(
1353 this->getType().getFieldDesc(BackSpecularFieldId
),
1354 const_cast<MaterialChunkBase
*>(this)));
1359 EditFieldHandlePtr
MaterialChunkBase::editHandleBackSpecular (void)
1361 SFColor4f::EditHandlePtr
returnValue(
1362 new SFColor4f::EditHandle(
1364 this->getType().getFieldDesc(BackSpecularFieldId
),
1368 editSField(BackSpecularFieldMask
);
1373 GetFieldHandlePtr
MaterialChunkBase::getHandleBackEmission (void) const
1375 SFColor4f::GetHandlePtr
returnValue(
1376 new SFColor4f::GetHandle(
1378 this->getType().getFieldDesc(BackEmissionFieldId
),
1379 const_cast<MaterialChunkBase
*>(this)));
1384 EditFieldHandlePtr
MaterialChunkBase::editHandleBackEmission (void)
1386 SFColor4f::EditHandlePtr
returnValue(
1387 new SFColor4f::EditHandle(
1389 this->getType().getFieldDesc(BackEmissionFieldId
),
1393 editSField(BackEmissionFieldMask
);
1398 GetFieldHandlePtr
MaterialChunkBase::getHandleBackShininess (void) const
1400 SFReal32::GetHandlePtr
returnValue(
1401 new SFReal32::GetHandle(
1403 this->getType().getFieldDesc(BackShininessFieldId
),
1404 const_cast<MaterialChunkBase
*>(this)));
1409 EditFieldHandlePtr
MaterialChunkBase::editHandleBackShininess (void)
1411 SFReal32::EditHandlePtr
returnValue(
1412 new SFReal32::EditHandle(
1414 this->getType().getFieldDesc(BackShininessFieldId
),
1418 editSField(BackShininessFieldMask
);
1423 GetFieldHandlePtr
MaterialChunkBase::getHandleBackColorMaterial (void) const
1425 SFGLenum::GetHandlePtr
returnValue(
1426 new SFGLenum::GetHandle(
1427 &_sfBackColorMaterial
,
1428 this->getType().getFieldDesc(BackColorMaterialFieldId
),
1429 const_cast<MaterialChunkBase
*>(this)));
1434 EditFieldHandlePtr
MaterialChunkBase::editHandleBackColorMaterial(void)
1436 SFGLenum::EditHandlePtr
returnValue(
1437 new SFGLenum::EditHandle(
1438 &_sfBackColorMaterial
,
1439 this->getType().getFieldDesc(BackColorMaterialFieldId
),
1443 editSField(BackColorMaterialFieldMask
);
1449 #ifdef OSG_MT_CPTR_ASPECT
1450 void MaterialChunkBase::execSyncV( FieldContainer
&oFrom
,
1451 ConstFieldMaskArg whichField
,
1452 AspectOffsetStore
&oOffsets
,
1453 ConstFieldMaskArg syncMode
,
1454 const UInt32 uiSyncInfo
)
1456 MaterialChunk
*pThis
= static_cast<MaterialChunk
*>(this);
1458 pThis
->execSync(static_cast<MaterialChunk
*>(&oFrom
),
1467 #ifdef OSG_MT_CPTR_ASPECT
1468 FieldContainer
*MaterialChunkBase::createAspectCopy(
1469 const FieldContainer
*pRefAspect
) const
1471 MaterialChunk
*returnValue
;
1473 newAspectCopy(returnValue
,
1474 dynamic_cast<const MaterialChunk
*>(pRefAspect
),
1475 dynamic_cast<const MaterialChunk
*>(this));
1481 void MaterialChunkBase::resolveLinks(void)
1483 Inherited::resolveLinks();