changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Groups / Base / OSGLightBase.cpp
blob8008447de5ffd9521792bca9cb71c597c33e22a5
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 Light!
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"
65 #include "OSGNode.h" // Beacon Class
66 #include "OSGLightEngine.h" // LightEngine Class
68 #include "OSGLightBase.h"
69 #include "OSGLight.h"
71 #include <boost/bind.hpp>
73 OSG_BEGIN_NAMESPACE
75 /***************************************************************************\
76 * Description *
77 \***************************************************************************/
79 /*! \class OSG::Light
80 Light is the base class for all the light source nodes.
81 It contains the field for the general light source attributes
82 (AmbientColor, DiffuseColor, SpecularColor, Beacon). The Beacon
83 defines the reference coordinate system for the lightsource, while
84 the position in the graph defines the objects that are lit.
87 /***************************************************************************\
88 * Field Documentation *
89 \***************************************************************************/
91 /*! \var Color4f LightBase::_sfAmbient
92 The light's ambient component.
95 /*! \var Color4f LightBase::_sfDiffuse
96 The light's diffuse color.
99 /*! \var Color4f LightBase::_sfSpecular
100 The light's specular color.
103 /*! \var Node * LightBase::_sfBeacon
107 /*! \var bool LightBase::_sfOn
111 /*! \var Real32 LightBase::_sfConstantAttenuation
112 The light's constant attenuation.
115 /*! \var Real32 LightBase::_sfLinearAttenuation
116 The light's linear attenuation.
119 /*! \var Real32 LightBase::_sfQuadraticAttenuation
120 The light's quadratic attenuation.
123 /*! \var LightEngine * LightBase::_sfLightEngine
127 /*! \var Real32 LightBase::_sfShadowIntensity
131 /*! \var UInt32 LightBase::_sfShadowMode
136 /***************************************************************************\
137 * FieldType/FieldTrait Instantiation *
138 \***************************************************************************/
140 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
141 PointerType FieldTraits<Light *, nsOSG>::_type(
142 "LightPtr",
143 "GroupPtr",
144 Light::getClassType(),
145 nsOSG);
146 #endif
148 OSG_FIELDTRAITS_GETTYPE_NS(Light *, nsOSG)
150 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
151 Light *,
152 nsOSG)
154 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
155 Light *,
156 nsOSG)
158 /***************************************************************************\
159 * Field Description *
160 \***************************************************************************/
162 void LightBase::classDescInserter(TypeObject &oType)
164 FieldDescriptionBase *pDesc = NULL;
167 pDesc = new SFColor4f::Description(
168 SFColor4f::getClassType(),
169 "ambient",
170 "The light's ambient component.\n",
171 AmbientFieldId, AmbientFieldMask,
172 false,
173 (Field::SFDefaultFlags | Field::FStdAccess),
174 static_cast<FieldEditMethodSig>(&Light::editHandleAmbient),
175 static_cast<FieldGetMethodSig >(&Light::getHandleAmbient));
177 oType.addInitialDesc(pDesc);
179 pDesc = new SFColor4f::Description(
180 SFColor4f::getClassType(),
181 "diffuse",
182 "The light's diffuse color.\n",
183 DiffuseFieldId, DiffuseFieldMask,
184 false,
185 (Field::SFDefaultFlags | Field::FStdAccess),
186 static_cast<FieldEditMethodSig>(&Light::editHandleDiffuse),
187 static_cast<FieldGetMethodSig >(&Light::getHandleDiffuse));
189 oType.addInitialDesc(pDesc);
191 pDesc = new SFColor4f::Description(
192 SFColor4f::getClassType(),
193 "specular",
194 "The light's specular color.\n",
195 SpecularFieldId, SpecularFieldMask,
196 false,
197 (Field::SFDefaultFlags | Field::FStdAccess),
198 static_cast<FieldEditMethodSig>(&Light::editHandleSpecular),
199 static_cast<FieldGetMethodSig >(&Light::getHandleSpecular));
201 oType.addInitialDesc(pDesc);
203 pDesc = new SFWeakNodePtr::Description(
204 SFWeakNodePtr::getClassType(),
205 "beacon",
207 BeaconFieldId, BeaconFieldMask,
208 false,
209 (Field::SFDefaultFlags | Field::FStdAccess),
210 static_cast<FieldEditMethodSig>(&Light::editHandleBeacon),
211 static_cast<FieldGetMethodSig >(&Light::getHandleBeacon));
213 oType.addInitialDesc(pDesc);
215 pDesc = new SFBool::Description(
216 SFBool::getClassType(),
217 "on",
219 OnFieldId, OnFieldMask,
220 false,
221 (Field::SFDefaultFlags | Field::FStdAccess),
222 static_cast<FieldEditMethodSig>(&Light::editHandleOn),
223 static_cast<FieldGetMethodSig >(&Light::getHandleOn));
225 oType.addInitialDesc(pDesc);
227 pDesc = new SFReal32::Description(
228 SFReal32::getClassType(),
229 "constantAttenuation",
230 "The light's constant attenuation.\n",
231 ConstantAttenuationFieldId, ConstantAttenuationFieldMask,
232 false,
233 (Field::SFDefaultFlags | Field::FStdAccess),
234 static_cast<FieldEditMethodSig>(&Light::editHandleConstantAttenuation),
235 static_cast<FieldGetMethodSig >(&Light::getHandleConstantAttenuation));
237 oType.addInitialDesc(pDesc);
239 pDesc = new SFReal32::Description(
240 SFReal32::getClassType(),
241 "linearAttenuation",
242 "The light's linear attenuation.\n",
243 LinearAttenuationFieldId, LinearAttenuationFieldMask,
244 false,
245 (Field::SFDefaultFlags | Field::FStdAccess),
246 static_cast<FieldEditMethodSig>(&Light::editHandleLinearAttenuation),
247 static_cast<FieldGetMethodSig >(&Light::getHandleLinearAttenuation));
249 oType.addInitialDesc(pDesc);
251 pDesc = new SFReal32::Description(
252 SFReal32::getClassType(),
253 "quadraticAttenuation",
254 "The light's quadratic attenuation.\n",
255 QuadraticAttenuationFieldId, QuadraticAttenuationFieldMask,
256 false,
257 (Field::SFDefaultFlags | Field::FStdAccess),
258 static_cast<FieldEditMethodSig>(&Light::editHandleQuadraticAttenuation),
259 static_cast<FieldGetMethodSig >(&Light::getHandleQuadraticAttenuation));
261 oType.addInitialDesc(pDesc);
263 pDesc = new SFUnrecLightEnginePtr::Description(
264 SFUnrecLightEnginePtr::getClassType(),
265 "lightEngine",
267 LightEngineFieldId, LightEngineFieldMask,
268 false,
269 (Field::SFDefaultFlags | Field::FStdAccess),
270 static_cast<FieldEditMethodSig>(&Light::editHandleLightEngine),
271 static_cast<FieldGetMethodSig >(&Light::getHandleLightEngine));
273 oType.addInitialDesc(pDesc);
275 pDesc = new SFReal32::Description(
276 SFReal32::getClassType(),
277 "shadowIntensity",
279 ShadowIntensityFieldId, ShadowIntensityFieldMask,
280 false,
281 (Field::SFDefaultFlags | Field::FStdAccess),
282 static_cast<FieldEditMethodSig>(&Light::editHandleShadowIntensity),
283 static_cast<FieldGetMethodSig >(&Light::getHandleShadowIntensity));
285 oType.addInitialDesc(pDesc);
287 pDesc = new SFUInt32::Description(
288 SFUInt32::getClassType(),
289 "shadowMode",
291 ShadowModeFieldId, ShadowModeFieldMask,
292 false,
293 (Field::SFDefaultFlags | Field::FStdAccess),
294 static_cast<FieldEditMethodSig>(&Light::editHandleShadowMode),
295 static_cast<FieldGetMethodSig >(&Light::getHandleShadowMode));
297 oType.addInitialDesc(pDesc);
301 LightBase::TypeObject LightBase::_type(
302 LightBase::getClassname(),
303 Inherited::getClassname(),
304 "NULL",
305 nsOSG, //Namespace
306 NULL,
307 reinterpret_cast<InitContainerF>(&Light::initMethod),
308 reinterpret_cast<ExitContainerF>(&Light::exitMethod),
309 reinterpret_cast<InitalInsertDescFunc>(
310 reinterpret_cast<void *>(&Light::classDescInserter)),
311 false,
313 "<?xml version=\"1.0\"?>\n"
314 "\n"
315 "<FieldContainer\n"
316 " name=\"Light\"\n"
317 " parent=\"Group\"\n"
318 " library=\"System\"\n"
319 " pointerfieldtypes=\"both\"\n"
320 " structure=\"abstract\"\n"
321 " systemcomponent=\"true\"\n"
322 " parentsystemcomponent=\"true\"\n"
323 " isNodeCore=\"true\"\n"
324 " decoratable=\"false\"\n"
325 " useLocalIncludes=\"false\"\n"
326 " docGroupBase=\"GrpSystemNodeCoreGroups\"\n"
327 " >\n"
328 "\n"
329 " Light is the base class for all the light source nodes.\n"
330 " It contains the field for the general light source attributes\n"
331 " (AmbientColor, DiffuseColor, SpecularColor, Beacon). The Beacon\n"
332 " defines the reference coordinate system for the lightsource, while\n"
333 " the position in the graph defines the objects that are lit.\n"
334 "\n"
335 " <Field\n"
336 "\t name=\"ambient\"\n"
337 "\t type=\"Color4f\"\n"
338 "\t cardinality=\"single\"\n"
339 "\t visibility=\"external\"\n"
340 "\t defaultValue=\"0.f,0.f,0.f,1.f\"\n"
341 "\t access=\"public\"\n"
342 "\t >\n"
343 "\tThe light's ambient component.\n"
344 " </Field>\n"
345 " <Field\n"
346 "\t name=\"diffuse\"\n"
347 "\t type=\"Color4f\"\n"
348 "\t cardinality=\"single\"\n"
349 "\t visibility=\"external\"\n"
350 "\t defaultValue=\"1.f,1.f,1.f,1.f\"\n"
351 "\t access=\"public\"\n"
352 "\t >\n"
353 "\tThe light's diffuse color.\n"
354 " </Field>\n"
355 " <Field\n"
356 "\t name=\"specular\"\n"
357 "\t type=\"Color4f\"\n"
358 "\t cardinality=\"single\"\n"
359 "\t visibility=\"external\"\n"
360 "\t defaultValue=\"1.f,1.f,1.f,1.f\"\n"
361 "\t access=\"public\"\n"
362 "\t >\n"
363 "\tThe light's specular color.\n"
364 " </Field>\n"
365 " <Field\n"
366 "\t name=\"beacon\"\n"
367 "\t type=\"Node\"\n"
368 " category=\"weakpointer\"\n"
369 "\t cardinality=\"single\"\n"
370 "\t visibility=\"external\"\n"
371 "\t access=\"public\"\n"
372 "\t >\n"
373 " </Field>\n"
374 " <Field\n"
375 "\t name=\"on\"\n"
376 "\t type=\"bool\"\n"
377 "\t cardinality=\"single\"\n"
378 "\t visibility=\"external\"\n"
379 "\t defaultValue=\"true\"\n"
380 "\t access=\"public\"\n"
381 "\t >\n"
382 " </Field>\n"
383 " <Field\n"
384 "\t name=\"constantAttenuation\"\n"
385 "\t type=\"Real32\"\n"
386 "\t cardinality=\"single\"\n"
387 "\t visibility=\"external\"\n"
388 "\t defaultValue=\"1.f\"\n"
389 "\t access=\"public\"\n"
390 "\t >\n"
391 "\tThe light's constant attenuation.\n"
392 " </Field>\n"
393 " <Field\n"
394 "\t name=\"linearAttenuation\"\n"
395 "\t type=\"Real32\"\n"
396 "\t cardinality=\"single\"\n"
397 "\t visibility=\"external\"\n"
398 "\t defaultValue=\"0.f\"\n"
399 "\t access=\"public\"\n"
400 "\t >\n"
401 "\tThe light's linear attenuation.\n"
402 " </Field>\n"
403 " <Field\n"
404 "\t name=\"quadraticAttenuation\"\n"
405 "\t type=\"Real32\"\n"
406 "\t cardinality=\"single\"\n"
407 "\t visibility=\"external\"\n"
408 "\t defaultValue=\"0.f\"\n"
409 "\t access=\"public\"\n"
410 "\t >\n"
411 "\tThe light's quadratic attenuation.\n"
412 " </Field>\n"
413 " <Field\n"
414 "\t name=\"lightEngine\"\n"
415 "\t type=\"LightEnginePtr\"\n"
416 "\t cardinality=\"single\"\n"
417 "\t visibility=\"external\"\n"
418 "\t access=\"public\"\n"
419 "\t >\n"
420 " </Field>\n"
421 "\n"
422 "\n"
423 " <Field\n"
424 "\t name=\"shadowIntensity\"\n"
425 "\t type=\"Real32\"\n"
426 "\t cardinality=\"single\"\n"
427 "\t visibility=\"external\"\n"
428 "\t defaultValue=\"0.f\"\n"
429 "\t access=\"public\"\n"
430 "\t >\n"
431 " </Field>\n"
432 " <Field\n"
433 "\t name=\"shadowMode\"\n"
434 "\t type=\"UInt32\"\n"
435 "\t cardinality=\"single\"\n"
436 "\t visibility=\"external\"\n"
437 "\t defaultValue=\"0\"\n"
438 "\t access=\"public\"\n"
439 "\t >\n"
440 " </Field>\n"
441 "\n"
442 "\n"
443 "</FieldContainer>\n",
444 "Light is the base class for all the light source nodes.\n"
445 "It contains the field for the general light source attributes\n"
446 "(AmbientColor, DiffuseColor, SpecularColor, Beacon). The Beacon\n"
447 "defines the reference coordinate system for the lightsource, while\n"
448 "the position in the graph defines the objects that are lit.\n"
451 /*------------------------------ get -----------------------------------*/
453 FieldContainerType &LightBase::getType(void)
455 return _type;
458 const FieldContainerType &LightBase::getType(void) const
460 return _type;
463 UInt32 LightBase::getContainerSize(void) const
465 return sizeof(Light);
468 /*------------------------- decorator get ------------------------------*/
471 SFColor4f *LightBase::editSFAmbient(void)
473 editSField(AmbientFieldMask);
475 return &_sfAmbient;
478 const SFColor4f *LightBase::getSFAmbient(void) const
480 return &_sfAmbient;
484 SFColor4f *LightBase::editSFDiffuse(void)
486 editSField(DiffuseFieldMask);
488 return &_sfDiffuse;
491 const SFColor4f *LightBase::getSFDiffuse(void) const
493 return &_sfDiffuse;
497 SFColor4f *LightBase::editSFSpecular(void)
499 editSField(SpecularFieldMask);
501 return &_sfSpecular;
504 const SFColor4f *LightBase::getSFSpecular(void) const
506 return &_sfSpecular;
510 //! Get the Light::_sfBeacon field.
511 const SFWeakNodePtr *LightBase::getSFBeacon(void) const
513 return &_sfBeacon;
516 SFWeakNodePtr *LightBase::editSFBeacon (void)
518 editSField(BeaconFieldMask);
520 return &_sfBeacon;
523 //! Get the value of the Light::_sfBeacon field.
524 Node * LightBase::getBeacon(void) const
526 return _sfBeacon.getValue();
529 //! Set the value of the Light::_sfBeacon field.
530 void LightBase::setBeacon(Node * const value)
532 editSField(BeaconFieldMask);
534 _sfBeacon.setValue(value);
538 SFBool *LightBase::editSFOn(void)
540 editSField(OnFieldMask);
542 return &_sfOn;
545 const SFBool *LightBase::getSFOn(void) const
547 return &_sfOn;
551 SFReal32 *LightBase::editSFConstantAttenuation(void)
553 editSField(ConstantAttenuationFieldMask);
555 return &_sfConstantAttenuation;
558 const SFReal32 *LightBase::getSFConstantAttenuation(void) const
560 return &_sfConstantAttenuation;
564 SFReal32 *LightBase::editSFLinearAttenuation(void)
566 editSField(LinearAttenuationFieldMask);
568 return &_sfLinearAttenuation;
571 const SFReal32 *LightBase::getSFLinearAttenuation(void) const
573 return &_sfLinearAttenuation;
577 SFReal32 *LightBase::editSFQuadraticAttenuation(void)
579 editSField(QuadraticAttenuationFieldMask);
581 return &_sfQuadraticAttenuation;
584 const SFReal32 *LightBase::getSFQuadraticAttenuation(void) const
586 return &_sfQuadraticAttenuation;
590 //! Get the Light::_sfLightEngine field.
591 const SFUnrecLightEnginePtr *LightBase::getSFLightEngine(void) const
593 return &_sfLightEngine;
596 SFUnrecLightEnginePtr *LightBase::editSFLightEngine (void)
598 editSField(LightEngineFieldMask);
600 return &_sfLightEngine;
603 //! Get the value of the Light::_sfLightEngine field.
604 LightEngine * LightBase::getLightEngine(void) const
606 return _sfLightEngine.getValue();
609 //! Set the value of the Light::_sfLightEngine field.
610 void LightBase::setLightEngine(LightEngine * const value)
612 editSField(LightEngineFieldMask);
614 _sfLightEngine.setValue(value);
618 SFReal32 *LightBase::editSFShadowIntensity(void)
620 editSField(ShadowIntensityFieldMask);
622 return &_sfShadowIntensity;
625 const SFReal32 *LightBase::getSFShadowIntensity(void) const
627 return &_sfShadowIntensity;
631 SFUInt32 *LightBase::editSFShadowMode(void)
633 editSField(ShadowModeFieldMask);
635 return &_sfShadowMode;
638 const SFUInt32 *LightBase::getSFShadowMode(void) const
640 return &_sfShadowMode;
648 /*------------------------------ access -----------------------------------*/
650 SizeT LightBase::getBinSize(ConstFieldMaskArg whichField)
652 SizeT returnValue = Inherited::getBinSize(whichField);
654 if(FieldBits::NoField != (AmbientFieldMask & whichField))
656 returnValue += _sfAmbient.getBinSize();
658 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
660 returnValue += _sfDiffuse.getBinSize();
662 if(FieldBits::NoField != (SpecularFieldMask & whichField))
664 returnValue += _sfSpecular.getBinSize();
666 if(FieldBits::NoField != (BeaconFieldMask & whichField))
668 returnValue += _sfBeacon.getBinSize();
670 if(FieldBits::NoField != (OnFieldMask & whichField))
672 returnValue += _sfOn.getBinSize();
674 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
676 returnValue += _sfConstantAttenuation.getBinSize();
678 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
680 returnValue += _sfLinearAttenuation.getBinSize();
682 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
684 returnValue += _sfQuadraticAttenuation.getBinSize();
686 if(FieldBits::NoField != (LightEngineFieldMask & whichField))
688 returnValue += _sfLightEngine.getBinSize();
690 if(FieldBits::NoField != (ShadowIntensityFieldMask & whichField))
692 returnValue += _sfShadowIntensity.getBinSize();
694 if(FieldBits::NoField != (ShadowModeFieldMask & whichField))
696 returnValue += _sfShadowMode.getBinSize();
699 return returnValue;
702 void LightBase::copyToBin(BinaryDataHandler &pMem,
703 ConstFieldMaskArg whichField)
705 Inherited::copyToBin(pMem, whichField);
707 if(FieldBits::NoField != (AmbientFieldMask & whichField))
709 _sfAmbient.copyToBin(pMem);
711 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
713 _sfDiffuse.copyToBin(pMem);
715 if(FieldBits::NoField != (SpecularFieldMask & whichField))
717 _sfSpecular.copyToBin(pMem);
719 if(FieldBits::NoField != (BeaconFieldMask & whichField))
721 _sfBeacon.copyToBin(pMem);
723 if(FieldBits::NoField != (OnFieldMask & whichField))
725 _sfOn.copyToBin(pMem);
727 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
729 _sfConstantAttenuation.copyToBin(pMem);
731 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
733 _sfLinearAttenuation.copyToBin(pMem);
735 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
737 _sfQuadraticAttenuation.copyToBin(pMem);
739 if(FieldBits::NoField != (LightEngineFieldMask & whichField))
741 _sfLightEngine.copyToBin(pMem);
743 if(FieldBits::NoField != (ShadowIntensityFieldMask & whichField))
745 _sfShadowIntensity.copyToBin(pMem);
747 if(FieldBits::NoField != (ShadowModeFieldMask & whichField))
749 _sfShadowMode.copyToBin(pMem);
753 void LightBase::copyFromBin(BinaryDataHandler &pMem,
754 ConstFieldMaskArg whichField)
756 Inherited::copyFromBin(pMem, whichField);
758 if(FieldBits::NoField != (AmbientFieldMask & whichField))
760 editSField(AmbientFieldMask);
761 _sfAmbient.copyFromBin(pMem);
763 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
765 editSField(DiffuseFieldMask);
766 _sfDiffuse.copyFromBin(pMem);
768 if(FieldBits::NoField != (SpecularFieldMask & whichField))
770 editSField(SpecularFieldMask);
771 _sfSpecular.copyFromBin(pMem);
773 if(FieldBits::NoField != (BeaconFieldMask & whichField))
775 editSField(BeaconFieldMask);
776 _sfBeacon.copyFromBin(pMem);
778 if(FieldBits::NoField != (OnFieldMask & whichField))
780 editSField(OnFieldMask);
781 _sfOn.copyFromBin(pMem);
783 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
785 editSField(ConstantAttenuationFieldMask);
786 _sfConstantAttenuation.copyFromBin(pMem);
788 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
790 editSField(LinearAttenuationFieldMask);
791 _sfLinearAttenuation.copyFromBin(pMem);
793 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
795 editSField(QuadraticAttenuationFieldMask);
796 _sfQuadraticAttenuation.copyFromBin(pMem);
798 if(FieldBits::NoField != (LightEngineFieldMask & whichField))
800 editSField(LightEngineFieldMask);
801 _sfLightEngine.copyFromBin(pMem);
803 if(FieldBits::NoField != (ShadowIntensityFieldMask & whichField))
805 editSField(ShadowIntensityFieldMask);
806 _sfShadowIntensity.copyFromBin(pMem);
808 if(FieldBits::NoField != (ShadowModeFieldMask & whichField))
810 editSField(ShadowModeFieldMask);
811 _sfShadowMode.copyFromBin(pMem);
818 /*------------------------- constructors ----------------------------------*/
820 LightBase::LightBase(void) :
821 Inherited(),
822 _sfAmbient (Color4f(0.f,0.f,0.f,1.f)),
823 _sfDiffuse (Color4f(1.f,1.f,1.f,1.f)),
824 _sfSpecular (Color4f(1.f,1.f,1.f,1.f)),
825 _sfBeacon (NULL),
826 _sfOn (bool(true)),
827 _sfConstantAttenuation (Real32(1.f)),
828 _sfLinearAttenuation (Real32(0.f)),
829 _sfQuadraticAttenuation (Real32(0.f)),
830 _sfLightEngine (NULL),
831 _sfShadowIntensity (Real32(0.f)),
832 _sfShadowMode (UInt32(0))
836 LightBase::LightBase(const LightBase &source) :
837 Inherited(source),
838 _sfAmbient (source._sfAmbient ),
839 _sfDiffuse (source._sfDiffuse ),
840 _sfSpecular (source._sfSpecular ),
841 _sfBeacon (NULL),
842 _sfOn (source._sfOn ),
843 _sfConstantAttenuation (source._sfConstantAttenuation ),
844 _sfLinearAttenuation (source._sfLinearAttenuation ),
845 _sfQuadraticAttenuation (source._sfQuadraticAttenuation ),
846 _sfLightEngine (NULL),
847 _sfShadowIntensity (source._sfShadowIntensity ),
848 _sfShadowMode (source._sfShadowMode )
853 /*-------------------------- destructors ----------------------------------*/
855 LightBase::~LightBase(void)
859 void LightBase::onCreate(const Light *source)
861 Inherited::onCreate(source);
863 if(source != NULL)
865 Light *pThis = static_cast<Light *>(this);
867 pThis->setBeacon(source->getBeacon());
869 pThis->setLightEngine(source->getLightEngine());
873 GetFieldHandlePtr LightBase::getHandleAmbient (void) const
875 SFColor4f::GetHandlePtr returnValue(
876 new SFColor4f::GetHandle(
877 &_sfAmbient,
878 this->getType().getFieldDesc(AmbientFieldId),
879 const_cast<LightBase *>(this)));
881 return returnValue;
884 EditFieldHandlePtr LightBase::editHandleAmbient (void)
886 SFColor4f::EditHandlePtr returnValue(
887 new SFColor4f::EditHandle(
888 &_sfAmbient,
889 this->getType().getFieldDesc(AmbientFieldId),
890 this));
893 editSField(AmbientFieldMask);
895 return returnValue;
898 GetFieldHandlePtr LightBase::getHandleDiffuse (void) const
900 SFColor4f::GetHandlePtr returnValue(
901 new SFColor4f::GetHandle(
902 &_sfDiffuse,
903 this->getType().getFieldDesc(DiffuseFieldId),
904 const_cast<LightBase *>(this)));
906 return returnValue;
909 EditFieldHandlePtr LightBase::editHandleDiffuse (void)
911 SFColor4f::EditHandlePtr returnValue(
912 new SFColor4f::EditHandle(
913 &_sfDiffuse,
914 this->getType().getFieldDesc(DiffuseFieldId),
915 this));
918 editSField(DiffuseFieldMask);
920 return returnValue;
923 GetFieldHandlePtr LightBase::getHandleSpecular (void) const
925 SFColor4f::GetHandlePtr returnValue(
926 new SFColor4f::GetHandle(
927 &_sfSpecular,
928 this->getType().getFieldDesc(SpecularFieldId),
929 const_cast<LightBase *>(this)));
931 return returnValue;
934 EditFieldHandlePtr LightBase::editHandleSpecular (void)
936 SFColor4f::EditHandlePtr returnValue(
937 new SFColor4f::EditHandle(
938 &_sfSpecular,
939 this->getType().getFieldDesc(SpecularFieldId),
940 this));
943 editSField(SpecularFieldMask);
945 return returnValue;
948 GetFieldHandlePtr LightBase::getHandleBeacon (void) const
950 SFWeakNodePtr::GetHandlePtr returnValue(
951 new SFWeakNodePtr::GetHandle(
952 &_sfBeacon,
953 this->getType().getFieldDesc(BeaconFieldId),
954 const_cast<LightBase *>(this)));
956 return returnValue;
959 EditFieldHandlePtr LightBase::editHandleBeacon (void)
961 SFWeakNodePtr::EditHandlePtr returnValue(
962 new SFWeakNodePtr::EditHandle(
963 &_sfBeacon,
964 this->getType().getFieldDesc(BeaconFieldId),
965 this));
967 returnValue->setSetMethod(
968 boost::bind(&Light::setBeacon,
969 static_cast<Light *>(this), _1));
971 editSField(BeaconFieldMask);
973 return returnValue;
976 GetFieldHandlePtr LightBase::getHandleOn (void) const
978 SFBool::GetHandlePtr returnValue(
979 new SFBool::GetHandle(
980 &_sfOn,
981 this->getType().getFieldDesc(OnFieldId),
982 const_cast<LightBase *>(this)));
984 return returnValue;
987 EditFieldHandlePtr LightBase::editHandleOn (void)
989 SFBool::EditHandlePtr returnValue(
990 new SFBool::EditHandle(
991 &_sfOn,
992 this->getType().getFieldDesc(OnFieldId),
993 this));
996 editSField(OnFieldMask);
998 return returnValue;
1001 GetFieldHandlePtr LightBase::getHandleConstantAttenuation (void) const
1003 SFReal32::GetHandlePtr returnValue(
1004 new SFReal32::GetHandle(
1005 &_sfConstantAttenuation,
1006 this->getType().getFieldDesc(ConstantAttenuationFieldId),
1007 const_cast<LightBase *>(this)));
1009 return returnValue;
1012 EditFieldHandlePtr LightBase::editHandleConstantAttenuation(void)
1014 SFReal32::EditHandlePtr returnValue(
1015 new SFReal32::EditHandle(
1016 &_sfConstantAttenuation,
1017 this->getType().getFieldDesc(ConstantAttenuationFieldId),
1018 this));
1021 editSField(ConstantAttenuationFieldMask);
1023 return returnValue;
1026 GetFieldHandlePtr LightBase::getHandleLinearAttenuation (void) const
1028 SFReal32::GetHandlePtr returnValue(
1029 new SFReal32::GetHandle(
1030 &_sfLinearAttenuation,
1031 this->getType().getFieldDesc(LinearAttenuationFieldId),
1032 const_cast<LightBase *>(this)));
1034 return returnValue;
1037 EditFieldHandlePtr LightBase::editHandleLinearAttenuation(void)
1039 SFReal32::EditHandlePtr returnValue(
1040 new SFReal32::EditHandle(
1041 &_sfLinearAttenuation,
1042 this->getType().getFieldDesc(LinearAttenuationFieldId),
1043 this));
1046 editSField(LinearAttenuationFieldMask);
1048 return returnValue;
1051 GetFieldHandlePtr LightBase::getHandleQuadraticAttenuation (void) const
1053 SFReal32::GetHandlePtr returnValue(
1054 new SFReal32::GetHandle(
1055 &_sfQuadraticAttenuation,
1056 this->getType().getFieldDesc(QuadraticAttenuationFieldId),
1057 const_cast<LightBase *>(this)));
1059 return returnValue;
1062 EditFieldHandlePtr LightBase::editHandleQuadraticAttenuation(void)
1064 SFReal32::EditHandlePtr returnValue(
1065 new SFReal32::EditHandle(
1066 &_sfQuadraticAttenuation,
1067 this->getType().getFieldDesc(QuadraticAttenuationFieldId),
1068 this));
1071 editSField(QuadraticAttenuationFieldMask);
1073 return returnValue;
1076 GetFieldHandlePtr LightBase::getHandleLightEngine (void) const
1078 SFUnrecLightEnginePtr::GetHandlePtr returnValue(
1079 new SFUnrecLightEnginePtr::GetHandle(
1080 &_sfLightEngine,
1081 this->getType().getFieldDesc(LightEngineFieldId),
1082 const_cast<LightBase *>(this)));
1084 return returnValue;
1087 EditFieldHandlePtr LightBase::editHandleLightEngine (void)
1089 SFUnrecLightEnginePtr::EditHandlePtr returnValue(
1090 new SFUnrecLightEnginePtr::EditHandle(
1091 &_sfLightEngine,
1092 this->getType().getFieldDesc(LightEngineFieldId),
1093 this));
1095 returnValue->setSetMethod(
1096 boost::bind(&Light::setLightEngine,
1097 static_cast<Light *>(this), _1));
1099 editSField(LightEngineFieldMask);
1101 return returnValue;
1104 GetFieldHandlePtr LightBase::getHandleShadowIntensity (void) const
1106 SFReal32::GetHandlePtr returnValue(
1107 new SFReal32::GetHandle(
1108 &_sfShadowIntensity,
1109 this->getType().getFieldDesc(ShadowIntensityFieldId),
1110 const_cast<LightBase *>(this)));
1112 return returnValue;
1115 EditFieldHandlePtr LightBase::editHandleShadowIntensity(void)
1117 SFReal32::EditHandlePtr returnValue(
1118 new SFReal32::EditHandle(
1119 &_sfShadowIntensity,
1120 this->getType().getFieldDesc(ShadowIntensityFieldId),
1121 this));
1124 editSField(ShadowIntensityFieldMask);
1126 return returnValue;
1129 GetFieldHandlePtr LightBase::getHandleShadowMode (void) const
1131 SFUInt32::GetHandlePtr returnValue(
1132 new SFUInt32::GetHandle(
1133 &_sfShadowMode,
1134 this->getType().getFieldDesc(ShadowModeFieldId),
1135 const_cast<LightBase *>(this)));
1137 return returnValue;
1140 EditFieldHandlePtr LightBase::editHandleShadowMode (void)
1142 SFUInt32::EditHandlePtr returnValue(
1143 new SFUInt32::EditHandle(
1144 &_sfShadowMode,
1145 this->getType().getFieldDesc(ShadowModeFieldId),
1146 this));
1149 editSField(ShadowModeFieldMask);
1151 return returnValue;
1155 #ifdef OSG_MT_CPTR_ASPECT
1156 void LightBase::execSyncV( FieldContainer &oFrom,
1157 ConstFieldMaskArg whichField,
1158 AspectOffsetStore &oOffsets,
1159 ConstFieldMaskArg syncMode,
1160 const UInt32 uiSyncInfo)
1162 Light *pThis = static_cast<Light *>(this);
1164 pThis->execSync(static_cast<Light *>(&oFrom),
1165 whichField,
1166 oOffsets,
1167 syncMode,
1168 uiSyncInfo);
1170 #endif
1174 void LightBase::resolveLinks(void)
1176 Inherited::resolveLinks();
1178 static_cast<Light *>(this)->setBeacon(NULL);
1180 static_cast<Light *>(this)->setLightEngine(NULL);
1186 OSG_END_NAMESPACE