changed: gcc8 base update
[opensg.git] / Source / System / State / Base / OSGLightChunkBase.cpp
blob7b9b0e5d86d59a70a8ad63342da058d94f2b4077
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 LightChunk!
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
67 #include "OSGLightChunkBase.h"
68 #include "OSGLightChunk.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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(
148 "LightChunkPtr",
149 "StateChunkPtr",
150 LightChunk::getClassType(),
151 nsOSG);
152 #endif
154 OSG_FIELDTRAITS_GETTYPE_NS(LightChunk *, nsOSG)
156 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
157 LightChunk *,
158 nsOSG)
160 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
161 LightChunk *,
162 nsOSG)
164 /***************************************************************************\
165 * Field Description *
166 \***************************************************************************/
168 void LightChunkBase::classDescInserter(TypeObject &oType)
170 FieldDescriptionBase *pDesc = NULL;
173 pDesc = new SFColor4f::Description(
174 SFColor4f::getClassType(),
175 "diffuse",
176 "The light's diffuse color.\n",
177 DiffuseFieldId, DiffuseFieldMask,
178 false,
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(),
187 "ambient",
188 "The light's ambient color.\n",
189 AmbientFieldId, AmbientFieldMask,
190 false,
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(),
199 "specular",
200 "The light's specular color.\n",
201 SpecularFieldId, SpecularFieldMask,
202 false,
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(),
211 "position",
212 "The light's position.\n",
213 PositionFieldId, PositionFieldMask,
214 false,
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(),
223 "direction",
224 "The light's direction (only for spotlights).\n",
225 DirectionFieldId, DirectionFieldMask,
226 false,
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(),
235 "exponent",
236 "The light's spotlight exponent.\n",
237 ExponentFieldId, ExponentFieldMask,
238 false,
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(),
247 "cutoff",
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,
250 false,
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,
262 false,
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(),
271 "linearAttenuation",
272 "The light's linear attenuation.\n",
273 LinearAttenuationFieldId, LinearAttenuationFieldMask,
274 false,
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,
286 false,
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(),
295 "beacon",
297 BeaconFieldId, BeaconFieldMask,
298 false,
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(),
310 "NULL",
311 nsOSG, //Namespace
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)),
317 false,
319 "<?xml version=\"1.0\" ?>\n"
320 "\n"
321 "<FieldContainer\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"
330 ">\n"
331 "See \\ref PageSystemLightChunk for a description.\n"
332 "\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"
335 "\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"
343 "\t<Field\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"
349 "\t>\n"
350 "\tThe light's diffuse color.\n"
351 "\t</Field>\n"
352 "\t<Field\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"
358 "\t>\n"
359 "\tThe light's ambient color.\n"
360 "\t</Field>\n"
361 "\t<Field\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"
367 "\t>\n"
368 "\tThe light's specular color.\n"
369 "\t</Field>\n"
370 "\t<Field\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"
376 "\t>\n"
377 "\tThe light's position.\n"
378 "\t</Field>\n"
379 "\t<Field\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"
385 "\t>\n"
386 "\tThe light's direction (only for spotlights).\n"
387 "\t</Field>\n"
388 "\t<Field\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"
394 "\t>\n"
395 "\tThe light's spotlight exponent.\n"
396 "\t</Field>\n"
397 "\t<Field\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"
403 "\t>\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"
405 "\t</Field>\n"
406 "\t<Field\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"
412 "\t>\n"
413 "\tThe light's constant attenuation.\n"
414 "\t</Field>\n"
415 "\t<Field\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"
421 "\t>\n"
422 "\tThe light's linear attenuation.\n"
423 "\t</Field>\n"
424 "\t<Field\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"
430 "\t>\n"
431 "\tThe light's quadratic attenuation.\n"
432 "\t</Field>\n"
433 "\t<Field\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"
441 "\t>\n"
442 "\t</Field>\n"
443 "</FieldContainer>\n",
444 "See \\ref PageSystemLightChunk for a description.\n"
445 "\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"
448 "\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)
462 return _type;
465 const FieldContainerType &LightChunkBase::getType(void) const
467 return _type;
470 UInt32 LightChunkBase::getContainerSize(void) const
472 return sizeof(LightChunk);
475 /*------------------------- decorator get ------------------------------*/
478 SFColor4f *LightChunkBase::editSFDiffuse(void)
480 editSField(DiffuseFieldMask);
482 return &_sfDiffuse;
485 const SFColor4f *LightChunkBase::getSFDiffuse(void) const
487 return &_sfDiffuse;
491 SFColor4f *LightChunkBase::editSFAmbient(void)
493 editSField(AmbientFieldMask);
495 return &_sfAmbient;
498 const SFColor4f *LightChunkBase::getSFAmbient(void) const
500 return &_sfAmbient;
504 SFColor4f *LightChunkBase::editSFSpecular(void)
506 editSField(SpecularFieldMask);
508 return &_sfSpecular;
511 const SFColor4f *LightChunkBase::getSFSpecular(void) const
513 return &_sfSpecular;
517 SFVec4f *LightChunkBase::editSFPosition(void)
519 editSField(PositionFieldMask);
521 return &_sfPosition;
524 const SFVec4f *LightChunkBase::getSFPosition(void) const
526 return &_sfPosition;
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);
547 return &_sfExponent;
550 const SFReal32 *LightChunkBase::getSFExponent(void) const
552 return &_sfExponent;
556 SFReal32 *LightChunkBase::editSFCutoff(void)
558 editSField(CutoffFieldMask);
560 return &_sfCutoff;
563 const SFReal32 *LightChunkBase::getSFCutoff(void) const
565 return &_sfCutoff;
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
611 return &_sfBeacon;
614 SFWeakNodePtr *LightChunkBase::editSFBeacon (void)
616 editSField(BeaconFieldMask);
618 return &_sfBeacon;
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();
691 return returnValue;
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);
820 return fc;
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);
836 return fc;
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);
852 return fc;
855 LightChunk *LightChunkBase::createEmptyLocal(BitVector bFlags)
857 LightChunk *returnValue;
859 newPtr<LightChunk>(returnValue, bFlags);
861 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
863 return returnValue;
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();
876 return returnValue;
880 FieldContainerTransitPtr LightChunkBase::shallowCopyLocal(
881 BitVector bFlags) const
883 LightChunk *tmpPtr;
885 newPtr(tmpPtr, dynamic_cast<const LightChunk *>(this), bFlags);
887 FieldContainerTransitPtr returnValue(tmpPtr);
889 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
891 return returnValue;
894 FieldContainerTransitPtr LightChunkBase::shallowCopyDependent(
895 BitVector bFlags) const
897 LightChunk *tmpPtr;
899 newPtr(tmpPtr, dynamic_cast<const LightChunk *>(this), ~bFlags);
901 FieldContainerTransitPtr returnValue(tmpPtr);
903 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
905 return returnValue;
908 FieldContainerTransitPtr LightChunkBase::shallowCopy(void) const
910 LightChunk *tmpPtr;
912 newPtr(tmpPtr,
913 dynamic_cast<const LightChunk *>(this),
914 Thread::getCurrentLocalFlags());
916 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
918 FieldContainerTransitPtr returnValue(tmpPtr);
920 return returnValue;
926 /*------------------------- constructors ----------------------------------*/
928 LightChunkBase::LightChunkBase(void) :
929 Inherited(),
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)),
940 _sfBeacon (NULL)
944 LightChunkBase::LightChunkBase(const LightChunkBase &source) :
945 Inherited(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 ),
956 _sfBeacon (NULL)
961 /*-------------------------- destructors ----------------------------------*/
963 LightChunkBase::~LightChunkBase(void)
967 void LightChunkBase::onCreate(const LightChunk *source)
969 Inherited::onCreate(source);
971 if(source != NULL)
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(
983 &_sfDiffuse,
984 this->getType().getFieldDesc(DiffuseFieldId),
985 const_cast<LightChunkBase *>(this)));
987 return returnValue;
990 EditFieldHandlePtr LightChunkBase::editHandleDiffuse (void)
992 SFColor4f::EditHandlePtr returnValue(
993 new SFColor4f::EditHandle(
994 &_sfDiffuse,
995 this->getType().getFieldDesc(DiffuseFieldId),
996 this));
999 editSField(DiffuseFieldMask);
1001 return returnValue;
1004 GetFieldHandlePtr LightChunkBase::getHandleAmbient (void) const
1006 SFColor4f::GetHandlePtr returnValue(
1007 new SFColor4f::GetHandle(
1008 &_sfAmbient,
1009 this->getType().getFieldDesc(AmbientFieldId),
1010 const_cast<LightChunkBase *>(this)));
1012 return returnValue;
1015 EditFieldHandlePtr LightChunkBase::editHandleAmbient (void)
1017 SFColor4f::EditHandlePtr returnValue(
1018 new SFColor4f::EditHandle(
1019 &_sfAmbient,
1020 this->getType().getFieldDesc(AmbientFieldId),
1021 this));
1024 editSField(AmbientFieldMask);
1026 return returnValue;
1029 GetFieldHandlePtr LightChunkBase::getHandleSpecular (void) const
1031 SFColor4f::GetHandlePtr returnValue(
1032 new SFColor4f::GetHandle(
1033 &_sfSpecular,
1034 this->getType().getFieldDesc(SpecularFieldId),
1035 const_cast<LightChunkBase *>(this)));
1037 return returnValue;
1040 EditFieldHandlePtr LightChunkBase::editHandleSpecular (void)
1042 SFColor4f::EditHandlePtr returnValue(
1043 new SFColor4f::EditHandle(
1044 &_sfSpecular,
1045 this->getType().getFieldDesc(SpecularFieldId),
1046 this));
1049 editSField(SpecularFieldMask);
1051 return returnValue;
1054 GetFieldHandlePtr LightChunkBase::getHandlePosition (void) const
1056 SFVec4f::GetHandlePtr returnValue(
1057 new SFVec4f::GetHandle(
1058 &_sfPosition,
1059 this->getType().getFieldDesc(PositionFieldId),
1060 const_cast<LightChunkBase *>(this)));
1062 return returnValue;
1065 EditFieldHandlePtr LightChunkBase::editHandlePosition (void)
1067 SFVec4f::EditHandlePtr returnValue(
1068 new SFVec4f::EditHandle(
1069 &_sfPosition,
1070 this->getType().getFieldDesc(PositionFieldId),
1071 this));
1074 editSField(PositionFieldMask);
1076 return returnValue;
1079 GetFieldHandlePtr LightChunkBase::getHandleDirection (void) const
1081 SFVec3f::GetHandlePtr returnValue(
1082 new SFVec3f::GetHandle(
1083 &_sfDirection,
1084 this->getType().getFieldDesc(DirectionFieldId),
1085 const_cast<LightChunkBase *>(this)));
1087 return returnValue;
1090 EditFieldHandlePtr LightChunkBase::editHandleDirection (void)
1092 SFVec3f::EditHandlePtr returnValue(
1093 new SFVec3f::EditHandle(
1094 &_sfDirection,
1095 this->getType().getFieldDesc(DirectionFieldId),
1096 this));
1099 editSField(DirectionFieldMask);
1101 return returnValue;
1104 GetFieldHandlePtr LightChunkBase::getHandleExponent (void) const
1106 SFReal32::GetHandlePtr returnValue(
1107 new SFReal32::GetHandle(
1108 &_sfExponent,
1109 this->getType().getFieldDesc(ExponentFieldId),
1110 const_cast<LightChunkBase *>(this)));
1112 return returnValue;
1115 EditFieldHandlePtr LightChunkBase::editHandleExponent (void)
1117 SFReal32::EditHandlePtr returnValue(
1118 new SFReal32::EditHandle(
1119 &_sfExponent,
1120 this->getType().getFieldDesc(ExponentFieldId),
1121 this));
1124 editSField(ExponentFieldMask);
1126 return returnValue;
1129 GetFieldHandlePtr LightChunkBase::getHandleCutoff (void) const
1131 SFReal32::GetHandlePtr returnValue(
1132 new SFReal32::GetHandle(
1133 &_sfCutoff,
1134 this->getType().getFieldDesc(CutoffFieldId),
1135 const_cast<LightChunkBase *>(this)));
1137 return returnValue;
1140 EditFieldHandlePtr LightChunkBase::editHandleCutoff (void)
1142 SFReal32::EditHandlePtr returnValue(
1143 new SFReal32::EditHandle(
1144 &_sfCutoff,
1145 this->getType().getFieldDesc(CutoffFieldId),
1146 this));
1149 editSField(CutoffFieldMask);
1151 return returnValue;
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)));
1162 return returnValue;
1165 EditFieldHandlePtr LightChunkBase::editHandleConstantAttenuation(void)
1167 SFReal32::EditHandlePtr returnValue(
1168 new SFReal32::EditHandle(
1169 &_sfConstantAttenuation,
1170 this->getType().getFieldDesc(ConstantAttenuationFieldId),
1171 this));
1174 editSField(ConstantAttenuationFieldMask);
1176 return returnValue;
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)));
1187 return returnValue;
1190 EditFieldHandlePtr LightChunkBase::editHandleLinearAttenuation(void)
1192 SFReal32::EditHandlePtr returnValue(
1193 new SFReal32::EditHandle(
1194 &_sfLinearAttenuation,
1195 this->getType().getFieldDesc(LinearAttenuationFieldId),
1196 this));
1199 editSField(LinearAttenuationFieldMask);
1201 return returnValue;
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)));
1212 return returnValue;
1215 EditFieldHandlePtr LightChunkBase::editHandleQuadraticAttenuation(void)
1217 SFReal32::EditHandlePtr returnValue(
1218 new SFReal32::EditHandle(
1219 &_sfQuadraticAttenuation,
1220 this->getType().getFieldDesc(QuadraticAttenuationFieldId),
1221 this));
1224 editSField(QuadraticAttenuationFieldMask);
1226 return returnValue;
1229 GetFieldHandlePtr LightChunkBase::getHandleBeacon (void) const
1231 SFWeakNodePtr::GetHandlePtr returnValue(
1232 new SFWeakNodePtr::GetHandle(
1233 &_sfBeacon,
1234 this->getType().getFieldDesc(BeaconFieldId),
1235 const_cast<LightChunkBase *>(this)));
1237 return returnValue;
1240 EditFieldHandlePtr LightChunkBase::editHandleBeacon (void)
1242 SFWeakNodePtr::EditHandlePtr returnValue(
1243 new SFWeakNodePtr::EditHandle(
1244 &_sfBeacon,
1245 this->getType().getFieldDesc(BeaconFieldId),
1246 this));
1248 returnValue->setSetMethod(
1249 boost::bind(&LightChunk::setBeacon,
1250 static_cast<LightChunk *>(this), _1));
1252 editSField(BeaconFieldMask);
1254 return returnValue;
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),
1268 whichField,
1269 oOffsets,
1270 syncMode,
1271 uiSyncInfo);
1273 #endif
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));
1286 return returnValue;
1288 #endif
1290 void LightChunkBase::resolveLinks(void)
1292 Inherited::resolveLinks();
1294 static_cast<LightChunk *>(this)->setBeacon(NULL);
1300 OSG_END_NAMESPACE