fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Light / OSGSpotLightBase.cpp
blob25c9858ac7f8a48ad44d9e716cf29805e93fa601
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 SpotLight!
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"
66 #include "OSGSpotLightBase.h"
67 #include "OSGSpotLight.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
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(
111 "SpotLightPtr",
112 "PointLightPtr",
113 SpotLight::getClassType(),
114 nsOSG);
115 #endif
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(),
130 "direction",
132 DirectionFieldId, DirectionFieldMask,
133 false,
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(),
142 "spotExponent",
143 "The drop-off exponent of the spotlight.\n",
144 SpotExponentFieldId, SpotExponentFieldMask,
145 false,
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(),
154 "spotCutOff",
155 "The cut-off angle of the spotlight (in radians, not degrees!).\n",
156 SpotCutOffFieldId, SpotCutOffFieldMask,
157 false,
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(),
169 "NULL",
170 nsOSG, //Namespace
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)),
176 false,
178 "<?xml version=\"1.0\" ?>\n"
179 "\n"
180 "<FieldContainer\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"
190 " >\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"
199 " <Field\n"
200 " name=\"direction\"\n"
201 " type=\"Vec3f\"\n"
202 " cardinality=\"single\"\n"
203 " visibility=\"external\"\n"
204 " defaultValue=\"0.f,0.f,1.f\"\n"
205 " >\n"
206 " </Field>\n"
207 " <Field\n"
208 " name=\"spotExponent\"\n"
209 " type=\"Real32\"\n"
210 " cardinality=\"single\"\n"
211 " visibility=\"external\"\n"
212 " defaultValue=\"0.1f\"\n"
213 " >\n"
214 " The drop-off exponent of the spotlight.\n"
215 " </Field>\n"
216 " <Field\n"
217 " name=\"spotCutOff\"\n"
218 " type=\"Real32\"\n"
219 " cardinality=\"single\"\n"
220 " visibility=\"external\"\n"
221 " defaultValue=\"1.0472f\"\n"
222 " >\n"
223 " The cut-off angle of the spotlight (in radians, not degrees!).\n"
224 " </Field>\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)
240 return _type;
243 const FieldContainerType &SpotLightBase::getType(void) const
245 return _type;
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();
318 return returnValue;
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);
375 return fc;
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);
391 return fc;
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);
407 return fc;
410 SpotLight *SpotLightBase::createEmptyLocal(BitVector bFlags)
412 SpotLight *returnValue;
414 newPtr<SpotLight>(returnValue, bFlags);
416 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
418 return returnValue;
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();
431 return returnValue;
435 FieldContainerTransitPtr SpotLightBase::shallowCopyLocal(
436 BitVector bFlags) const
438 SpotLight *tmpPtr;
440 newPtr(tmpPtr, dynamic_cast<const SpotLight *>(this), bFlags);
442 FieldContainerTransitPtr returnValue(tmpPtr);
444 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
446 return returnValue;
449 FieldContainerTransitPtr SpotLightBase::shallowCopyDependent(
450 BitVector bFlags) const
452 SpotLight *tmpPtr;
454 newPtr(tmpPtr, dynamic_cast<const SpotLight *>(this), ~bFlags);
456 FieldContainerTransitPtr returnValue(tmpPtr);
458 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
460 return returnValue;
463 FieldContainerTransitPtr SpotLightBase::shallowCopy(void) const
465 SpotLight *tmpPtr;
467 newPtr(tmpPtr,
468 dynamic_cast<const SpotLight *>(this),
469 Thread::getCurrentLocalFlags());
471 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
473 FieldContainerTransitPtr returnValue(tmpPtr);
475 return returnValue;
481 /*------------------------- constructors ----------------------------------*/
483 SpotLightBase::SpotLightBase(void) :
484 Inherited(),
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) :
492 Inherited(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(
511 &_sfDirection,
512 this->getType().getFieldDesc(DirectionFieldId),
513 const_cast<SpotLightBase *>(this)));
515 return returnValue;
518 EditFieldHandlePtr SpotLightBase::editHandleDirection (void)
520 SFVec3f::EditHandlePtr returnValue(
521 new SFVec3f::EditHandle(
522 &_sfDirection,
523 this->getType().getFieldDesc(DirectionFieldId),
524 this));
527 editSField(DirectionFieldMask);
529 return returnValue;
532 GetFieldHandlePtr SpotLightBase::getHandleSpotExponent (void) const
534 SFReal32::GetHandlePtr returnValue(
535 new SFReal32::GetHandle(
536 &_sfSpotExponent,
537 this->getType().getFieldDesc(SpotExponentFieldId),
538 const_cast<SpotLightBase *>(this)));
540 return returnValue;
543 EditFieldHandlePtr SpotLightBase::editHandleSpotExponent (void)
545 SFReal32::EditHandlePtr returnValue(
546 new SFReal32::EditHandle(
547 &_sfSpotExponent,
548 this->getType().getFieldDesc(SpotExponentFieldId),
549 this));
552 editSField(SpotExponentFieldMask);
554 return returnValue;
557 GetFieldHandlePtr SpotLightBase::getHandleSpotCutOff (void) const
559 SFReal32::GetHandlePtr returnValue(
560 new SFReal32::GetHandle(
561 &_sfSpotCutOff,
562 this->getType().getFieldDesc(SpotCutOffFieldId),
563 const_cast<SpotLightBase *>(this)));
565 return returnValue;
568 EditFieldHandlePtr SpotLightBase::editHandleSpotCutOff (void)
570 SFReal32::EditHandlePtr returnValue(
571 new SFReal32::EditHandle(
572 &_sfSpotCutOff,
573 this->getType().getFieldDesc(SpotCutOffFieldId),
574 this));
577 editSField(SpotCutOffFieldMask);
579 return returnValue;
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),
593 whichField,
594 oOffsets,
595 syncMode,
596 uiSyncInfo);
598 #endif
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));
611 return returnValue;
613 #endif
615 void SpotLightBase::resolveLinks(void)
617 Inherited::resolveLinks();
623 OSG_END_NAMESPACE