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 **
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"
65 #include "OSGNode.h" // Beacon Class
67 #include "OSGLightChunkBase.h"
68 #include "OSGLightChunk.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::LightChunk
79 See \ref PageSystemLightChunk for a description.
81 The light chunk contains the parameter set for a single light source. It's taken
82 straight from the glLight() manpage.
84 This chunk wraps glLight() (OSG::LightChunk::_sfAmbient,
85 OSG::LightChunk::_sfDiffuse, OSG::LightChunk::_sfSpecular,
86 OSG::LightChunk::_sfEmission, OSG::LightChunk::_sfPosition,
87 OSG::LightChunk::_sfDirection, OSG::LightChunk::_sfExponent,
88 OSG::LightChunk::_sfCutoff, OSG::LightChunk::_sfConstantAttenuation,
89 OSG::LightChunk::_sfLinearAttenuation,
90 OSG::LightChunk::_sfQuadraticAttenuation).
93 /***************************************************************************\
94 * Field Documentation *
95 \***************************************************************************/
97 /*! \var Color4f LightChunkBase::_sfDiffuse
98 The light's diffuse color.
101 /*! \var Color4f LightChunkBase::_sfAmbient
102 The light's ambient color.
105 /*! \var Color4f LightChunkBase::_sfSpecular
106 The light's specular color.
109 /*! \var Vec4f LightChunkBase::_sfPosition
110 The light's position.
113 /*! \var Vec3f LightChunkBase::_sfDirection
114 The light's direction (only for spotlights).
117 /*! \var Real32 LightChunkBase::_sfExponent
118 The light's spotlight exponent.
121 /*! \var Real32 LightChunkBase::_sfCutoff
122 The light's spotlight cutoff. As this chunk follows OpenGL conventions, this is the only angle in the system given in degrees.
125 /*! \var Real32 LightChunkBase::_sfConstantAttenuation
126 The light's constant attenuation.
129 /*! \var Real32 LightChunkBase::_sfLinearAttenuation
130 The light's linear attenuation.
133 /*! \var Real32 LightChunkBase::_sfQuadraticAttenuation
134 The light's quadratic attenuation.
137 /*! \var Node * LightChunkBase::_sfBeacon
142 /***************************************************************************\
143 * FieldType/FieldTrait Instantiation *
144 \***************************************************************************/
146 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
147 PointerType FieldTraits
<LightChunk
*, nsOSG
>::_type(
150 LightChunk::getClassType(),
154 OSG_FIELDTRAITS_GETTYPE_NS(LightChunk
*, nsOSG
)
156 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
160 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
164 /***************************************************************************\
165 * Field Description *
166 \***************************************************************************/
168 void LightChunkBase::classDescInserter(TypeObject
&oType
)
170 FieldDescriptionBase
*pDesc
= NULL
;
173 pDesc
= new SFColor4f::Description(
174 SFColor4f::getClassType(),
176 "The light's diffuse color.\n",
177 DiffuseFieldId
, DiffuseFieldMask
,
179 (Field::SFDefaultFlags
| Field::FStdAccess
),
180 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleDiffuse
),
181 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleDiffuse
));
183 oType
.addInitialDesc(pDesc
);
185 pDesc
= new SFColor4f::Description(
186 SFColor4f::getClassType(),
188 "The light's ambient color.\n",
189 AmbientFieldId
, AmbientFieldMask
,
191 (Field::SFDefaultFlags
| Field::FStdAccess
),
192 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleAmbient
),
193 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleAmbient
));
195 oType
.addInitialDesc(pDesc
);
197 pDesc
= new SFColor4f::Description(
198 SFColor4f::getClassType(),
200 "The light's specular color.\n",
201 SpecularFieldId
, SpecularFieldMask
,
203 (Field::SFDefaultFlags
| Field::FStdAccess
),
204 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleSpecular
),
205 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleSpecular
));
207 oType
.addInitialDesc(pDesc
);
209 pDesc
= new SFVec4f::Description(
210 SFVec4f::getClassType(),
212 "The light's position.\n",
213 PositionFieldId
, PositionFieldMask
,
215 (Field::SFDefaultFlags
| Field::FStdAccess
),
216 static_cast<FieldEditMethodSig
>(&LightChunk::editHandlePosition
),
217 static_cast<FieldGetMethodSig
>(&LightChunk::getHandlePosition
));
219 oType
.addInitialDesc(pDesc
);
221 pDesc
= new SFVec3f::Description(
222 SFVec3f::getClassType(),
224 "The light's direction (only for spotlights).\n",
225 DirectionFieldId
, DirectionFieldMask
,
227 (Field::SFDefaultFlags
| Field::FStdAccess
),
228 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleDirection
),
229 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleDirection
));
231 oType
.addInitialDesc(pDesc
);
233 pDesc
= new SFReal32::Description(
234 SFReal32::getClassType(),
236 "The light's spotlight exponent.\n",
237 ExponentFieldId
, ExponentFieldMask
,
239 (Field::SFDefaultFlags
| Field::FStdAccess
),
240 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleExponent
),
241 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleExponent
));
243 oType
.addInitialDesc(pDesc
);
245 pDesc
= new SFReal32::Description(
246 SFReal32::getClassType(),
248 "The light's spotlight cutoff. As this chunk follows OpenGL conventions, this is the only angle in the system given in degrees.\n",
249 CutoffFieldId
, CutoffFieldMask
,
251 (Field::SFDefaultFlags
| Field::FStdAccess
),
252 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleCutoff
),
253 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleCutoff
));
255 oType
.addInitialDesc(pDesc
);
257 pDesc
= new SFReal32::Description(
258 SFReal32::getClassType(),
259 "constantAttenuation",
260 "The light's constant attenuation.\n",
261 ConstantAttenuationFieldId
, ConstantAttenuationFieldMask
,
263 (Field::SFDefaultFlags
| Field::FStdAccess
),
264 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleConstantAttenuation
),
265 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleConstantAttenuation
));
267 oType
.addInitialDesc(pDesc
);
269 pDesc
= new SFReal32::Description(
270 SFReal32::getClassType(),
272 "The light's linear attenuation.\n",
273 LinearAttenuationFieldId
, LinearAttenuationFieldMask
,
275 (Field::SFDefaultFlags
| Field::FStdAccess
),
276 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleLinearAttenuation
),
277 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleLinearAttenuation
));
279 oType
.addInitialDesc(pDesc
);
281 pDesc
= new SFReal32::Description(
282 SFReal32::getClassType(),
283 "quadraticAttenuation",
284 "The light's quadratic attenuation.\n",
285 QuadraticAttenuationFieldId
, QuadraticAttenuationFieldMask
,
287 (Field::SFDefaultFlags
| Field::FStdAccess
),
288 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleQuadraticAttenuation
),
289 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleQuadraticAttenuation
));
291 oType
.addInitialDesc(pDesc
);
293 pDesc
= new SFWeakNodePtr::Description(
294 SFWeakNodePtr::getClassType(),
297 BeaconFieldId
, BeaconFieldMask
,
299 (Field::SFDefaultFlags
| Field::FStdAccess
),
300 static_cast<FieldEditMethodSig
>(&LightChunk::editHandleBeacon
),
301 static_cast<FieldGetMethodSig
>(&LightChunk::getHandleBeacon
));
303 oType
.addInitialDesc(pDesc
);
307 LightChunkBase::TypeObject
LightChunkBase::_type(
308 LightChunkBase::getClassname(),
309 Inherited::getClassname(),
312 reinterpret_cast<PrototypeCreateF
>(&LightChunkBase::createEmptyLocal
),
313 reinterpret_cast<InitContainerF
>(&LightChunk::initMethod
),
314 reinterpret_cast<ExitContainerF
>(&LightChunk::exitMethod
),
315 reinterpret_cast<InitalInsertDescFunc
>(
316 reinterpret_cast<void *>(&LightChunk::classDescInserter
)),
319 "<?xml version=\"1.0\" ?>\n"
322 " name=\"LightChunk\"\n"
323 " parent=\"StateChunk\"\n"
324 " library=\"System\"\n"
325 " structure=\"concrete\"\n"
326 " pointerfieldtypes=\"both\"\n"
327 " systemcomponent=\"true\"\n"
328 " parentsystemcomponent=\"true\"\n"
329 " docGroupBase=\"GrpSystemState\"\n"
331 "See \\ref PageSystemLightChunk for a description.\n"
333 "The light chunk contains the parameter set for a single light source. It's taken\n"
334 "straight from the glLight() manpage.\n"
336 "This chunk wraps glLight() (OSG::LightChunk::_sfAmbient,\n"
337 "OSG::LightChunk::_sfDiffuse, OSG::LightChunk::_sfSpecular,\n"
338 "OSG::LightChunk::_sfEmission, OSG::LightChunk::_sfPosition,\n"
339 "OSG::LightChunk::_sfDirection, OSG::LightChunk::_sfExponent,\n"
340 "OSG::LightChunk::_sfCutoff, OSG::LightChunk::_sfConstantAttenuation,\n"
341 "OSG::LightChunk::_sfLinearAttenuation,\n"
342 "OSG::LightChunk::_sfQuadraticAttenuation).\n"
344 "\t\tname=\"diffuse\"\n"
345 "\t\ttype=\"Color4f\"\n"
346 "\t\tcardinality=\"single\"\n"
347 "\t\tvisibility=\"external\"\n"
348 "\t\tdefaultValue=\"1.f,1.f,1.f,0.f\"\n"
350 "\tThe light's diffuse color.\n"
353 "\t\tname=\"ambient\"\n"
354 "\t\ttype=\"Color4f\"\n"
355 "\t\tcardinality=\"single\"\n"
356 "\t\tvisibility=\"external\"\n"
357 "\t\tdefaultValue=\".1f,.1f,.1f,0.f\"\n"
359 "\tThe light's ambient color.\n"
362 "\t\tname=\"specular\"\n"
363 "\t\ttype=\"Color4f\"\n"
364 "\t\tcardinality=\"single\"\n"
365 "\t\tvisibility=\"external\"\n"
366 "\t\tdefaultValue=\"1.f,1.f,1.f,0.f\"\n"
368 "\tThe light's specular color.\n"
371 "\t\tname=\"position\"\n"
372 "\t\ttype=\"Vec4f\"\n"
373 "\t\tcardinality=\"single\"\n"
374 "\t\tvisibility=\"external\"\n"
375 "\t\tdefaultValue=\"0.f,-1.f,0.f,0.f\"\n"
377 "\tThe light's position.\n"
380 "\t\tname=\"direction\"\n"
381 "\t\ttype=\"Vec3f\"\n"
382 "\t\tcardinality=\"single\"\n"
383 "\t\tvisibility=\"external\"\n"
384 "\t\tdefaultValue=\"0.f,0.f,1.f\"\n"
386 "\tThe light's direction (only for spotlights).\n"
389 "\t\tname=\"exponent\"\n"
390 "\t\ttype=\"Real32\"\n"
391 "\t\tcardinality=\"single\"\n"
392 "\t\tvisibility=\"external\"\n"
393 "\t\tdefaultValue=\"2.f\"\n"
395 "\tThe light's spotlight exponent.\n"
398 "\t\tname=\"cutoff\"\n"
399 "\t\ttype=\"Real32\"\n"
400 "\t\tcardinality=\"single\"\n"
401 "\t\tvisibility=\"external\"\n"
402 "\t\tdefaultValue=\"180.f\"\n"
404 "\tThe light's spotlight cutoff. As this chunk follows OpenGL conventions, this is the only angle in the system given in degrees.\n"
407 "\t\tname=\"constantAttenuation\"\n"
408 "\t\ttype=\"Real32\"\n"
409 "\t\tcardinality=\"single\"\n"
410 "\t\tvisibility=\"external\"\n"
411 "\t\tdefaultValue=\"1.f\"\n"
413 "\tThe light's constant attenuation.\n"
416 "\t\tname=\"linearAttenuation\"\n"
417 "\t\ttype=\"Real32\"\n"
418 "\t\tcardinality=\"single\"\n"
419 "\t\tvisibility=\"external\"\n"
420 "\t\tdefaultValue=\"0.f\"\n"
422 "\tThe light's linear attenuation.\n"
425 "\t\tname=\"quadraticAttenuation\"\n"
426 "\t\ttype=\"Real32\"\n"
427 "\t\tcardinality=\"single\"\n"
428 "\t\tvisibility=\"external\"\n"
429 "\t\tdefaultValue=\"0.f\"\n"
431 "\tThe light's quadratic attenuation.\n"
434 "\t\tname=\"beacon\"\n"
435 "\t\ttype=\"Node\"\n"
436 " category=\"weakpointer\"\n"
437 "\t\tcardinality=\"single\"\n"
438 "\t\tvisibility=\"external\"\n"
439 "\t\tdefaultValue=\"NULL\"\n"
440 "\t\taccess=\"public\"\n"
443 "</FieldContainer>\n",
444 "See \\ref PageSystemLightChunk for a description.\n"
446 "The light chunk contains the parameter set for a single light source. It's taken\n"
447 "straight from the glLight() manpage.\n"
449 "This chunk wraps glLight() (OSG::LightChunk::_sfAmbient,\n"
450 "OSG::LightChunk::_sfDiffuse, OSG::LightChunk::_sfSpecular,\n"
451 "OSG::LightChunk::_sfEmission, OSG::LightChunk::_sfPosition,\n"
452 "OSG::LightChunk::_sfDirection, OSG::LightChunk::_sfExponent,\n"
453 "OSG::LightChunk::_sfCutoff, OSG::LightChunk::_sfConstantAttenuation,\n"
454 "OSG::LightChunk::_sfLinearAttenuation,\n"
455 "OSG::LightChunk::_sfQuadraticAttenuation).\n"
458 /*------------------------------ get -----------------------------------*/
460 FieldContainerType
&LightChunkBase::getType(void)
465 const FieldContainerType
&LightChunkBase::getType(void) const
470 UInt32
LightChunkBase::getContainerSize(void) const
472 return sizeof(LightChunk
);
475 /*------------------------- decorator get ------------------------------*/
478 SFColor4f
*LightChunkBase::editSFDiffuse(void)
480 editSField(DiffuseFieldMask
);
485 const SFColor4f
*LightChunkBase::getSFDiffuse(void) const
491 SFColor4f
*LightChunkBase::editSFAmbient(void)
493 editSField(AmbientFieldMask
);
498 const SFColor4f
*LightChunkBase::getSFAmbient(void) const
504 SFColor4f
*LightChunkBase::editSFSpecular(void)
506 editSField(SpecularFieldMask
);
511 const SFColor4f
*LightChunkBase::getSFSpecular(void) const
517 SFVec4f
*LightChunkBase::editSFPosition(void)
519 editSField(PositionFieldMask
);
524 const SFVec4f
*LightChunkBase::getSFPosition(void) const
530 SFVec3f
*LightChunkBase::editSFDirection(void)
532 editSField(DirectionFieldMask
);
534 return &_sfDirection
;
537 const SFVec3f
*LightChunkBase::getSFDirection(void) const
539 return &_sfDirection
;
543 SFReal32
*LightChunkBase::editSFExponent(void)
545 editSField(ExponentFieldMask
);
550 const SFReal32
*LightChunkBase::getSFExponent(void) const
556 SFReal32
*LightChunkBase::editSFCutoff(void)
558 editSField(CutoffFieldMask
);
563 const SFReal32
*LightChunkBase::getSFCutoff(void) const
569 SFReal32
*LightChunkBase::editSFConstantAttenuation(void)
571 editSField(ConstantAttenuationFieldMask
);
573 return &_sfConstantAttenuation
;
576 const SFReal32
*LightChunkBase::getSFConstantAttenuation(void) const
578 return &_sfConstantAttenuation
;
582 SFReal32
*LightChunkBase::editSFLinearAttenuation(void)
584 editSField(LinearAttenuationFieldMask
);
586 return &_sfLinearAttenuation
;
589 const SFReal32
*LightChunkBase::getSFLinearAttenuation(void) const
591 return &_sfLinearAttenuation
;
595 SFReal32
*LightChunkBase::editSFQuadraticAttenuation(void)
597 editSField(QuadraticAttenuationFieldMask
);
599 return &_sfQuadraticAttenuation
;
602 const SFReal32
*LightChunkBase::getSFQuadraticAttenuation(void) const
604 return &_sfQuadraticAttenuation
;
608 //! Get the LightChunk::_sfBeacon field.
609 const SFWeakNodePtr
*LightChunkBase::getSFBeacon(void) const
614 SFWeakNodePtr
*LightChunkBase::editSFBeacon (void)
616 editSField(BeaconFieldMask
);
621 //! Get the value of the LightChunk::_sfBeacon field.
622 Node
* LightChunkBase::getBeacon(void) const
624 return _sfBeacon
.getValue();
627 //! Set the value of the LightChunk::_sfBeacon field.
628 void LightChunkBase::setBeacon(Node
* const value
)
630 editSField(BeaconFieldMask
);
632 _sfBeacon
.setValue(value
);
640 /*------------------------------ access -----------------------------------*/
642 SizeT
LightChunkBase::getBinSize(ConstFieldMaskArg whichField
)
644 SizeT returnValue
= Inherited::getBinSize(whichField
);
646 if(FieldBits::NoField
!= (DiffuseFieldMask
& whichField
))
648 returnValue
+= _sfDiffuse
.getBinSize();
650 if(FieldBits::NoField
!= (AmbientFieldMask
& whichField
))
652 returnValue
+= _sfAmbient
.getBinSize();
654 if(FieldBits::NoField
!= (SpecularFieldMask
& whichField
))
656 returnValue
+= _sfSpecular
.getBinSize();
658 if(FieldBits::NoField
!= (PositionFieldMask
& whichField
))
660 returnValue
+= _sfPosition
.getBinSize();
662 if(FieldBits::NoField
!= (DirectionFieldMask
& whichField
))
664 returnValue
+= _sfDirection
.getBinSize();
666 if(FieldBits::NoField
!= (ExponentFieldMask
& whichField
))
668 returnValue
+= _sfExponent
.getBinSize();
670 if(FieldBits::NoField
!= (CutoffFieldMask
& whichField
))
672 returnValue
+= _sfCutoff
.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
!= (BeaconFieldMask
& whichField
))
688 returnValue
+= _sfBeacon
.getBinSize();
694 void LightChunkBase::copyToBin(BinaryDataHandler
&pMem
,
695 ConstFieldMaskArg whichField
)
697 Inherited::copyToBin(pMem
, whichField
);
699 if(FieldBits::NoField
!= (DiffuseFieldMask
& whichField
))
701 _sfDiffuse
.copyToBin(pMem
);
703 if(FieldBits::NoField
!= (AmbientFieldMask
& whichField
))
705 _sfAmbient
.copyToBin(pMem
);
707 if(FieldBits::NoField
!= (SpecularFieldMask
& whichField
))
709 _sfSpecular
.copyToBin(pMem
);
711 if(FieldBits::NoField
!= (PositionFieldMask
& whichField
))
713 _sfPosition
.copyToBin(pMem
);
715 if(FieldBits::NoField
!= (DirectionFieldMask
& whichField
))
717 _sfDirection
.copyToBin(pMem
);
719 if(FieldBits::NoField
!= (ExponentFieldMask
& whichField
))
721 _sfExponent
.copyToBin(pMem
);
723 if(FieldBits::NoField
!= (CutoffFieldMask
& whichField
))
725 _sfCutoff
.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
!= (BeaconFieldMask
& whichField
))
741 _sfBeacon
.copyToBin(pMem
);
745 void LightChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
746 ConstFieldMaskArg whichField
)
748 Inherited::copyFromBin(pMem
, whichField
);
750 if(FieldBits::NoField
!= (DiffuseFieldMask
& whichField
))
752 editSField(DiffuseFieldMask
);
753 _sfDiffuse
.copyFromBin(pMem
);
755 if(FieldBits::NoField
!= (AmbientFieldMask
& whichField
))
757 editSField(AmbientFieldMask
);
758 _sfAmbient
.copyFromBin(pMem
);
760 if(FieldBits::NoField
!= (SpecularFieldMask
& whichField
))
762 editSField(SpecularFieldMask
);
763 _sfSpecular
.copyFromBin(pMem
);
765 if(FieldBits::NoField
!= (PositionFieldMask
& whichField
))
767 editSField(PositionFieldMask
);
768 _sfPosition
.copyFromBin(pMem
);
770 if(FieldBits::NoField
!= (DirectionFieldMask
& whichField
))
772 editSField(DirectionFieldMask
);
773 _sfDirection
.copyFromBin(pMem
);
775 if(FieldBits::NoField
!= (ExponentFieldMask
& whichField
))
777 editSField(ExponentFieldMask
);
778 _sfExponent
.copyFromBin(pMem
);
780 if(FieldBits::NoField
!= (CutoffFieldMask
& whichField
))
782 editSField(CutoffFieldMask
);
783 _sfCutoff
.copyFromBin(pMem
);
785 if(FieldBits::NoField
!= (ConstantAttenuationFieldMask
& whichField
))
787 editSField(ConstantAttenuationFieldMask
);
788 _sfConstantAttenuation
.copyFromBin(pMem
);
790 if(FieldBits::NoField
!= (LinearAttenuationFieldMask
& whichField
))
792 editSField(LinearAttenuationFieldMask
);
793 _sfLinearAttenuation
.copyFromBin(pMem
);
795 if(FieldBits::NoField
!= (QuadraticAttenuationFieldMask
& whichField
))
797 editSField(QuadraticAttenuationFieldMask
);
798 _sfQuadraticAttenuation
.copyFromBin(pMem
);
800 if(FieldBits::NoField
!= (BeaconFieldMask
& whichField
))
802 editSField(BeaconFieldMask
);
803 _sfBeacon
.copyFromBin(pMem
);
807 //! create a new instance of the class
808 LightChunkTransitPtr
LightChunkBase::createLocal(BitVector bFlags
)
810 LightChunkTransitPtr fc
;
812 if(getClassType().getPrototype() != NULL
)
814 FieldContainerTransitPtr tmpPtr
=
815 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
817 fc
= dynamic_pointer_cast
<LightChunk
>(tmpPtr
);
823 //! create a new instance of the class, copy the container flags
824 LightChunkTransitPtr
LightChunkBase::createDependent(BitVector bFlags
)
826 LightChunkTransitPtr fc
;
828 if(getClassType().getPrototype() != NULL
)
830 FieldContainerTransitPtr tmpPtr
=
831 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
833 fc
= dynamic_pointer_cast
<LightChunk
>(tmpPtr
);
839 //! create a new instance of the class
840 LightChunkTransitPtr
LightChunkBase::create(void)
842 LightChunkTransitPtr fc
;
844 if(getClassType().getPrototype() != NULL
)
846 FieldContainerTransitPtr tmpPtr
=
847 getClassType().getPrototype()-> shallowCopy();
849 fc
= dynamic_pointer_cast
<LightChunk
>(tmpPtr
);
855 LightChunk
*LightChunkBase::createEmptyLocal(BitVector bFlags
)
857 LightChunk
*returnValue
;
859 newPtr
<LightChunk
>(returnValue
, bFlags
);
861 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
866 //! create an empty new instance of the class, do not copy the prototype
867 LightChunk
*LightChunkBase::createEmpty(void)
869 LightChunk
*returnValue
;
871 newPtr
<LightChunk
>(returnValue
, Thread::getCurrentLocalFlags());
873 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
874 ~Thread::getCurrentLocalFlags();
880 FieldContainerTransitPtr
LightChunkBase::shallowCopyLocal(
881 BitVector bFlags
) const
885 newPtr(tmpPtr
, dynamic_cast<const LightChunk
*>(this), bFlags
);
887 FieldContainerTransitPtr
returnValue(tmpPtr
);
889 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
894 FieldContainerTransitPtr
LightChunkBase::shallowCopyDependent(
895 BitVector bFlags
) const
899 newPtr(tmpPtr
, dynamic_cast<const LightChunk
*>(this), ~bFlags
);
901 FieldContainerTransitPtr
returnValue(tmpPtr
);
903 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
908 FieldContainerTransitPtr
LightChunkBase::shallowCopy(void) const
913 dynamic_cast<const LightChunk
*>(this),
914 Thread::getCurrentLocalFlags());
916 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
918 FieldContainerTransitPtr
returnValue(tmpPtr
);
926 /*------------------------- constructors ----------------------------------*/
928 LightChunkBase::LightChunkBase(void) :
930 _sfDiffuse (Color4f(1.f
,1.f
,1.f
,0.f
)),
931 _sfAmbient (Color4f(.1f
,.1f
,.1f
,0.f
)),
932 _sfSpecular (Color4f(1.f
,1.f
,1.f
,0.f
)),
933 _sfPosition (Vec4f(0.f
,-1.f
,0.f
,0.f
)),
934 _sfDirection (Vec3f(0.f
,0.f
,1.f
)),
935 _sfExponent (Real32(2.f
)),
936 _sfCutoff (Real32(180.f
)),
937 _sfConstantAttenuation (Real32(1.f
)),
938 _sfLinearAttenuation (Real32(0.f
)),
939 _sfQuadraticAttenuation (Real32(0.f
)),
944 LightChunkBase::LightChunkBase(const LightChunkBase
&source
) :
946 _sfDiffuse (source
._sfDiffuse
),
947 _sfAmbient (source
._sfAmbient
),
948 _sfSpecular (source
._sfSpecular
),
949 _sfPosition (source
._sfPosition
),
950 _sfDirection (source
._sfDirection
),
951 _sfExponent (source
._sfExponent
),
952 _sfCutoff (source
._sfCutoff
),
953 _sfConstantAttenuation (source
._sfConstantAttenuation
),
954 _sfLinearAttenuation (source
._sfLinearAttenuation
),
955 _sfQuadraticAttenuation (source
._sfQuadraticAttenuation
),
961 /*-------------------------- destructors ----------------------------------*/
963 LightChunkBase::~LightChunkBase(void)
967 void LightChunkBase::onCreate(const LightChunk
*source
)
969 Inherited::onCreate(source
);
973 LightChunk
*pThis
= static_cast<LightChunk
*>(this);
975 pThis
->setBeacon(source
->getBeacon());
979 GetFieldHandlePtr
LightChunkBase::getHandleDiffuse (void) const
981 SFColor4f::GetHandlePtr
returnValue(
982 new SFColor4f::GetHandle(
984 this->getType().getFieldDesc(DiffuseFieldId
),
985 const_cast<LightChunkBase
*>(this)));
990 EditFieldHandlePtr
LightChunkBase::editHandleDiffuse (void)
992 SFColor4f::EditHandlePtr
returnValue(
993 new SFColor4f::EditHandle(
995 this->getType().getFieldDesc(DiffuseFieldId
),
999 editSField(DiffuseFieldMask
);
1004 GetFieldHandlePtr
LightChunkBase::getHandleAmbient (void) const
1006 SFColor4f::GetHandlePtr
returnValue(
1007 new SFColor4f::GetHandle(
1009 this->getType().getFieldDesc(AmbientFieldId
),
1010 const_cast<LightChunkBase
*>(this)));
1015 EditFieldHandlePtr
LightChunkBase::editHandleAmbient (void)
1017 SFColor4f::EditHandlePtr
returnValue(
1018 new SFColor4f::EditHandle(
1020 this->getType().getFieldDesc(AmbientFieldId
),
1024 editSField(AmbientFieldMask
);
1029 GetFieldHandlePtr
LightChunkBase::getHandleSpecular (void) const
1031 SFColor4f::GetHandlePtr
returnValue(
1032 new SFColor4f::GetHandle(
1034 this->getType().getFieldDesc(SpecularFieldId
),
1035 const_cast<LightChunkBase
*>(this)));
1040 EditFieldHandlePtr
LightChunkBase::editHandleSpecular (void)
1042 SFColor4f::EditHandlePtr
returnValue(
1043 new SFColor4f::EditHandle(
1045 this->getType().getFieldDesc(SpecularFieldId
),
1049 editSField(SpecularFieldMask
);
1054 GetFieldHandlePtr
LightChunkBase::getHandlePosition (void) const
1056 SFVec4f::GetHandlePtr
returnValue(
1057 new SFVec4f::GetHandle(
1059 this->getType().getFieldDesc(PositionFieldId
),
1060 const_cast<LightChunkBase
*>(this)));
1065 EditFieldHandlePtr
LightChunkBase::editHandlePosition (void)
1067 SFVec4f::EditHandlePtr
returnValue(
1068 new SFVec4f::EditHandle(
1070 this->getType().getFieldDesc(PositionFieldId
),
1074 editSField(PositionFieldMask
);
1079 GetFieldHandlePtr
LightChunkBase::getHandleDirection (void) const
1081 SFVec3f::GetHandlePtr
returnValue(
1082 new SFVec3f::GetHandle(
1084 this->getType().getFieldDesc(DirectionFieldId
),
1085 const_cast<LightChunkBase
*>(this)));
1090 EditFieldHandlePtr
LightChunkBase::editHandleDirection (void)
1092 SFVec3f::EditHandlePtr
returnValue(
1093 new SFVec3f::EditHandle(
1095 this->getType().getFieldDesc(DirectionFieldId
),
1099 editSField(DirectionFieldMask
);
1104 GetFieldHandlePtr
LightChunkBase::getHandleExponent (void) const
1106 SFReal32::GetHandlePtr
returnValue(
1107 new SFReal32::GetHandle(
1109 this->getType().getFieldDesc(ExponentFieldId
),
1110 const_cast<LightChunkBase
*>(this)));
1115 EditFieldHandlePtr
LightChunkBase::editHandleExponent (void)
1117 SFReal32::EditHandlePtr
returnValue(
1118 new SFReal32::EditHandle(
1120 this->getType().getFieldDesc(ExponentFieldId
),
1124 editSField(ExponentFieldMask
);
1129 GetFieldHandlePtr
LightChunkBase::getHandleCutoff (void) const
1131 SFReal32::GetHandlePtr
returnValue(
1132 new SFReal32::GetHandle(
1134 this->getType().getFieldDesc(CutoffFieldId
),
1135 const_cast<LightChunkBase
*>(this)));
1140 EditFieldHandlePtr
LightChunkBase::editHandleCutoff (void)
1142 SFReal32::EditHandlePtr
returnValue(
1143 new SFReal32::EditHandle(
1145 this->getType().getFieldDesc(CutoffFieldId
),
1149 editSField(CutoffFieldMask
);
1154 GetFieldHandlePtr
LightChunkBase::getHandleConstantAttenuation (void) const
1156 SFReal32::GetHandlePtr
returnValue(
1157 new SFReal32::GetHandle(
1158 &_sfConstantAttenuation
,
1159 this->getType().getFieldDesc(ConstantAttenuationFieldId
),
1160 const_cast<LightChunkBase
*>(this)));
1165 EditFieldHandlePtr
LightChunkBase::editHandleConstantAttenuation(void)
1167 SFReal32::EditHandlePtr
returnValue(
1168 new SFReal32::EditHandle(
1169 &_sfConstantAttenuation
,
1170 this->getType().getFieldDesc(ConstantAttenuationFieldId
),
1174 editSField(ConstantAttenuationFieldMask
);
1179 GetFieldHandlePtr
LightChunkBase::getHandleLinearAttenuation (void) const
1181 SFReal32::GetHandlePtr
returnValue(
1182 new SFReal32::GetHandle(
1183 &_sfLinearAttenuation
,
1184 this->getType().getFieldDesc(LinearAttenuationFieldId
),
1185 const_cast<LightChunkBase
*>(this)));
1190 EditFieldHandlePtr
LightChunkBase::editHandleLinearAttenuation(void)
1192 SFReal32::EditHandlePtr
returnValue(
1193 new SFReal32::EditHandle(
1194 &_sfLinearAttenuation
,
1195 this->getType().getFieldDesc(LinearAttenuationFieldId
),
1199 editSField(LinearAttenuationFieldMask
);
1204 GetFieldHandlePtr
LightChunkBase::getHandleQuadraticAttenuation (void) const
1206 SFReal32::GetHandlePtr
returnValue(
1207 new SFReal32::GetHandle(
1208 &_sfQuadraticAttenuation
,
1209 this->getType().getFieldDesc(QuadraticAttenuationFieldId
),
1210 const_cast<LightChunkBase
*>(this)));
1215 EditFieldHandlePtr
LightChunkBase::editHandleQuadraticAttenuation(void)
1217 SFReal32::EditHandlePtr
returnValue(
1218 new SFReal32::EditHandle(
1219 &_sfQuadraticAttenuation
,
1220 this->getType().getFieldDesc(QuadraticAttenuationFieldId
),
1224 editSField(QuadraticAttenuationFieldMask
);
1229 GetFieldHandlePtr
LightChunkBase::getHandleBeacon (void) const
1231 SFWeakNodePtr::GetHandlePtr
returnValue(
1232 new SFWeakNodePtr::GetHandle(
1234 this->getType().getFieldDesc(BeaconFieldId
),
1235 const_cast<LightChunkBase
*>(this)));
1240 EditFieldHandlePtr
LightChunkBase::editHandleBeacon (void)
1242 SFWeakNodePtr::EditHandlePtr
returnValue(
1243 new SFWeakNodePtr::EditHandle(
1245 this->getType().getFieldDesc(BeaconFieldId
),
1248 returnValue
->setSetMethod(
1249 boost::bind(&LightChunk::setBeacon
,
1250 static_cast<LightChunk
*>(this), _1
));
1252 editSField(BeaconFieldMask
);
1258 #ifdef OSG_MT_CPTR_ASPECT
1259 void LightChunkBase::execSyncV( FieldContainer
&oFrom
,
1260 ConstFieldMaskArg whichField
,
1261 AspectOffsetStore
&oOffsets
,
1262 ConstFieldMaskArg syncMode
,
1263 const UInt32 uiSyncInfo
)
1265 LightChunk
*pThis
= static_cast<LightChunk
*>(this);
1267 pThis
->execSync(static_cast<LightChunk
*>(&oFrom
),
1276 #ifdef OSG_MT_CPTR_ASPECT
1277 FieldContainer
*LightChunkBase::createAspectCopy(
1278 const FieldContainer
*pRefAspect
) const
1280 LightChunk
*returnValue
;
1282 newAspectCopy(returnValue
,
1283 dynamic_cast<const LightChunk
*>(pRefAspect
),
1284 dynamic_cast<const LightChunk
*>(this));
1290 void LightChunkBase::resolveLinks(void)
1292 Inherited::resolveLinks();
1294 static_cast<LightChunk
*>(this)->setBeacon(NULL
);