fixed: stay with old cmake qt link setup (policy CMP0020)
[opensg.git] / Source / System / State / Base / OSGLightChunkBase.cpp
blobb95c0824eb6a1e1787430fba4fe0463b533958c4
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 #include "OSGConfig.h"
60 #include "OSGNode.h" // Beacon Class
62 #include "OSGLightChunkBase.h"
63 #include "OSGLightChunk.h"
65 #include <boost/bind.hpp>
67 #ifdef WIN32 // turn off 'this' : used in base member initializer list warning
68 #pragma warning(disable:4355)
69 #endif
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::LightChunk
78 See \ref PageSystemLightChunk for a description.
80 The light chunk contains the parameter set for a single light source. It's taken
81 straight from the glLight() manpage.
83 This chunk wraps glLight() (OSG::LightChunk::_sfAmbient,
84 OSG::LightChunk::_sfDiffuse, OSG::LightChunk::_sfSpecular,
85 OSG::LightChunk::_sfEmission, OSG::LightChunk::_sfPosition,
86 OSG::LightChunk::_sfDirection, OSG::LightChunk::_sfExponent,
87 OSG::LightChunk::_sfCutoff, OSG::LightChunk::_sfConstantAttenuation,
88 OSG::LightChunk::_sfLinearAttenuation,
89 OSG::LightChunk::_sfQuadraticAttenuation).
92 /***************************************************************************\
93 * Field Documentation *
94 \***************************************************************************/
96 /*! \var Color4f LightChunkBase::_sfDiffuse
97 The light's diffuse color.
100 /*! \var Color4f LightChunkBase::_sfAmbient
101 The light's ambient color.
104 /*! \var Color4f LightChunkBase::_sfSpecular
105 The light's specular color.
108 /*! \var Vec4f LightChunkBase::_sfPosition
109 The light's position.
112 /*! \var Vec3f LightChunkBase::_sfDirection
113 The light's direction (only for spotlights).
116 /*! \var Real32 LightChunkBase::_sfExponent
117 The light's spotlight exponent.
120 /*! \var Real32 LightChunkBase::_sfCutoff
121 The light's spotlight cutoff. As this chunk follows OpenGL conventions, this is the only angle in the system given in degrees.
124 /*! \var Real32 LightChunkBase::_sfConstantAttenuation
125 The light's constant attenuation.
128 /*! \var Real32 LightChunkBase::_sfLinearAttenuation
129 The light's linear attenuation.
132 /*! \var Real32 LightChunkBase::_sfQuadraticAttenuation
133 The light's quadratic attenuation.
136 /*! \var Node * LightChunkBase::_sfBeacon
141 /***************************************************************************\
142 * FieldType/FieldTrait Instantiation *
143 \***************************************************************************/
145 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
146 PointerType FieldTraits<LightChunk *, nsOSG>::_type(
147 "LightChunkPtr",
148 "StateChunkPtr",
149 LightChunk::getClassType(),
150 nsOSG);
151 #endif
153 OSG_FIELDTRAITS_GETTYPE_NS(LightChunk *, nsOSG)
155 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
156 LightChunk *,
157 nsOSG);
159 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
160 LightChunk *,
161 nsOSG);
163 /***************************************************************************\
164 * Field Description *
165 \***************************************************************************/
167 void LightChunkBase::classDescInserter(TypeObject &oType)
169 FieldDescriptionBase *pDesc = NULL;
172 pDesc = new SFColor4f::Description(
173 SFColor4f::getClassType(),
174 "diffuse",
175 "The light's diffuse color.\n",
176 DiffuseFieldId, DiffuseFieldMask,
177 false,
178 (Field::SFDefaultFlags | Field::FStdAccess),
179 static_cast<FieldEditMethodSig>(&LightChunk::editHandleDiffuse),
180 static_cast<FieldGetMethodSig >(&LightChunk::getHandleDiffuse));
182 oType.addInitialDesc(pDesc);
184 pDesc = new SFColor4f::Description(
185 SFColor4f::getClassType(),
186 "ambient",
187 "The light's ambient color.\n",
188 AmbientFieldId, AmbientFieldMask,
189 false,
190 (Field::SFDefaultFlags | Field::FStdAccess),
191 static_cast<FieldEditMethodSig>(&LightChunk::editHandleAmbient),
192 static_cast<FieldGetMethodSig >(&LightChunk::getHandleAmbient));
194 oType.addInitialDesc(pDesc);
196 pDesc = new SFColor4f::Description(
197 SFColor4f::getClassType(),
198 "specular",
199 "The light's specular color.\n",
200 SpecularFieldId, SpecularFieldMask,
201 false,
202 (Field::SFDefaultFlags | Field::FStdAccess),
203 static_cast<FieldEditMethodSig>(&LightChunk::editHandleSpecular),
204 static_cast<FieldGetMethodSig >(&LightChunk::getHandleSpecular));
206 oType.addInitialDesc(pDesc);
208 pDesc = new SFVec4f::Description(
209 SFVec4f::getClassType(),
210 "position",
211 "The light's position.\n",
212 PositionFieldId, PositionFieldMask,
213 false,
214 (Field::SFDefaultFlags | Field::FStdAccess),
215 static_cast<FieldEditMethodSig>(&LightChunk::editHandlePosition),
216 static_cast<FieldGetMethodSig >(&LightChunk::getHandlePosition));
218 oType.addInitialDesc(pDesc);
220 pDesc = new SFVec3f::Description(
221 SFVec3f::getClassType(),
222 "direction",
223 "The light's direction (only for spotlights).\n",
224 DirectionFieldId, DirectionFieldMask,
225 false,
226 (Field::SFDefaultFlags | Field::FStdAccess),
227 static_cast<FieldEditMethodSig>(&LightChunk::editHandleDirection),
228 static_cast<FieldGetMethodSig >(&LightChunk::getHandleDirection));
230 oType.addInitialDesc(pDesc);
232 pDesc = new SFReal32::Description(
233 SFReal32::getClassType(),
234 "exponent",
235 "The light's spotlight exponent.\n",
236 ExponentFieldId, ExponentFieldMask,
237 false,
238 (Field::SFDefaultFlags | Field::FStdAccess),
239 static_cast<FieldEditMethodSig>(&LightChunk::editHandleExponent),
240 static_cast<FieldGetMethodSig >(&LightChunk::getHandleExponent));
242 oType.addInitialDesc(pDesc);
244 pDesc = new SFReal32::Description(
245 SFReal32::getClassType(),
246 "cutoff",
247 "The light's spotlight cutoff. As this chunk follows OpenGL conventions, this is the only angle in the system given in degrees.\n",
248 CutoffFieldId, CutoffFieldMask,
249 false,
250 (Field::SFDefaultFlags | Field::FStdAccess),
251 static_cast<FieldEditMethodSig>(&LightChunk::editHandleCutoff),
252 static_cast<FieldGetMethodSig >(&LightChunk::getHandleCutoff));
254 oType.addInitialDesc(pDesc);
256 pDesc = new SFReal32::Description(
257 SFReal32::getClassType(),
258 "constantAttenuation",
259 "The light's constant attenuation.\n",
260 ConstantAttenuationFieldId, ConstantAttenuationFieldMask,
261 false,
262 (Field::SFDefaultFlags | Field::FStdAccess),
263 static_cast<FieldEditMethodSig>(&LightChunk::editHandleConstantAttenuation),
264 static_cast<FieldGetMethodSig >(&LightChunk::getHandleConstantAttenuation));
266 oType.addInitialDesc(pDesc);
268 pDesc = new SFReal32::Description(
269 SFReal32::getClassType(),
270 "linearAttenuation",
271 "The light's linear attenuation.\n",
272 LinearAttenuationFieldId, LinearAttenuationFieldMask,
273 false,
274 (Field::SFDefaultFlags | Field::FStdAccess),
275 static_cast<FieldEditMethodSig>(&LightChunk::editHandleLinearAttenuation),
276 static_cast<FieldGetMethodSig >(&LightChunk::getHandleLinearAttenuation));
278 oType.addInitialDesc(pDesc);
280 pDesc = new SFReal32::Description(
281 SFReal32::getClassType(),
282 "quadraticAttenuation",
283 "The light's quadratic attenuation.\n",
284 QuadraticAttenuationFieldId, QuadraticAttenuationFieldMask,
285 false,
286 (Field::SFDefaultFlags | Field::FStdAccess),
287 static_cast<FieldEditMethodSig>(&LightChunk::editHandleQuadraticAttenuation),
288 static_cast<FieldGetMethodSig >(&LightChunk::getHandleQuadraticAttenuation));
290 oType.addInitialDesc(pDesc);
292 pDesc = new SFWeakNodePtr::Description(
293 SFWeakNodePtr::getClassType(),
294 "beacon",
296 BeaconFieldId, BeaconFieldMask,
297 false,
298 (Field::SFDefaultFlags | Field::FStdAccess),
299 static_cast<FieldEditMethodSig>(&LightChunk::editHandleBeacon),
300 static_cast<FieldGetMethodSig >(&LightChunk::getHandleBeacon));
302 oType.addInitialDesc(pDesc);
306 LightChunkBase::TypeObject LightChunkBase::_type(
307 LightChunkBase::getClassname(),
308 Inherited::getClassname(),
309 "NULL",
310 nsOSG, //Namespace
311 reinterpret_cast<PrototypeCreateF>(&LightChunkBase::createEmptyLocal),
312 LightChunk::initMethod,
313 LightChunk::exitMethod,
314 reinterpret_cast<InitalInsertDescFunc>(&LightChunk::classDescInserter),
315 false,
317 "<?xml version=\"1.0\" ?>\n"
318 "\n"
319 "<FieldContainer\n"
320 " name=\"LightChunk\"\n"
321 " parent=\"StateChunk\"\n"
322 " library=\"System\"\n"
323 " structure=\"concrete\"\n"
324 " pointerfieldtypes=\"both\"\n"
325 " systemcomponent=\"true\"\n"
326 " parentsystemcomponent=\"true\"\n"
327 " docGroupBase=\"GrpSystemState\"\n"
328 ">\n"
329 "See \\ref PageSystemLightChunk for a description.\n"
330 "\n"
331 "The light chunk contains the parameter set for a single light source. It's taken\n"
332 "straight from the glLight() manpage.\n"
333 "\n"
334 "This chunk wraps glLight() (OSG::LightChunk::_sfAmbient,\n"
335 "OSG::LightChunk::_sfDiffuse, OSG::LightChunk::_sfSpecular,\n"
336 "OSG::LightChunk::_sfEmission, OSG::LightChunk::_sfPosition,\n"
337 "OSG::LightChunk::_sfDirection, OSG::LightChunk::_sfExponent,\n"
338 "OSG::LightChunk::_sfCutoff, OSG::LightChunk::_sfConstantAttenuation,\n"
339 "OSG::LightChunk::_sfLinearAttenuation,\n"
340 "OSG::LightChunk::_sfQuadraticAttenuation).\n"
341 "\t<Field\n"
342 "\t\tname=\"diffuse\"\n"
343 "\t\ttype=\"Color4f\"\n"
344 "\t\tcardinality=\"single\"\n"
345 "\t\tvisibility=\"external\"\n"
346 "\t\tdefaultValue=\"1.f,1.f,1.f,0.f\"\n"
347 "\t>\n"
348 "\tThe light's diffuse color.\n"
349 "\t</Field>\n"
350 "\t<Field\n"
351 "\t\tname=\"ambient\"\n"
352 "\t\ttype=\"Color4f\"\n"
353 "\t\tcardinality=\"single\"\n"
354 "\t\tvisibility=\"external\"\n"
355 "\t\tdefaultValue=\".1f,.1f,.1f,0.f\"\n"
356 "\t>\n"
357 "\tThe light's ambient color.\n"
358 "\t</Field>\n"
359 "\t<Field\n"
360 "\t\tname=\"specular\"\n"
361 "\t\ttype=\"Color4f\"\n"
362 "\t\tcardinality=\"single\"\n"
363 "\t\tvisibility=\"external\"\n"
364 "\t\tdefaultValue=\"1.f,1.f,1.f,0.f\"\n"
365 "\t>\n"
366 "\tThe light's specular color.\n"
367 "\t</Field>\n"
368 "\t<Field\n"
369 "\t\tname=\"position\"\n"
370 "\t\ttype=\"Vec4f\"\n"
371 "\t\tcardinality=\"single\"\n"
372 "\t\tvisibility=\"external\"\n"
373 "\t\tdefaultValue=\"0.f,-1.f,0.f,0.f\"\n"
374 "\t>\n"
375 "\tThe light's position.\n"
376 "\t</Field>\n"
377 "\t<Field\n"
378 "\t\tname=\"direction\"\n"
379 "\t\ttype=\"Vec3f\"\n"
380 "\t\tcardinality=\"single\"\n"
381 "\t\tvisibility=\"external\"\n"
382 "\t\tdefaultValue=\"0.f,0.f,1.f\"\n"
383 "\t>\n"
384 "\tThe light's direction (only for spotlights).\n"
385 "\t</Field>\n"
386 "\t<Field\n"
387 "\t\tname=\"exponent\"\n"
388 "\t\ttype=\"Real32\"\n"
389 "\t\tcardinality=\"single\"\n"
390 "\t\tvisibility=\"external\"\n"
391 "\t\tdefaultValue=\"2.f\"\n"
392 "\t>\n"
393 "\tThe light's spotlight exponent.\n"
394 "\t</Field>\n"
395 "\t<Field\n"
396 "\t\tname=\"cutoff\"\n"
397 "\t\ttype=\"Real32\"\n"
398 "\t\tcardinality=\"single\"\n"
399 "\t\tvisibility=\"external\"\n"
400 "\t\tdefaultValue=\"180.f\"\n"
401 "\t>\n"
402 "\tThe light's spotlight cutoff. As this chunk follows OpenGL conventions, this is the only angle in the system given in degrees.\n"
403 "\t</Field>\n"
404 "\t<Field\n"
405 "\t\tname=\"constantAttenuation\"\n"
406 "\t\ttype=\"Real32\"\n"
407 "\t\tcardinality=\"single\"\n"
408 "\t\tvisibility=\"external\"\n"
409 "\t\tdefaultValue=\"1.f\"\n"
410 "\t>\n"
411 "\tThe light's constant attenuation.\n"
412 "\t</Field>\n"
413 "\t<Field\n"
414 "\t\tname=\"linearAttenuation\"\n"
415 "\t\ttype=\"Real32\"\n"
416 "\t\tcardinality=\"single\"\n"
417 "\t\tvisibility=\"external\"\n"
418 "\t\tdefaultValue=\"0.f\"\n"
419 "\t>\n"
420 "\tThe light's linear attenuation.\n"
421 "\t</Field>\n"
422 "\t<Field\n"
423 "\t\tname=\"quadraticAttenuation\"\n"
424 "\t\ttype=\"Real32\"\n"
425 "\t\tcardinality=\"single\"\n"
426 "\t\tvisibility=\"external\"\n"
427 "\t\tdefaultValue=\"0.f\"\n"
428 "\t>\n"
429 "\tThe light's quadratic attenuation.\n"
430 "\t</Field>\n"
431 "\t<Field\n"
432 "\t\tname=\"beacon\"\n"
433 "\t\ttype=\"Node\"\n"
434 " category=\"weakpointer\"\n"
435 "\t\tcardinality=\"single\"\n"
436 "\t\tvisibility=\"external\"\n"
437 "\t\tdefaultValue=\"NULL\"\n"
438 "\t\taccess=\"public\"\n"
439 "\t>\n"
440 "\t</Field>\n"
441 "</FieldContainer>\n",
442 "See \\ref PageSystemLightChunk for a description.\n"
443 "\n"
444 "The light chunk contains the parameter set for a single light source. It's taken\n"
445 "straight from the glLight() manpage.\n"
446 "\n"
447 "This chunk wraps glLight() (OSG::LightChunk::_sfAmbient,\n"
448 "OSG::LightChunk::_sfDiffuse, OSG::LightChunk::_sfSpecular,\n"
449 "OSG::LightChunk::_sfEmission, OSG::LightChunk::_sfPosition,\n"
450 "OSG::LightChunk::_sfDirection, OSG::LightChunk::_sfExponent,\n"
451 "OSG::LightChunk::_sfCutoff, OSG::LightChunk::_sfConstantAttenuation,\n"
452 "OSG::LightChunk::_sfLinearAttenuation,\n"
453 "OSG::LightChunk::_sfQuadraticAttenuation).\n"
456 /*------------------------------ get -----------------------------------*/
458 FieldContainerType &LightChunkBase::getType(void)
460 return _type;
463 const FieldContainerType &LightChunkBase::getType(void) const
465 return _type;
468 UInt32 LightChunkBase::getContainerSize(void) const
470 return sizeof(LightChunk);
473 /*------------------------- decorator get ------------------------------*/
476 SFColor4f *LightChunkBase::editSFDiffuse(void)
478 editSField(DiffuseFieldMask);
480 return &_sfDiffuse;
483 const SFColor4f *LightChunkBase::getSFDiffuse(void) const
485 return &_sfDiffuse;
489 SFColor4f *LightChunkBase::editSFAmbient(void)
491 editSField(AmbientFieldMask);
493 return &_sfAmbient;
496 const SFColor4f *LightChunkBase::getSFAmbient(void) const
498 return &_sfAmbient;
502 SFColor4f *LightChunkBase::editSFSpecular(void)
504 editSField(SpecularFieldMask);
506 return &_sfSpecular;
509 const SFColor4f *LightChunkBase::getSFSpecular(void) const
511 return &_sfSpecular;
515 SFVec4f *LightChunkBase::editSFPosition(void)
517 editSField(PositionFieldMask);
519 return &_sfPosition;
522 const SFVec4f *LightChunkBase::getSFPosition(void) const
524 return &_sfPosition;
528 SFVec3f *LightChunkBase::editSFDirection(void)
530 editSField(DirectionFieldMask);
532 return &_sfDirection;
535 const SFVec3f *LightChunkBase::getSFDirection(void) const
537 return &_sfDirection;
541 SFReal32 *LightChunkBase::editSFExponent(void)
543 editSField(ExponentFieldMask);
545 return &_sfExponent;
548 const SFReal32 *LightChunkBase::getSFExponent(void) const
550 return &_sfExponent;
554 SFReal32 *LightChunkBase::editSFCutoff(void)
556 editSField(CutoffFieldMask);
558 return &_sfCutoff;
561 const SFReal32 *LightChunkBase::getSFCutoff(void) const
563 return &_sfCutoff;
567 SFReal32 *LightChunkBase::editSFConstantAttenuation(void)
569 editSField(ConstantAttenuationFieldMask);
571 return &_sfConstantAttenuation;
574 const SFReal32 *LightChunkBase::getSFConstantAttenuation(void) const
576 return &_sfConstantAttenuation;
580 SFReal32 *LightChunkBase::editSFLinearAttenuation(void)
582 editSField(LinearAttenuationFieldMask);
584 return &_sfLinearAttenuation;
587 const SFReal32 *LightChunkBase::getSFLinearAttenuation(void) const
589 return &_sfLinearAttenuation;
593 SFReal32 *LightChunkBase::editSFQuadraticAttenuation(void)
595 editSField(QuadraticAttenuationFieldMask);
597 return &_sfQuadraticAttenuation;
600 const SFReal32 *LightChunkBase::getSFQuadraticAttenuation(void) const
602 return &_sfQuadraticAttenuation;
606 //! Get the LightChunk::_sfBeacon field.
607 const SFWeakNodePtr *LightChunkBase::getSFBeacon(void) const
609 return &_sfBeacon;
612 SFWeakNodePtr *LightChunkBase::editSFBeacon (void)
614 editSField(BeaconFieldMask);
616 return &_sfBeacon;
619 //! Get the value of the LightChunk::_sfBeacon field.
620 Node * LightChunkBase::getBeacon(void) const
622 return _sfBeacon.getValue();
625 //! Set the value of the LightChunk::_sfBeacon field.
626 void LightChunkBase::setBeacon(Node * const value)
628 editSField(BeaconFieldMask);
630 _sfBeacon.setValue(value);
638 /*------------------------------ access -----------------------------------*/
640 SizeT LightChunkBase::getBinSize(ConstFieldMaskArg whichField)
642 SizeT returnValue = Inherited::getBinSize(whichField);
644 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
646 returnValue += _sfDiffuse.getBinSize();
648 if(FieldBits::NoField != (AmbientFieldMask & whichField))
650 returnValue += _sfAmbient.getBinSize();
652 if(FieldBits::NoField != (SpecularFieldMask & whichField))
654 returnValue += _sfSpecular.getBinSize();
656 if(FieldBits::NoField != (PositionFieldMask & whichField))
658 returnValue += _sfPosition.getBinSize();
660 if(FieldBits::NoField != (DirectionFieldMask & whichField))
662 returnValue += _sfDirection.getBinSize();
664 if(FieldBits::NoField != (ExponentFieldMask & whichField))
666 returnValue += _sfExponent.getBinSize();
668 if(FieldBits::NoField != (CutoffFieldMask & whichField))
670 returnValue += _sfCutoff.getBinSize();
672 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
674 returnValue += _sfConstantAttenuation.getBinSize();
676 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
678 returnValue += _sfLinearAttenuation.getBinSize();
680 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
682 returnValue += _sfQuadraticAttenuation.getBinSize();
684 if(FieldBits::NoField != (BeaconFieldMask & whichField))
686 returnValue += _sfBeacon.getBinSize();
689 return returnValue;
692 void LightChunkBase::copyToBin(BinaryDataHandler &pMem,
693 ConstFieldMaskArg whichField)
695 Inherited::copyToBin(pMem, whichField);
697 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
699 _sfDiffuse.copyToBin(pMem);
701 if(FieldBits::NoField != (AmbientFieldMask & whichField))
703 _sfAmbient.copyToBin(pMem);
705 if(FieldBits::NoField != (SpecularFieldMask & whichField))
707 _sfSpecular.copyToBin(pMem);
709 if(FieldBits::NoField != (PositionFieldMask & whichField))
711 _sfPosition.copyToBin(pMem);
713 if(FieldBits::NoField != (DirectionFieldMask & whichField))
715 _sfDirection.copyToBin(pMem);
717 if(FieldBits::NoField != (ExponentFieldMask & whichField))
719 _sfExponent.copyToBin(pMem);
721 if(FieldBits::NoField != (CutoffFieldMask & whichField))
723 _sfCutoff.copyToBin(pMem);
725 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
727 _sfConstantAttenuation.copyToBin(pMem);
729 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
731 _sfLinearAttenuation.copyToBin(pMem);
733 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
735 _sfQuadraticAttenuation.copyToBin(pMem);
737 if(FieldBits::NoField != (BeaconFieldMask & whichField))
739 _sfBeacon.copyToBin(pMem);
743 void LightChunkBase::copyFromBin(BinaryDataHandler &pMem,
744 ConstFieldMaskArg whichField)
746 Inherited::copyFromBin(pMem, whichField);
748 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
750 editSField(DiffuseFieldMask);
751 _sfDiffuse.copyFromBin(pMem);
753 if(FieldBits::NoField != (AmbientFieldMask & whichField))
755 editSField(AmbientFieldMask);
756 _sfAmbient.copyFromBin(pMem);
758 if(FieldBits::NoField != (SpecularFieldMask & whichField))
760 editSField(SpecularFieldMask);
761 _sfSpecular.copyFromBin(pMem);
763 if(FieldBits::NoField != (PositionFieldMask & whichField))
765 editSField(PositionFieldMask);
766 _sfPosition.copyFromBin(pMem);
768 if(FieldBits::NoField != (DirectionFieldMask & whichField))
770 editSField(DirectionFieldMask);
771 _sfDirection.copyFromBin(pMem);
773 if(FieldBits::NoField != (ExponentFieldMask & whichField))
775 editSField(ExponentFieldMask);
776 _sfExponent.copyFromBin(pMem);
778 if(FieldBits::NoField != (CutoffFieldMask & whichField))
780 editSField(CutoffFieldMask);
781 _sfCutoff.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 != (BeaconFieldMask & whichField))
800 editSField(BeaconFieldMask);
801 _sfBeacon.copyFromBin(pMem);
805 //! create a new instance of the class
806 LightChunkTransitPtr LightChunkBase::createLocal(BitVector bFlags)
808 LightChunkTransitPtr fc;
810 if(getClassType().getPrototype() != NULL)
812 FieldContainerTransitPtr tmpPtr =
813 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
815 fc = dynamic_pointer_cast<LightChunk>(tmpPtr);
818 return fc;
821 //! create a new instance of the class, copy the container flags
822 LightChunkTransitPtr LightChunkBase::createDependent(BitVector bFlags)
824 LightChunkTransitPtr fc;
826 if(getClassType().getPrototype() != NULL)
828 FieldContainerTransitPtr tmpPtr =
829 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
831 fc = dynamic_pointer_cast<LightChunk>(tmpPtr);
834 return fc;
837 //! create a new instance of the class
838 LightChunkTransitPtr LightChunkBase::create(void)
840 LightChunkTransitPtr fc;
842 if(getClassType().getPrototype() != NULL)
844 FieldContainerTransitPtr tmpPtr =
845 getClassType().getPrototype()-> shallowCopy();
847 fc = dynamic_pointer_cast<LightChunk>(tmpPtr);
850 return fc;
853 LightChunk *LightChunkBase::createEmptyLocal(BitVector bFlags)
855 LightChunk *returnValue;
857 newPtr<LightChunk>(returnValue, bFlags);
859 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
861 return returnValue;
864 //! create an empty new instance of the class, do not copy the prototype
865 LightChunk *LightChunkBase::createEmpty(void)
867 LightChunk *returnValue;
869 newPtr<LightChunk>(returnValue, Thread::getCurrentLocalFlags());
871 returnValue->_pFieldFlags->_bNamespaceMask &=
872 ~Thread::getCurrentLocalFlags();
874 return returnValue;
878 FieldContainerTransitPtr LightChunkBase::shallowCopyLocal(
879 BitVector bFlags) const
881 LightChunk *tmpPtr;
883 newPtr(tmpPtr, dynamic_cast<const LightChunk *>(this), bFlags);
885 FieldContainerTransitPtr returnValue(tmpPtr);
887 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
889 return returnValue;
892 FieldContainerTransitPtr LightChunkBase::shallowCopyDependent(
893 BitVector bFlags) const
895 LightChunk *tmpPtr;
897 newPtr(tmpPtr, dynamic_cast<const LightChunk *>(this), ~bFlags);
899 FieldContainerTransitPtr returnValue(tmpPtr);
901 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
903 return returnValue;
906 FieldContainerTransitPtr LightChunkBase::shallowCopy(void) const
908 LightChunk *tmpPtr;
910 newPtr(tmpPtr,
911 dynamic_cast<const LightChunk *>(this),
912 Thread::getCurrentLocalFlags());
914 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
916 FieldContainerTransitPtr returnValue(tmpPtr);
918 return returnValue;
924 /*------------------------- constructors ----------------------------------*/
926 LightChunkBase::LightChunkBase(void) :
927 Inherited(),
928 _sfDiffuse (Color4f(1.f,1.f,1.f,0.f)),
929 _sfAmbient (Color4f(.1f,.1f,.1f,0.f)),
930 _sfSpecular (Color4f(1.f,1.f,1.f,0.f)),
931 _sfPosition (Vec4f(0.f,-1.f,0.f,0.f)),
932 _sfDirection (Vec3f(0.f,0.f,1.f)),
933 _sfExponent (Real32(2.f)),
934 _sfCutoff (Real32(180.f)),
935 _sfConstantAttenuation (Real32(1.f)),
936 _sfLinearAttenuation (Real32(0.f)),
937 _sfQuadraticAttenuation (Real32(0.f)),
938 _sfBeacon (NULL)
942 LightChunkBase::LightChunkBase(const LightChunkBase &source) :
943 Inherited(source),
944 _sfDiffuse (source._sfDiffuse ),
945 _sfAmbient (source._sfAmbient ),
946 _sfSpecular (source._sfSpecular ),
947 _sfPosition (source._sfPosition ),
948 _sfDirection (source._sfDirection ),
949 _sfExponent (source._sfExponent ),
950 _sfCutoff (source._sfCutoff ),
951 _sfConstantAttenuation (source._sfConstantAttenuation ),
952 _sfLinearAttenuation (source._sfLinearAttenuation ),
953 _sfQuadraticAttenuation (source._sfQuadraticAttenuation ),
954 _sfBeacon (NULL)
959 /*-------------------------- destructors ----------------------------------*/
961 LightChunkBase::~LightChunkBase(void)
965 void LightChunkBase::onCreate(const LightChunk *source)
967 Inherited::onCreate(source);
969 if(source != NULL)
971 LightChunk *pThis = static_cast<LightChunk *>(this);
973 pThis->setBeacon(source->getBeacon());
977 GetFieldHandlePtr LightChunkBase::getHandleDiffuse (void) const
979 SFColor4f::GetHandlePtr returnValue(
980 new SFColor4f::GetHandle(
981 &_sfDiffuse,
982 this->getType().getFieldDesc(DiffuseFieldId),
983 const_cast<LightChunkBase *>(this)));
985 return returnValue;
988 EditFieldHandlePtr LightChunkBase::editHandleDiffuse (void)
990 SFColor4f::EditHandlePtr returnValue(
991 new SFColor4f::EditHandle(
992 &_sfDiffuse,
993 this->getType().getFieldDesc(DiffuseFieldId),
994 this));
997 editSField(DiffuseFieldMask);
999 return returnValue;
1002 GetFieldHandlePtr LightChunkBase::getHandleAmbient (void) const
1004 SFColor4f::GetHandlePtr returnValue(
1005 new SFColor4f::GetHandle(
1006 &_sfAmbient,
1007 this->getType().getFieldDesc(AmbientFieldId),
1008 const_cast<LightChunkBase *>(this)));
1010 return returnValue;
1013 EditFieldHandlePtr LightChunkBase::editHandleAmbient (void)
1015 SFColor4f::EditHandlePtr returnValue(
1016 new SFColor4f::EditHandle(
1017 &_sfAmbient,
1018 this->getType().getFieldDesc(AmbientFieldId),
1019 this));
1022 editSField(AmbientFieldMask);
1024 return returnValue;
1027 GetFieldHandlePtr LightChunkBase::getHandleSpecular (void) const
1029 SFColor4f::GetHandlePtr returnValue(
1030 new SFColor4f::GetHandle(
1031 &_sfSpecular,
1032 this->getType().getFieldDesc(SpecularFieldId),
1033 const_cast<LightChunkBase *>(this)));
1035 return returnValue;
1038 EditFieldHandlePtr LightChunkBase::editHandleSpecular (void)
1040 SFColor4f::EditHandlePtr returnValue(
1041 new SFColor4f::EditHandle(
1042 &_sfSpecular,
1043 this->getType().getFieldDesc(SpecularFieldId),
1044 this));
1047 editSField(SpecularFieldMask);
1049 return returnValue;
1052 GetFieldHandlePtr LightChunkBase::getHandlePosition (void) const
1054 SFVec4f::GetHandlePtr returnValue(
1055 new SFVec4f::GetHandle(
1056 &_sfPosition,
1057 this->getType().getFieldDesc(PositionFieldId),
1058 const_cast<LightChunkBase *>(this)));
1060 return returnValue;
1063 EditFieldHandlePtr LightChunkBase::editHandlePosition (void)
1065 SFVec4f::EditHandlePtr returnValue(
1066 new SFVec4f::EditHandle(
1067 &_sfPosition,
1068 this->getType().getFieldDesc(PositionFieldId),
1069 this));
1072 editSField(PositionFieldMask);
1074 return returnValue;
1077 GetFieldHandlePtr LightChunkBase::getHandleDirection (void) const
1079 SFVec3f::GetHandlePtr returnValue(
1080 new SFVec3f::GetHandle(
1081 &_sfDirection,
1082 this->getType().getFieldDesc(DirectionFieldId),
1083 const_cast<LightChunkBase *>(this)));
1085 return returnValue;
1088 EditFieldHandlePtr LightChunkBase::editHandleDirection (void)
1090 SFVec3f::EditHandlePtr returnValue(
1091 new SFVec3f::EditHandle(
1092 &_sfDirection,
1093 this->getType().getFieldDesc(DirectionFieldId),
1094 this));
1097 editSField(DirectionFieldMask);
1099 return returnValue;
1102 GetFieldHandlePtr LightChunkBase::getHandleExponent (void) const
1104 SFReal32::GetHandlePtr returnValue(
1105 new SFReal32::GetHandle(
1106 &_sfExponent,
1107 this->getType().getFieldDesc(ExponentFieldId),
1108 const_cast<LightChunkBase *>(this)));
1110 return returnValue;
1113 EditFieldHandlePtr LightChunkBase::editHandleExponent (void)
1115 SFReal32::EditHandlePtr returnValue(
1116 new SFReal32::EditHandle(
1117 &_sfExponent,
1118 this->getType().getFieldDesc(ExponentFieldId),
1119 this));
1122 editSField(ExponentFieldMask);
1124 return returnValue;
1127 GetFieldHandlePtr LightChunkBase::getHandleCutoff (void) const
1129 SFReal32::GetHandlePtr returnValue(
1130 new SFReal32::GetHandle(
1131 &_sfCutoff,
1132 this->getType().getFieldDesc(CutoffFieldId),
1133 const_cast<LightChunkBase *>(this)));
1135 return returnValue;
1138 EditFieldHandlePtr LightChunkBase::editHandleCutoff (void)
1140 SFReal32::EditHandlePtr returnValue(
1141 new SFReal32::EditHandle(
1142 &_sfCutoff,
1143 this->getType().getFieldDesc(CutoffFieldId),
1144 this));
1147 editSField(CutoffFieldMask);
1149 return returnValue;
1152 GetFieldHandlePtr LightChunkBase::getHandleConstantAttenuation (void) const
1154 SFReal32::GetHandlePtr returnValue(
1155 new SFReal32::GetHandle(
1156 &_sfConstantAttenuation,
1157 this->getType().getFieldDesc(ConstantAttenuationFieldId),
1158 const_cast<LightChunkBase *>(this)));
1160 return returnValue;
1163 EditFieldHandlePtr LightChunkBase::editHandleConstantAttenuation(void)
1165 SFReal32::EditHandlePtr returnValue(
1166 new SFReal32::EditHandle(
1167 &_sfConstantAttenuation,
1168 this->getType().getFieldDesc(ConstantAttenuationFieldId),
1169 this));
1172 editSField(ConstantAttenuationFieldMask);
1174 return returnValue;
1177 GetFieldHandlePtr LightChunkBase::getHandleLinearAttenuation (void) const
1179 SFReal32::GetHandlePtr returnValue(
1180 new SFReal32::GetHandle(
1181 &_sfLinearAttenuation,
1182 this->getType().getFieldDesc(LinearAttenuationFieldId),
1183 const_cast<LightChunkBase *>(this)));
1185 return returnValue;
1188 EditFieldHandlePtr LightChunkBase::editHandleLinearAttenuation(void)
1190 SFReal32::EditHandlePtr returnValue(
1191 new SFReal32::EditHandle(
1192 &_sfLinearAttenuation,
1193 this->getType().getFieldDesc(LinearAttenuationFieldId),
1194 this));
1197 editSField(LinearAttenuationFieldMask);
1199 return returnValue;
1202 GetFieldHandlePtr LightChunkBase::getHandleQuadraticAttenuation (void) const
1204 SFReal32::GetHandlePtr returnValue(
1205 new SFReal32::GetHandle(
1206 &_sfQuadraticAttenuation,
1207 this->getType().getFieldDesc(QuadraticAttenuationFieldId),
1208 const_cast<LightChunkBase *>(this)));
1210 return returnValue;
1213 EditFieldHandlePtr LightChunkBase::editHandleQuadraticAttenuation(void)
1215 SFReal32::EditHandlePtr returnValue(
1216 new SFReal32::EditHandle(
1217 &_sfQuadraticAttenuation,
1218 this->getType().getFieldDesc(QuadraticAttenuationFieldId),
1219 this));
1222 editSField(QuadraticAttenuationFieldMask);
1224 return returnValue;
1227 GetFieldHandlePtr LightChunkBase::getHandleBeacon (void) const
1229 SFWeakNodePtr::GetHandlePtr returnValue(
1230 new SFWeakNodePtr::GetHandle(
1231 &_sfBeacon,
1232 this->getType().getFieldDesc(BeaconFieldId),
1233 const_cast<LightChunkBase *>(this)));
1235 return returnValue;
1238 EditFieldHandlePtr LightChunkBase::editHandleBeacon (void)
1240 SFWeakNodePtr::EditHandlePtr returnValue(
1241 new SFWeakNodePtr::EditHandle(
1242 &_sfBeacon,
1243 this->getType().getFieldDesc(BeaconFieldId),
1244 this));
1246 returnValue->setSetMethod(
1247 boost::bind(&LightChunk::setBeacon,
1248 static_cast<LightChunk *>(this), _1));
1250 editSField(BeaconFieldMask);
1252 return returnValue;
1256 #ifdef OSG_MT_CPTR_ASPECT
1257 void LightChunkBase::execSyncV( FieldContainer &oFrom,
1258 ConstFieldMaskArg whichField,
1259 AspectOffsetStore &oOffsets,
1260 ConstFieldMaskArg syncMode,
1261 const UInt32 uiSyncInfo)
1263 LightChunk *pThis = static_cast<LightChunk *>(this);
1265 pThis->execSync(static_cast<LightChunk *>(&oFrom),
1266 whichField,
1267 oOffsets,
1268 syncMode,
1269 uiSyncInfo);
1271 #endif
1274 #ifdef OSG_MT_CPTR_ASPECT
1275 FieldContainer *LightChunkBase::createAspectCopy(
1276 const FieldContainer *pRefAspect) const
1278 LightChunk *returnValue;
1280 newAspectCopy(returnValue,
1281 dynamic_cast<const LightChunk *>(pRefAspect),
1282 dynamic_cast<const LightChunk *>(this));
1284 return returnValue;
1286 #endif
1288 void LightChunkBase::resolveLinks(void)
1290 Inherited::resolveLinks();
1292 static_cast<LightChunk *>(this)->setBeacon(NULL);
1298 OSG_END_NAMESPACE