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"
66 #include "OSGSpotLightBase.h"
67 #include "OSGSpotLight.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::SpotLight
78 SpotLight is a located lightsource. The position of the light source
79 (in the beacon's coordinate system) is defined by the \c position
80 attribute, its direction by the \c direction attribute. The spot has an
81 exponential fallof, controlled by the \c spotExponent attribute and a
82 maximum opening angle, defined by the \c spotCutOff attribute.
83 The influence of the light diminishes with distance, controlled
84 by the \c constantAttenuation, \c linearAttenuation and \c
85 quadraticAttenuation attributes.
88 /***************************************************************************\
89 * Field Documentation *
90 \***************************************************************************/
92 /*! \var Vec3f SpotLightBase::_sfDirection
96 /*! \var Real32 SpotLightBase::_sfSpotExponent
97 The drop-off exponent of the spotlight.
100 /*! \var Real32 SpotLightBase::_sfSpotCutOff
101 The cut-off angle of the spotlight (in radians, not degrees!).
105 /***************************************************************************\
106 * FieldType/FieldTrait Instantiation *
107 \***************************************************************************/
109 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
110 PointerType FieldTraits
<SpotLight
*, nsOSG
>::_type(
113 SpotLight::getClassType(),
117 OSG_FIELDTRAITS_GETTYPE_NS(SpotLight
*, nsOSG
)
119 /***************************************************************************\
120 * Field Description *
121 \***************************************************************************/
123 void SpotLightBase::classDescInserter(TypeObject
&oType
)
125 FieldDescriptionBase
*pDesc
= NULL
;
128 pDesc
= new SFVec3f::Description(
129 SFVec3f::getClassType(),
132 DirectionFieldId
, DirectionFieldMask
,
134 (Field::SFDefaultFlags
| Field::FStdAccess
),
135 static_cast<FieldEditMethodSig
>(&SpotLight::editHandleDirection
),
136 static_cast<FieldGetMethodSig
>(&SpotLight::getHandleDirection
));
138 oType
.addInitialDesc(pDesc
);
140 pDesc
= new SFReal32::Description(
141 SFReal32::getClassType(),
143 "The drop-off exponent of the spotlight.\n",
144 SpotExponentFieldId
, SpotExponentFieldMask
,
146 (Field::SFDefaultFlags
| Field::FStdAccess
),
147 static_cast<FieldEditMethodSig
>(&SpotLight::editHandleSpotExponent
),
148 static_cast<FieldGetMethodSig
>(&SpotLight::getHandleSpotExponent
));
150 oType
.addInitialDesc(pDesc
);
152 pDesc
= new SFReal32::Description(
153 SFReal32::getClassType(),
155 "The cut-off angle of the spotlight (in radians, not degrees!).\n",
156 SpotCutOffFieldId
, SpotCutOffFieldMask
,
158 (Field::SFDefaultFlags
| Field::FStdAccess
),
159 static_cast<FieldEditMethodSig
>(&SpotLight::editHandleSpotCutOff
),
160 static_cast<FieldGetMethodSig
>(&SpotLight::getHandleSpotCutOff
));
162 oType
.addInitialDesc(pDesc
);
166 SpotLightBase::TypeObject
SpotLightBase::_type(
167 SpotLightBase::getClassname(),
168 Inherited::getClassname(),
171 reinterpret_cast<PrototypeCreateF
>(&SpotLightBase::createEmptyLocal
),
172 reinterpret_cast<InitContainerF
>(&SpotLight::initMethod
),
173 reinterpret_cast<ExitContainerF
>(&SpotLight::exitMethod
),
174 reinterpret_cast<InitalInsertDescFunc
>(
175 reinterpret_cast<void *>(&SpotLight::classDescInserter
)),
178 "<?xml version=\"1.0\" ?>\n"
181 " name=\"SpotLight\"\n"
182 " parent=\"PointLight\"\n"
183 " library=\"Group\"\n"
184 " structure=\"concrete\"\n"
185 " pointerfieldtypes=\"none\"\n"
186 " systemcomponent=\"true\"\n"
187 " parentsystemcomponent=\"true\"\n"
188 " isNodeCore=\"true\"\n"
189 " docGroupBase=\"GrpGroupLight\"\n"
191 " SpotLight is a located lightsource. The position of the light source\n"
192 " (in the beacon's coordinate system) is defined by the \\c position\n"
193 " attribute, its direction by the \\c direction attribute. The spot has an\n"
194 " exponential fallof, controlled by the \\c spotExponent attribute and a\n"
195 " maximum opening angle, defined by the \\c spotCutOff attribute.\n"
196 " The influence of the light diminishes with distance, controlled\n"
197 " by the \\c constantAttenuation, \\c linearAttenuation and \\c\n"
198 " quadraticAttenuation attributes.\n"
200 " name=\"direction\"\n"
202 " cardinality=\"single\"\n"
203 " visibility=\"external\"\n"
204 " defaultValue=\"0.f,0.f,1.f\"\n"
208 " name=\"spotExponent\"\n"
210 " cardinality=\"single\"\n"
211 " visibility=\"external\"\n"
212 " defaultValue=\"0.1f\"\n"
214 " The drop-off exponent of the spotlight.\n"
217 " name=\"spotCutOff\"\n"
219 " cardinality=\"single\"\n"
220 " visibility=\"external\"\n"
221 " defaultValue=\"1.0472f\"\n"
223 " The cut-off angle of the spotlight (in radians, not degrees!).\n"
225 "</FieldContainer>\n",
226 "SpotLight is a located lightsource. The position of the light source\n"
227 "(in the beacon's coordinate system) is defined by the \\c position\n"
228 "attribute, its direction by the \\c direction attribute. The spot has an\n"
229 "exponential fallof, controlled by the \\c spotExponent attribute and a\n"
230 "maximum opening angle, defined by the \\c spotCutOff attribute.\n"
231 "The influence of the light diminishes with distance, controlled\n"
232 "by the \\c constantAttenuation, \\c linearAttenuation and \\c\n"
233 "quadraticAttenuation attributes.\n"
236 /*------------------------------ get -----------------------------------*/
238 FieldContainerType
&SpotLightBase::getType(void)
243 const FieldContainerType
&SpotLightBase::getType(void) const
248 UInt32
SpotLightBase::getContainerSize(void) const
250 return sizeof(SpotLight
);
253 /*------------------------- decorator get ------------------------------*/
256 SFVec3f
*SpotLightBase::editSFDirection(void)
258 editSField(DirectionFieldMask
);
260 return &_sfDirection
;
263 const SFVec3f
*SpotLightBase::getSFDirection(void) const
265 return &_sfDirection
;
269 SFReal32
*SpotLightBase::editSFSpotExponent(void)
271 editSField(SpotExponentFieldMask
);
273 return &_sfSpotExponent
;
276 const SFReal32
*SpotLightBase::getSFSpotExponent(void) const
278 return &_sfSpotExponent
;
282 SFReal32
*SpotLightBase::editSFSpotCutOff(void)
284 editSField(SpotCutOffFieldMask
);
286 return &_sfSpotCutOff
;
289 const SFReal32
*SpotLightBase::getSFSpotCutOff(void) const
291 return &_sfSpotCutOff
;
299 /*------------------------------ access -----------------------------------*/
301 SizeT
SpotLightBase::getBinSize(ConstFieldMaskArg whichField
)
303 SizeT returnValue
= Inherited::getBinSize(whichField
);
305 if(FieldBits::NoField
!= (DirectionFieldMask
& whichField
))
307 returnValue
+= _sfDirection
.getBinSize();
309 if(FieldBits::NoField
!= (SpotExponentFieldMask
& whichField
))
311 returnValue
+= _sfSpotExponent
.getBinSize();
313 if(FieldBits::NoField
!= (SpotCutOffFieldMask
& whichField
))
315 returnValue
+= _sfSpotCutOff
.getBinSize();
321 void SpotLightBase::copyToBin(BinaryDataHandler
&pMem
,
322 ConstFieldMaskArg whichField
)
324 Inherited::copyToBin(pMem
, whichField
);
326 if(FieldBits::NoField
!= (DirectionFieldMask
& whichField
))
328 _sfDirection
.copyToBin(pMem
);
330 if(FieldBits::NoField
!= (SpotExponentFieldMask
& whichField
))
332 _sfSpotExponent
.copyToBin(pMem
);
334 if(FieldBits::NoField
!= (SpotCutOffFieldMask
& whichField
))
336 _sfSpotCutOff
.copyToBin(pMem
);
340 void SpotLightBase::copyFromBin(BinaryDataHandler
&pMem
,
341 ConstFieldMaskArg whichField
)
343 Inherited::copyFromBin(pMem
, whichField
);
345 if(FieldBits::NoField
!= (DirectionFieldMask
& whichField
))
347 editSField(DirectionFieldMask
);
348 _sfDirection
.copyFromBin(pMem
);
350 if(FieldBits::NoField
!= (SpotExponentFieldMask
& whichField
))
352 editSField(SpotExponentFieldMask
);
353 _sfSpotExponent
.copyFromBin(pMem
);
355 if(FieldBits::NoField
!= (SpotCutOffFieldMask
& whichField
))
357 editSField(SpotCutOffFieldMask
);
358 _sfSpotCutOff
.copyFromBin(pMem
);
362 //! create a new instance of the class
363 SpotLightTransitPtr
SpotLightBase::createLocal(BitVector bFlags
)
365 SpotLightTransitPtr fc
;
367 if(getClassType().getPrototype() != NULL
)
369 FieldContainerTransitPtr tmpPtr
=
370 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
372 fc
= dynamic_pointer_cast
<SpotLight
>(tmpPtr
);
378 //! create a new instance of the class, copy the container flags
379 SpotLightTransitPtr
SpotLightBase::createDependent(BitVector bFlags
)
381 SpotLightTransitPtr fc
;
383 if(getClassType().getPrototype() != NULL
)
385 FieldContainerTransitPtr tmpPtr
=
386 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
388 fc
= dynamic_pointer_cast
<SpotLight
>(tmpPtr
);
394 //! create a new instance of the class
395 SpotLightTransitPtr
SpotLightBase::create(void)
397 SpotLightTransitPtr fc
;
399 if(getClassType().getPrototype() != NULL
)
401 FieldContainerTransitPtr tmpPtr
=
402 getClassType().getPrototype()-> shallowCopy();
404 fc
= dynamic_pointer_cast
<SpotLight
>(tmpPtr
);
410 SpotLight
*SpotLightBase::createEmptyLocal(BitVector bFlags
)
412 SpotLight
*returnValue
;
414 newPtr
<SpotLight
>(returnValue
, bFlags
);
416 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
421 //! create an empty new instance of the class, do not copy the prototype
422 SpotLight
*SpotLightBase::createEmpty(void)
424 SpotLight
*returnValue
;
426 newPtr
<SpotLight
>(returnValue
, Thread::getCurrentLocalFlags());
428 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
429 ~Thread::getCurrentLocalFlags();
435 FieldContainerTransitPtr
SpotLightBase::shallowCopyLocal(
436 BitVector bFlags
) const
440 newPtr(tmpPtr
, dynamic_cast<const SpotLight
*>(this), bFlags
);
442 FieldContainerTransitPtr
returnValue(tmpPtr
);
444 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
449 FieldContainerTransitPtr
SpotLightBase::shallowCopyDependent(
450 BitVector bFlags
) const
454 newPtr(tmpPtr
, dynamic_cast<const SpotLight
*>(this), ~bFlags
);
456 FieldContainerTransitPtr
returnValue(tmpPtr
);
458 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
463 FieldContainerTransitPtr
SpotLightBase::shallowCopy(void) const
468 dynamic_cast<const SpotLight
*>(this),
469 Thread::getCurrentLocalFlags());
471 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
473 FieldContainerTransitPtr
returnValue(tmpPtr
);
481 /*------------------------- constructors ----------------------------------*/
483 SpotLightBase::SpotLightBase(void) :
485 _sfDirection (Vec3f(0.f
,0.f
,1.f
)),
486 _sfSpotExponent (Real32(0.1f
)),
487 _sfSpotCutOff (Real32(1.0472f
))
491 SpotLightBase::SpotLightBase(const SpotLightBase
&source
) :
493 _sfDirection (source
._sfDirection
),
494 _sfSpotExponent (source
._sfSpotExponent
),
495 _sfSpotCutOff (source
._sfSpotCutOff
)
500 /*-------------------------- destructors ----------------------------------*/
502 SpotLightBase::~SpotLightBase(void)
507 GetFieldHandlePtr
SpotLightBase::getHandleDirection (void) const
509 SFVec3f::GetHandlePtr
returnValue(
510 new SFVec3f::GetHandle(
512 this->getType().getFieldDesc(DirectionFieldId
),
513 const_cast<SpotLightBase
*>(this)));
518 EditFieldHandlePtr
SpotLightBase::editHandleDirection (void)
520 SFVec3f::EditHandlePtr
returnValue(
521 new SFVec3f::EditHandle(
523 this->getType().getFieldDesc(DirectionFieldId
),
527 editSField(DirectionFieldMask
);
532 GetFieldHandlePtr
SpotLightBase::getHandleSpotExponent (void) const
534 SFReal32::GetHandlePtr
returnValue(
535 new SFReal32::GetHandle(
537 this->getType().getFieldDesc(SpotExponentFieldId
),
538 const_cast<SpotLightBase
*>(this)));
543 EditFieldHandlePtr
SpotLightBase::editHandleSpotExponent (void)
545 SFReal32::EditHandlePtr
returnValue(
546 new SFReal32::EditHandle(
548 this->getType().getFieldDesc(SpotExponentFieldId
),
552 editSField(SpotExponentFieldMask
);
557 GetFieldHandlePtr
SpotLightBase::getHandleSpotCutOff (void) const
559 SFReal32::GetHandlePtr
returnValue(
560 new SFReal32::GetHandle(
562 this->getType().getFieldDesc(SpotCutOffFieldId
),
563 const_cast<SpotLightBase
*>(this)));
568 EditFieldHandlePtr
SpotLightBase::editHandleSpotCutOff (void)
570 SFReal32::EditHandlePtr
returnValue(
571 new SFReal32::EditHandle(
573 this->getType().getFieldDesc(SpotCutOffFieldId
),
577 editSField(SpotCutOffFieldMask
);
583 #ifdef OSG_MT_CPTR_ASPECT
584 void SpotLightBase::execSyncV( FieldContainer
&oFrom
,
585 ConstFieldMaskArg whichField
,
586 AspectOffsetStore
&oOffsets
,
587 ConstFieldMaskArg syncMode
,
588 const UInt32 uiSyncInfo
)
590 SpotLight
*pThis
= static_cast<SpotLight
*>(this);
592 pThis
->execSync(static_cast<SpotLight
*>(&oFrom
),
601 #ifdef OSG_MT_CPTR_ASPECT
602 FieldContainer
*SpotLightBase::createAspectCopy(
603 const FieldContainer
*pRefAspect
) const
605 SpotLight
*returnValue
;
607 newAspectCopy(returnValue
,
608 dynamic_cast<const SpotLight
*>(pRefAspect
),
609 dynamic_cast<const SpotLight
*>(this));
615 void SpotLightBase::resolveLinks(void)
617 Inherited::resolveLinks();