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 **
48 ** class ShadowMapEngine!
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
65 #include "OSGTextureObjChunk.h" // ShadowTexChunk Class
67 #include "OSGShadowMapEngineBase.h"
68 #include "OSGShadowMapEngine.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::ShadowMapEngine
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var TextureObjChunk * ShadowMapEngineBase::_sfShadowTexChunk
87 Holds the generated shadow texture. If you leave this field empty an
88 appropriate object will be created the first time the engine runs.
91 /*! \var Int32 ShadowMapEngineBase::_sfWidth
95 /*! \var Int32 ShadowMapEngineBase::_sfHeight
99 /*! \var Real32 ShadowMapEngineBase::_sfOffsetBias
103 /*! \var Real32 ShadowMapEngineBase::_sfOffsetFactor
107 /*! \var UInt32 ShadowMapEngineBase::_sfShadowTravMask
108 Traversal mask when generating the shadow map.
112 /***************************************************************************\
113 * FieldType/FieldTrait Instantiation *
114 \***************************************************************************/
116 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
117 PointerType FieldTraits
<ShadowMapEngine
*, nsOSG
>::_type(
118 "ShadowMapEnginePtr",
120 ShadowMapEngine::getClassType(),
124 OSG_FIELDTRAITS_GETTYPE_NS(ShadowMapEngine
*, nsOSG
)
126 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
130 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
134 /***************************************************************************\
135 * Field Description *
136 \***************************************************************************/
138 void ShadowMapEngineBase::classDescInserter(TypeObject
&oType
)
140 Inherited::classDescInserter(oType
);
142 FieldDescriptionBase
*pDesc
= NULL
;
145 pDesc
= new SFUnrecTextureObjChunkPtr::Description(
146 SFUnrecTextureObjChunkPtr::getClassType(),
148 "Holds the generated shadow texture. If you leave this field empty an\n"
149 "appropriate object will be created the first time the engine runs.\n",
150 ShadowTexChunkFieldId
, ShadowTexChunkFieldMask
,
152 (Field::SFDefaultFlags
| Field::FStdAccess
),
153 static_cast<FieldEditMethodSig
>(&ShadowMapEngine::editHandleShadowTexChunk
),
154 static_cast<FieldGetMethodSig
>(&ShadowMapEngine::getHandleShadowTexChunk
));
156 oType
.addInitialDesc(pDesc
);
158 pDesc
= new SFInt32::Description(
159 SFInt32::getClassType(),
162 WidthFieldId
, WidthFieldMask
,
164 (Field::SFDefaultFlags
| Field::FStdAccess
),
165 static_cast<FieldEditMethodSig
>(&ShadowMapEngine::editHandleWidth
),
166 static_cast<FieldGetMethodSig
>(&ShadowMapEngine::getHandleWidth
));
168 oType
.addInitialDesc(pDesc
);
170 pDesc
= new SFInt32::Description(
171 SFInt32::getClassType(),
174 HeightFieldId
, HeightFieldMask
,
176 (Field::SFDefaultFlags
| Field::FStdAccess
),
177 static_cast<FieldEditMethodSig
>(&ShadowMapEngine::editHandleHeight
),
178 static_cast<FieldGetMethodSig
>(&ShadowMapEngine::getHandleHeight
));
180 oType
.addInitialDesc(pDesc
);
182 pDesc
= new SFReal32::Description(
183 SFReal32::getClassType(),
186 OffsetBiasFieldId
, OffsetBiasFieldMask
,
188 (Field::SFDefaultFlags
| Field::FStdAccess
),
189 static_cast<FieldEditMethodSig
>(&ShadowMapEngine::editHandleOffsetBias
),
190 static_cast<FieldGetMethodSig
>(&ShadowMapEngine::getHandleOffsetBias
));
192 oType
.addInitialDesc(pDesc
);
194 pDesc
= new SFReal32::Description(
195 SFReal32::getClassType(),
198 OffsetFactorFieldId
, OffsetFactorFieldMask
,
200 (Field::SFDefaultFlags
| Field::FStdAccess
),
201 static_cast<FieldEditMethodSig
>(&ShadowMapEngine::editHandleOffsetFactor
),
202 static_cast<FieldGetMethodSig
>(&ShadowMapEngine::getHandleOffsetFactor
));
204 oType
.addInitialDesc(pDesc
);
206 pDesc
= new SFUInt32::Description(
207 SFUInt32::getClassType(),
209 "Traversal mask when generating the shadow map. \n",
210 ShadowTravMaskFieldId
, ShadowTravMaskFieldMask
,
212 (Field::SFDefaultFlags
| Field::FStdAccess
),
213 static_cast<FieldEditMethodSig
>(&ShadowMapEngine::editHandleShadowTravMask
),
214 static_cast<FieldGetMethodSig
>(&ShadowMapEngine::getHandleShadowTravMask
));
216 oType
.addInitialDesc(pDesc
);
220 ShadowMapEngineBase::TypeObject
ShadowMapEngineBase::_type(
221 ShadowMapEngineBase::getClassname(),
222 Inherited::getClassname(),
226 reinterpret_cast<InitContainerF
>(&ShadowMapEngine::initMethod
),
227 reinterpret_cast<ExitContainerF
>(&ShadowMapEngine::exitMethod
),
228 reinterpret_cast<InitalInsertDescFunc
>(
229 reinterpret_cast<void *>(&ShadowMapEngine::classDescInserter
)),
232 "<?xml version=\"1.0\" ?>\n"
235 " name=\"ShadowMapEngine\"\n"
236 " parent=\"LightEngine\"\n"
237 " mixinparent=\"ShadowMapEngineParent\"\n"
238 " library=\"Group\"\n"
239 " structure=\"abstract\"\n"
240 " pointerfieldtypes=\"both\"\n"
241 " systemcomponent=\"true\"\n"
242 " parentsystemcomponent=\"true\"\n"
243 " isNodeCore=\"false\"\n"
244 " docGroupBase=\"GrpGroupLightShadowBase\"\n"
247 " name=\"shadowTexChunk\"\n"
248 " category=\"pointer\"\n"
249 " type=\"TextureObjChunk\"\n"
250 " cardinality=\"single\"\n"
251 " visibility=\"external\"\n"
252 " defaultValue=\"NULL\"\n"
253 " access=\"public\"\n"
255 " Holds the generated shadow texture. If you leave this field empty an\n"
256 " appropriate object will be created the first time the engine runs.\n"
259 "\t name=\"width\"\n"
260 "\t type=\"Int32\"\n"
261 "\t cardinality=\"single\"\n"
262 "\t visibility=\"external\"\n"
263 "\t defaultValue=\"512\"\n"
264 "\t access=\"public\"\n"
268 "\t name=\"height\"\n"
269 "\t type=\"Int32\"\n"
270 "\t cardinality=\"single\"\n"
271 "\t visibility=\"external\"\n"
272 "\t defaultValue=\"512\"\n"
273 "\t access=\"public\"\n"
277 "\t name=\"offsetBias\"\n"
278 "\t type=\"Real32\"\n"
279 "\t cardinality=\"single\"\n"
280 "\t visibility=\"external\"\n"
281 "\t defaultValue=\"4.f\"\n"
282 "\t access=\"public\"\n"
286 "\t name=\"offsetFactor\"\n"
287 "\t type=\"Real32\"\n"
288 "\t cardinality=\"single\"\n"
289 "\t visibility=\"external\"\n"
290 "\t defaultValue=\"10.f\"\n"
291 "\t access=\"public\"\n"
295 " name=\"shadowTravMask\"\n"
297 " cardinality=\"single\"\n"
298 " visibility=\"external\"\n"
299 " defaultValue=\"TypeTraits<UInt32>::BitsSet\"\n"
300 " access=\"public\"\n"
302 " Traversal mask when generating the shadow map. \n"
304 "</FieldContainer>\n",
308 /*------------------------------ get -----------------------------------*/
310 FieldContainerType
&ShadowMapEngineBase::getType(void)
315 const FieldContainerType
&ShadowMapEngineBase::getType(void) const
320 UInt32
ShadowMapEngineBase::getContainerSize(void) const
322 return sizeof(ShadowMapEngine
);
325 /*------------------------- decorator get ------------------------------*/
328 //! Get the ShadowMapEngine::_sfShadowTexChunk field.
329 const SFUnrecTextureObjChunkPtr
*ShadowMapEngineBase::getSFShadowTexChunk(void) const
331 return &_sfShadowTexChunk
;
334 SFUnrecTextureObjChunkPtr
*ShadowMapEngineBase::editSFShadowTexChunk (void)
336 editSField(ShadowTexChunkFieldMask
);
338 return &_sfShadowTexChunk
;
341 //! Get the value of the ShadowMapEngine::_sfShadowTexChunk field.
342 TextureObjChunk
* ShadowMapEngineBase::getShadowTexChunk(void) const
344 return _sfShadowTexChunk
.getValue();
347 //! Set the value of the ShadowMapEngine::_sfShadowTexChunk field.
348 void ShadowMapEngineBase::setShadowTexChunk(TextureObjChunk
* const value
)
350 editSField(ShadowTexChunkFieldMask
);
352 _sfShadowTexChunk
.setValue(value
);
356 SFInt32
*ShadowMapEngineBase::editSFWidth(void)
358 editSField(WidthFieldMask
);
363 const SFInt32
*ShadowMapEngineBase::getSFWidth(void) const
369 SFInt32
*ShadowMapEngineBase::editSFHeight(void)
371 editSField(HeightFieldMask
);
376 const SFInt32
*ShadowMapEngineBase::getSFHeight(void) const
382 SFReal32
*ShadowMapEngineBase::editSFOffsetBias(void)
384 editSField(OffsetBiasFieldMask
);
386 return &_sfOffsetBias
;
389 const SFReal32
*ShadowMapEngineBase::getSFOffsetBias(void) const
391 return &_sfOffsetBias
;
395 SFReal32
*ShadowMapEngineBase::editSFOffsetFactor(void)
397 editSField(OffsetFactorFieldMask
);
399 return &_sfOffsetFactor
;
402 const SFReal32
*ShadowMapEngineBase::getSFOffsetFactor(void) const
404 return &_sfOffsetFactor
;
408 SFUInt32
*ShadowMapEngineBase::editSFShadowTravMask(void)
410 editSField(ShadowTravMaskFieldMask
);
412 return &_sfShadowTravMask
;
415 const SFUInt32
*ShadowMapEngineBase::getSFShadowTravMask(void) const
417 return &_sfShadowTravMask
;
425 /*------------------------------ access -----------------------------------*/
427 SizeT
ShadowMapEngineBase::getBinSize(ConstFieldMaskArg whichField
)
429 SizeT returnValue
= Inherited::getBinSize(whichField
);
431 if(FieldBits::NoField
!= (ShadowTexChunkFieldMask
& whichField
))
433 returnValue
+= _sfShadowTexChunk
.getBinSize();
435 if(FieldBits::NoField
!= (WidthFieldMask
& whichField
))
437 returnValue
+= _sfWidth
.getBinSize();
439 if(FieldBits::NoField
!= (HeightFieldMask
& whichField
))
441 returnValue
+= _sfHeight
.getBinSize();
443 if(FieldBits::NoField
!= (OffsetBiasFieldMask
& whichField
))
445 returnValue
+= _sfOffsetBias
.getBinSize();
447 if(FieldBits::NoField
!= (OffsetFactorFieldMask
& whichField
))
449 returnValue
+= _sfOffsetFactor
.getBinSize();
451 if(FieldBits::NoField
!= (ShadowTravMaskFieldMask
& whichField
))
453 returnValue
+= _sfShadowTravMask
.getBinSize();
459 void ShadowMapEngineBase::copyToBin(BinaryDataHandler
&pMem
,
460 ConstFieldMaskArg whichField
)
462 Inherited::copyToBin(pMem
, whichField
);
464 if(FieldBits::NoField
!= (ShadowTexChunkFieldMask
& whichField
))
466 _sfShadowTexChunk
.copyToBin(pMem
);
468 if(FieldBits::NoField
!= (WidthFieldMask
& whichField
))
470 _sfWidth
.copyToBin(pMem
);
472 if(FieldBits::NoField
!= (HeightFieldMask
& whichField
))
474 _sfHeight
.copyToBin(pMem
);
476 if(FieldBits::NoField
!= (OffsetBiasFieldMask
& whichField
))
478 _sfOffsetBias
.copyToBin(pMem
);
480 if(FieldBits::NoField
!= (OffsetFactorFieldMask
& whichField
))
482 _sfOffsetFactor
.copyToBin(pMem
);
484 if(FieldBits::NoField
!= (ShadowTravMaskFieldMask
& whichField
))
486 _sfShadowTravMask
.copyToBin(pMem
);
490 void ShadowMapEngineBase::copyFromBin(BinaryDataHandler
&pMem
,
491 ConstFieldMaskArg whichField
)
493 Inherited::copyFromBin(pMem
, whichField
);
495 if(FieldBits::NoField
!= (ShadowTexChunkFieldMask
& whichField
))
497 editSField(ShadowTexChunkFieldMask
);
498 _sfShadowTexChunk
.copyFromBin(pMem
);
500 if(FieldBits::NoField
!= (WidthFieldMask
& whichField
))
502 editSField(WidthFieldMask
);
503 _sfWidth
.copyFromBin(pMem
);
505 if(FieldBits::NoField
!= (HeightFieldMask
& whichField
))
507 editSField(HeightFieldMask
);
508 _sfHeight
.copyFromBin(pMem
);
510 if(FieldBits::NoField
!= (OffsetBiasFieldMask
& whichField
))
512 editSField(OffsetBiasFieldMask
);
513 _sfOffsetBias
.copyFromBin(pMem
);
515 if(FieldBits::NoField
!= (OffsetFactorFieldMask
& whichField
))
517 editSField(OffsetFactorFieldMask
);
518 _sfOffsetFactor
.copyFromBin(pMem
);
520 if(FieldBits::NoField
!= (ShadowTravMaskFieldMask
& whichField
))
522 editSField(ShadowTravMaskFieldMask
);
523 _sfShadowTravMask
.copyFromBin(pMem
);
530 /*------------------------- constructors ----------------------------------*/
532 ShadowMapEngineBase::ShadowMapEngineBase(void) :
534 _sfShadowTexChunk (NULL
),
535 _sfWidth (Int32(512)),
536 _sfHeight (Int32(512)),
537 _sfOffsetBias (Real32(4.f
)),
538 _sfOffsetFactor (Real32(10.f
)),
539 _sfShadowTravMask (UInt32(TypeTraits
<UInt32
>::BitsSet
))
543 ShadowMapEngineBase::ShadowMapEngineBase(const ShadowMapEngineBase
&source
) :
545 _sfShadowTexChunk (NULL
),
546 _sfWidth (source
._sfWidth
),
547 _sfHeight (source
._sfHeight
),
548 _sfOffsetBias (source
._sfOffsetBias
),
549 _sfOffsetFactor (source
._sfOffsetFactor
),
550 _sfShadowTravMask (source
._sfShadowTravMask
)
555 /*-------------------------- destructors ----------------------------------*/
557 ShadowMapEngineBase::~ShadowMapEngineBase(void)
561 void ShadowMapEngineBase::onCreate(const ShadowMapEngine
*source
)
563 Inherited::onCreate(source
);
567 ShadowMapEngine
*pThis
= static_cast<ShadowMapEngine
*>(this);
569 pThis
->setShadowTexChunk(source
->getShadowTexChunk());
573 GetFieldHandlePtr
ShadowMapEngineBase::getHandleShadowTexChunk (void) const
575 SFUnrecTextureObjChunkPtr::GetHandlePtr
returnValue(
576 new SFUnrecTextureObjChunkPtr::GetHandle(
578 this->getType().getFieldDesc(ShadowTexChunkFieldId
),
579 const_cast<ShadowMapEngineBase
*>(this)));
584 EditFieldHandlePtr
ShadowMapEngineBase::editHandleShadowTexChunk (void)
586 SFUnrecTextureObjChunkPtr::EditHandlePtr
returnValue(
587 new SFUnrecTextureObjChunkPtr::EditHandle(
589 this->getType().getFieldDesc(ShadowTexChunkFieldId
),
592 returnValue
->setSetMethod(
593 boost::bind(&ShadowMapEngine::setShadowTexChunk
,
594 static_cast<ShadowMapEngine
*>(this), _1
));
596 editSField(ShadowTexChunkFieldMask
);
601 GetFieldHandlePtr
ShadowMapEngineBase::getHandleWidth (void) const
603 SFInt32::GetHandlePtr
returnValue(
604 new SFInt32::GetHandle(
606 this->getType().getFieldDesc(WidthFieldId
),
607 const_cast<ShadowMapEngineBase
*>(this)));
612 EditFieldHandlePtr
ShadowMapEngineBase::editHandleWidth (void)
614 SFInt32::EditHandlePtr
returnValue(
615 new SFInt32::EditHandle(
617 this->getType().getFieldDesc(WidthFieldId
),
621 editSField(WidthFieldMask
);
626 GetFieldHandlePtr
ShadowMapEngineBase::getHandleHeight (void) const
628 SFInt32::GetHandlePtr
returnValue(
629 new SFInt32::GetHandle(
631 this->getType().getFieldDesc(HeightFieldId
),
632 const_cast<ShadowMapEngineBase
*>(this)));
637 EditFieldHandlePtr
ShadowMapEngineBase::editHandleHeight (void)
639 SFInt32::EditHandlePtr
returnValue(
640 new SFInt32::EditHandle(
642 this->getType().getFieldDesc(HeightFieldId
),
646 editSField(HeightFieldMask
);
651 GetFieldHandlePtr
ShadowMapEngineBase::getHandleOffsetBias (void) const
653 SFReal32::GetHandlePtr
returnValue(
654 new SFReal32::GetHandle(
656 this->getType().getFieldDesc(OffsetBiasFieldId
),
657 const_cast<ShadowMapEngineBase
*>(this)));
662 EditFieldHandlePtr
ShadowMapEngineBase::editHandleOffsetBias (void)
664 SFReal32::EditHandlePtr
returnValue(
665 new SFReal32::EditHandle(
667 this->getType().getFieldDesc(OffsetBiasFieldId
),
671 editSField(OffsetBiasFieldMask
);
676 GetFieldHandlePtr
ShadowMapEngineBase::getHandleOffsetFactor (void) const
678 SFReal32::GetHandlePtr
returnValue(
679 new SFReal32::GetHandle(
681 this->getType().getFieldDesc(OffsetFactorFieldId
),
682 const_cast<ShadowMapEngineBase
*>(this)));
687 EditFieldHandlePtr
ShadowMapEngineBase::editHandleOffsetFactor (void)
689 SFReal32::EditHandlePtr
returnValue(
690 new SFReal32::EditHandle(
692 this->getType().getFieldDesc(OffsetFactorFieldId
),
696 editSField(OffsetFactorFieldMask
);
701 GetFieldHandlePtr
ShadowMapEngineBase::getHandleShadowTravMask (void) const
703 SFUInt32::GetHandlePtr
returnValue(
704 new SFUInt32::GetHandle(
706 this->getType().getFieldDesc(ShadowTravMaskFieldId
),
707 const_cast<ShadowMapEngineBase
*>(this)));
712 EditFieldHandlePtr
ShadowMapEngineBase::editHandleShadowTravMask (void)
714 SFUInt32::EditHandlePtr
returnValue(
715 new SFUInt32::EditHandle(
717 this->getType().getFieldDesc(ShadowTravMaskFieldId
),
721 editSField(ShadowTravMaskFieldMask
);
727 #ifdef OSG_MT_CPTR_ASPECT
728 void ShadowMapEngineBase::execSyncV( FieldContainer
&oFrom
,
729 ConstFieldMaskArg whichField
,
730 AspectOffsetStore
&oOffsets
,
731 ConstFieldMaskArg syncMode
,
732 const UInt32 uiSyncInfo
)
734 ShadowMapEngine
*pThis
= static_cast<ShadowMapEngine
*>(this);
736 pThis
->execSync(static_cast<ShadowMapEngine
*>(&oFrom
),
746 void ShadowMapEngineBase::resolveLinks(void)
748 Inherited::resolveLinks();
750 static_cast<ShadowMapEngine
*>(this)->setShadowTexChunk(NULL
);