fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Base / OSGMaterialChunkBase.cpp
blob5a9eb21f199a7435d954b21b0b87cc40b03f758b
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 MaterialChunk!
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
65 #include "OSGGL.h" // BackColorMaterial default header
68 #include "OSGMaterialChunkBase.h"
69 #include "OSGMaterialChunk.h"
71 #include <boost/bind.hpp>
73 OSG_BEGIN_NAMESPACE
75 /***************************************************************************\
76 * Description *
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
125 backfaces.
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(
159 "MaterialChunkPtr",
160 "StateChunkPtr",
161 MaterialChunk::getClassType(),
162 nsOSG);
163 #endif
165 OSG_FIELDTRAITS_GETTYPE_NS(MaterialChunk *, nsOSG)
167 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
168 MaterialChunk *,
169 nsOSG)
171 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
172 MaterialChunk *,
173 nsOSG)
175 /***************************************************************************\
176 * Field Description *
177 \***************************************************************************/
179 void MaterialChunkBase::classDescInserter(TypeObject &oType)
181 FieldDescriptionBase *pDesc = NULL;
184 pDesc = new SFColor4f::Description(
185 SFColor4f::getClassType(),
186 "diffuse",
188 DiffuseFieldId, DiffuseFieldMask,
189 false,
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(),
198 "ambient",
200 AmbientFieldId, AmbientFieldMask,
201 false,
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(),
210 "specular",
212 SpecularFieldId, SpecularFieldMask,
213 false,
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(),
222 "emission",
224 EmissionFieldId, EmissionFieldMask,
225 false,
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(),
234 "shininess",
236 ShininessFieldId, ShininessFieldMask,
237 false,
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(),
246 "lit",
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,
250 false,
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(),
259 "colorMaterial",
260 "The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.\n",
261 ColorMaterialFieldId, ColorMaterialFieldMask,
262 false,
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(),
271 "backMaterial",
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"
274 "backfaces.\n",
275 BackMaterialFieldId, BackMaterialFieldMask,
276 false,
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(),
285 "backDiffuse",
287 BackDiffuseFieldId, BackDiffuseFieldMask,
288 false,
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(),
297 "backAmbient",
299 BackAmbientFieldId, BackAmbientFieldMask,
300 false,
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(),
309 "backSpecular",
311 BackSpecularFieldId, BackSpecularFieldMask,
312 false,
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(),
321 "backEmission",
323 BackEmissionFieldId, BackEmissionFieldMask,
324 false,
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(),
333 "backShininess",
335 BackShininessFieldId, BackShininessFieldMask,
336 false,
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(),
345 "backColorMaterial",
346 "The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.\n",
347 BackColorMaterialFieldId, BackColorMaterialFieldMask,
348 false,
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(),
360 "NULL",
361 nsOSG, //Namespace
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)),
367 false,
369 "<?xml version=\"1.0\" ?>\n"
370 "\n"
371 "<FieldContainer\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"
380 ">\n"
381 "See \\ref PageSystemMaterialChunk for details.\n"
382 "\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"
388 "\t<Field\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"
394 "\t>\n"
395 "\t</Field>\n"
396 "\t<Field\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"
402 "\t>\n"
403 "\t</Field>\n"
404 "\t<Field\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"
410 "\t>\n"
411 "\t</Field>\n"
412 "\t<Field\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"
418 "\t>\n"
419 "\t</Field>\n"
420 "\t<Field\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"
426 "\t>\n"
427 "\t</Field>\n"
428 "\t<Field\n"
429 "\t\tname=\"lit\"\n"
430 "\t\ttype=\"bool\"\n"
431 "\t\tcardinality=\"single\"\n"
432 "\t\tvisibility=\"external\"\n"
433 "\t\tdefaultValue=\"true\"\n"
434 "\t>\n"
435 " Switch for using this material in lighting calculation. \n"
436 " If not set the diffuse color is used as is.\n"
437 "\t</Field>\n"
438 "\t<Field\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=\"&quot;OSGGL.h&quot;\"\n"
445 "\t>\n"
446 " The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.\n"
447 "\t</Field>\n"
448 "\t<Field\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"
454 "\t>\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"
457 " backfaces.\n"
458 "\t</Field>\n"
459 "\t<Field\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"
465 "\t>\n"
466 "\t</Field>\n"
467 "\t<Field\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"
473 "\t>\n"
474 "\t</Field>\n"
475 "\t<Field\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"
481 "\t>\n"
482 "\t</Field>\n"
483 "\t<Field\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"
489 "\t>\n"
490 "\t</Field>\n"
491 "\t<Field\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"
497 "\t>\n"
498 "\t</Field>\n"
499 "\t<Field\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=\"&quot;OSGGL.h&quot;\"\n"
506 "\t>\n"
507 " The mode for using Geometry colors in lighting. Defaults to GL_DIFFUSE.\n"
508 "\t</Field> \n"
509 "</FieldContainer>\n",
510 "See \\ref PageSystemMaterialChunk for details.\n"
511 "\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)
523 return _type;
526 const FieldContainerType &MaterialChunkBase::getType(void) const
528 return _type;
531 UInt32 MaterialChunkBase::getContainerSize(void) const
533 return sizeof(MaterialChunk);
536 /*------------------------- decorator get ------------------------------*/
539 SFColor4f *MaterialChunkBase::editSFDiffuse(void)
541 editSField(DiffuseFieldMask);
543 return &_sfDiffuse;
546 const SFColor4f *MaterialChunkBase::getSFDiffuse(void) const
548 return &_sfDiffuse;
552 SFColor4f *MaterialChunkBase::editSFAmbient(void)
554 editSField(AmbientFieldMask);
556 return &_sfAmbient;
559 const SFColor4f *MaterialChunkBase::getSFAmbient(void) const
561 return &_sfAmbient;
565 SFColor4f *MaterialChunkBase::editSFSpecular(void)
567 editSField(SpecularFieldMask);
569 return &_sfSpecular;
572 const SFColor4f *MaterialChunkBase::getSFSpecular(void) const
574 return &_sfSpecular;
578 SFColor4f *MaterialChunkBase::editSFEmission(void)
580 editSField(EmissionFieldMask);
582 return &_sfEmission;
585 const SFColor4f *MaterialChunkBase::getSFEmission(void) const
587 return &_sfEmission;
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);
608 return &_sfLit;
611 const SFBool *MaterialChunkBase::getSFLit(void) const
613 return &_sfLit;
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();
788 return returnValue;
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);
944 return fc;
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);
960 return fc;
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);
976 return fc;
979 MaterialChunk *MaterialChunkBase::createEmptyLocal(BitVector bFlags)
981 MaterialChunk *returnValue;
983 newPtr<MaterialChunk>(returnValue, bFlags);
985 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
987 return returnValue;
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();
1000 return returnValue;
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;
1015 return returnValue;
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;
1029 return returnValue;
1032 FieldContainerTransitPtr MaterialChunkBase::shallowCopy(void) const
1034 MaterialChunk *tmpPtr;
1036 newPtr(tmpPtr,
1037 dynamic_cast<const MaterialChunk *>(this),
1038 Thread::getCurrentLocalFlags());
1040 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
1042 FieldContainerTransitPtr returnValue(tmpPtr);
1044 return returnValue;
1050 /*------------------------- constructors ----------------------------------*/
1052 MaterialChunkBase::MaterialChunkBase(void) :
1053 Inherited(),
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) :
1072 Inherited(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(
1102 &_sfDiffuse,
1103 this->getType().getFieldDesc(DiffuseFieldId),
1104 const_cast<MaterialChunkBase *>(this)));
1106 return returnValue;
1109 EditFieldHandlePtr MaterialChunkBase::editHandleDiffuse (void)
1111 SFColor4f::EditHandlePtr returnValue(
1112 new SFColor4f::EditHandle(
1113 &_sfDiffuse,
1114 this->getType().getFieldDesc(DiffuseFieldId),
1115 this));
1118 editSField(DiffuseFieldMask);
1120 return returnValue;
1123 GetFieldHandlePtr MaterialChunkBase::getHandleAmbient (void) const
1125 SFColor4f::GetHandlePtr returnValue(
1126 new SFColor4f::GetHandle(
1127 &_sfAmbient,
1128 this->getType().getFieldDesc(AmbientFieldId),
1129 const_cast<MaterialChunkBase *>(this)));
1131 return returnValue;
1134 EditFieldHandlePtr MaterialChunkBase::editHandleAmbient (void)
1136 SFColor4f::EditHandlePtr returnValue(
1137 new SFColor4f::EditHandle(
1138 &_sfAmbient,
1139 this->getType().getFieldDesc(AmbientFieldId),
1140 this));
1143 editSField(AmbientFieldMask);
1145 return returnValue;
1148 GetFieldHandlePtr MaterialChunkBase::getHandleSpecular (void) const
1150 SFColor4f::GetHandlePtr returnValue(
1151 new SFColor4f::GetHandle(
1152 &_sfSpecular,
1153 this->getType().getFieldDesc(SpecularFieldId),
1154 const_cast<MaterialChunkBase *>(this)));
1156 return returnValue;
1159 EditFieldHandlePtr MaterialChunkBase::editHandleSpecular (void)
1161 SFColor4f::EditHandlePtr returnValue(
1162 new SFColor4f::EditHandle(
1163 &_sfSpecular,
1164 this->getType().getFieldDesc(SpecularFieldId),
1165 this));
1168 editSField(SpecularFieldMask);
1170 return returnValue;
1173 GetFieldHandlePtr MaterialChunkBase::getHandleEmission (void) const
1175 SFColor4f::GetHandlePtr returnValue(
1176 new SFColor4f::GetHandle(
1177 &_sfEmission,
1178 this->getType().getFieldDesc(EmissionFieldId),
1179 const_cast<MaterialChunkBase *>(this)));
1181 return returnValue;
1184 EditFieldHandlePtr MaterialChunkBase::editHandleEmission (void)
1186 SFColor4f::EditHandlePtr returnValue(
1187 new SFColor4f::EditHandle(
1188 &_sfEmission,
1189 this->getType().getFieldDesc(EmissionFieldId),
1190 this));
1193 editSField(EmissionFieldMask);
1195 return returnValue;
1198 GetFieldHandlePtr MaterialChunkBase::getHandleShininess (void) const
1200 SFReal32::GetHandlePtr returnValue(
1201 new SFReal32::GetHandle(
1202 &_sfShininess,
1203 this->getType().getFieldDesc(ShininessFieldId),
1204 const_cast<MaterialChunkBase *>(this)));
1206 return returnValue;
1209 EditFieldHandlePtr MaterialChunkBase::editHandleShininess (void)
1211 SFReal32::EditHandlePtr returnValue(
1212 new SFReal32::EditHandle(
1213 &_sfShininess,
1214 this->getType().getFieldDesc(ShininessFieldId),
1215 this));
1218 editSField(ShininessFieldMask);
1220 return returnValue;
1223 GetFieldHandlePtr MaterialChunkBase::getHandleLit (void) const
1225 SFBool::GetHandlePtr returnValue(
1226 new SFBool::GetHandle(
1227 &_sfLit,
1228 this->getType().getFieldDesc(LitFieldId),
1229 const_cast<MaterialChunkBase *>(this)));
1231 return returnValue;
1234 EditFieldHandlePtr MaterialChunkBase::editHandleLit (void)
1236 SFBool::EditHandlePtr returnValue(
1237 new SFBool::EditHandle(
1238 &_sfLit,
1239 this->getType().getFieldDesc(LitFieldId),
1240 this));
1243 editSField(LitFieldMask);
1245 return returnValue;
1248 GetFieldHandlePtr MaterialChunkBase::getHandleColorMaterial (void) const
1250 SFGLenum::GetHandlePtr returnValue(
1251 new SFGLenum::GetHandle(
1252 &_sfColorMaterial,
1253 this->getType().getFieldDesc(ColorMaterialFieldId),
1254 const_cast<MaterialChunkBase *>(this)));
1256 return returnValue;
1259 EditFieldHandlePtr MaterialChunkBase::editHandleColorMaterial (void)
1261 SFGLenum::EditHandlePtr returnValue(
1262 new SFGLenum::EditHandle(
1263 &_sfColorMaterial,
1264 this->getType().getFieldDesc(ColorMaterialFieldId),
1265 this));
1268 editSField(ColorMaterialFieldMask);
1270 return returnValue;
1273 GetFieldHandlePtr MaterialChunkBase::getHandleBackMaterial (void) const
1275 SFBool::GetHandlePtr returnValue(
1276 new SFBool::GetHandle(
1277 &_sfBackMaterial,
1278 this->getType().getFieldDesc(BackMaterialFieldId),
1279 const_cast<MaterialChunkBase *>(this)));
1281 return returnValue;
1284 EditFieldHandlePtr MaterialChunkBase::editHandleBackMaterial (void)
1286 SFBool::EditHandlePtr returnValue(
1287 new SFBool::EditHandle(
1288 &_sfBackMaterial,
1289 this->getType().getFieldDesc(BackMaterialFieldId),
1290 this));
1293 editSField(BackMaterialFieldMask);
1295 return returnValue;
1298 GetFieldHandlePtr MaterialChunkBase::getHandleBackDiffuse (void) const
1300 SFColor4f::GetHandlePtr returnValue(
1301 new SFColor4f::GetHandle(
1302 &_sfBackDiffuse,
1303 this->getType().getFieldDesc(BackDiffuseFieldId),
1304 const_cast<MaterialChunkBase *>(this)));
1306 return returnValue;
1309 EditFieldHandlePtr MaterialChunkBase::editHandleBackDiffuse (void)
1311 SFColor4f::EditHandlePtr returnValue(
1312 new SFColor4f::EditHandle(
1313 &_sfBackDiffuse,
1314 this->getType().getFieldDesc(BackDiffuseFieldId),
1315 this));
1318 editSField(BackDiffuseFieldMask);
1320 return returnValue;
1323 GetFieldHandlePtr MaterialChunkBase::getHandleBackAmbient (void) const
1325 SFColor4f::GetHandlePtr returnValue(
1326 new SFColor4f::GetHandle(
1327 &_sfBackAmbient,
1328 this->getType().getFieldDesc(BackAmbientFieldId),
1329 const_cast<MaterialChunkBase *>(this)));
1331 return returnValue;
1334 EditFieldHandlePtr MaterialChunkBase::editHandleBackAmbient (void)
1336 SFColor4f::EditHandlePtr returnValue(
1337 new SFColor4f::EditHandle(
1338 &_sfBackAmbient,
1339 this->getType().getFieldDesc(BackAmbientFieldId),
1340 this));
1343 editSField(BackAmbientFieldMask);
1345 return returnValue;
1348 GetFieldHandlePtr MaterialChunkBase::getHandleBackSpecular (void) const
1350 SFColor4f::GetHandlePtr returnValue(
1351 new SFColor4f::GetHandle(
1352 &_sfBackSpecular,
1353 this->getType().getFieldDesc(BackSpecularFieldId),
1354 const_cast<MaterialChunkBase *>(this)));
1356 return returnValue;
1359 EditFieldHandlePtr MaterialChunkBase::editHandleBackSpecular (void)
1361 SFColor4f::EditHandlePtr returnValue(
1362 new SFColor4f::EditHandle(
1363 &_sfBackSpecular,
1364 this->getType().getFieldDesc(BackSpecularFieldId),
1365 this));
1368 editSField(BackSpecularFieldMask);
1370 return returnValue;
1373 GetFieldHandlePtr MaterialChunkBase::getHandleBackEmission (void) const
1375 SFColor4f::GetHandlePtr returnValue(
1376 new SFColor4f::GetHandle(
1377 &_sfBackEmission,
1378 this->getType().getFieldDesc(BackEmissionFieldId),
1379 const_cast<MaterialChunkBase *>(this)));
1381 return returnValue;
1384 EditFieldHandlePtr MaterialChunkBase::editHandleBackEmission (void)
1386 SFColor4f::EditHandlePtr returnValue(
1387 new SFColor4f::EditHandle(
1388 &_sfBackEmission,
1389 this->getType().getFieldDesc(BackEmissionFieldId),
1390 this));
1393 editSField(BackEmissionFieldMask);
1395 return returnValue;
1398 GetFieldHandlePtr MaterialChunkBase::getHandleBackShininess (void) const
1400 SFReal32::GetHandlePtr returnValue(
1401 new SFReal32::GetHandle(
1402 &_sfBackShininess,
1403 this->getType().getFieldDesc(BackShininessFieldId),
1404 const_cast<MaterialChunkBase *>(this)));
1406 return returnValue;
1409 EditFieldHandlePtr MaterialChunkBase::editHandleBackShininess (void)
1411 SFReal32::EditHandlePtr returnValue(
1412 new SFReal32::EditHandle(
1413 &_sfBackShininess,
1414 this->getType().getFieldDesc(BackShininessFieldId),
1415 this));
1418 editSField(BackShininessFieldMask);
1420 return returnValue;
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)));
1431 return returnValue;
1434 EditFieldHandlePtr MaterialChunkBase::editHandleBackColorMaterial(void)
1436 SFGLenum::EditHandlePtr returnValue(
1437 new SFGLenum::EditHandle(
1438 &_sfBackColorMaterial,
1439 this->getType().getFieldDesc(BackColorMaterialFieldId),
1440 this));
1443 editSField(BackColorMaterialFieldMask);
1445 return returnValue;
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),
1459 whichField,
1460 oOffsets,
1461 syncMode,
1462 uiSyncInfo);
1464 #endif
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));
1477 return returnValue;
1479 #endif
1481 void MaterialChunkBase::resolveLinks(void)
1483 Inherited::resolveLinks();
1489 OSG_END_NAMESPACE