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"
64 #include "OSGGL.h" // Mode default header
67 #include "OSGFogChunkBase.h"
68 #include "OSGFogChunk.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::FogChunk
79 This chunk wraps glFog() (OSG::FogChunk::_sfMode, OSG::FogChunk::_sfFogColor,
80 OSG::FogChunk::_sfStart, OSG::FogChunk::_sfEnd, OSG::FogChunk::_sfDensity).
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var GLenum FogChunkBase::_sfMode
88 The fog type to use (GL_LINEAR, GL_EXP, GL_EXP2, default: GL_EXP).
91 /*! \var Color4f FogChunkBase::_sfColor
92 The color of the fog (default: 0, 0, 0, 0).
95 /*! \var Real32 FogChunkBase::_sfStart
96 The near value for the fog, used in GL_LINEAR mode (default: 0.f)
99 /*! \var Real32 FogChunkBase::_sfEnd
100 The far value for the fog, used in GL_LINEAR mode (default: 1.f)
103 /*! \var Real32 FogChunkBase::_sfDensity
104 The denisty of the fog, used in GL_EXP, GL_EXP2 mode (default: 1.f)
108 /***************************************************************************\
109 * FieldType/FieldTrait Instantiation *
110 \***************************************************************************/
112 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
113 PointerType FieldTraits
<FogChunk
*, nsOSG
>::_type(
116 FogChunk::getClassType(),
120 OSG_FIELDTRAITS_GETTYPE_NS(FogChunk
*, nsOSG
)
122 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
126 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
130 /***************************************************************************\
131 * Field Description *
132 \***************************************************************************/
134 void FogChunkBase::classDescInserter(TypeObject
&oType
)
136 FieldDescriptionBase
*pDesc
= NULL
;
139 pDesc
= new SFGLenum::Description(
140 SFGLenum::getClassType(),
142 "The fog type to use (GL_LINEAR, GL_EXP, GL_EXP2, default: GL_EXP).\n",
143 ModeFieldId
, ModeFieldMask
,
145 (Field::SFDefaultFlags
| Field::FStdAccess
),
146 static_cast<FieldEditMethodSig
>(&FogChunk::editHandleMode
),
147 static_cast<FieldGetMethodSig
>(&FogChunk::getHandleMode
));
149 oType
.addInitialDesc(pDesc
);
151 pDesc
= new SFColor4f::Description(
152 SFColor4f::getClassType(),
154 "The color of the fog (default: 0, 0, 0, 0).\n",
155 ColorFieldId
, ColorFieldMask
,
157 (Field::SFDefaultFlags
| Field::FStdAccess
),
158 static_cast<FieldEditMethodSig
>(&FogChunk::editHandleColor
),
159 static_cast<FieldGetMethodSig
>(&FogChunk::getHandleColor
));
161 oType
.addInitialDesc(pDesc
);
163 pDesc
= new SFReal32::Description(
164 SFReal32::getClassType(),
166 "The near value for the fog, used in GL_LINEAR mode (default: 0.f)\n",
167 StartFieldId
, StartFieldMask
,
169 (Field::SFDefaultFlags
| Field::FStdAccess
),
170 static_cast<FieldEditMethodSig
>(&FogChunk::editHandleStart
),
171 static_cast<FieldGetMethodSig
>(&FogChunk::getHandleStart
));
173 oType
.addInitialDesc(pDesc
);
175 pDesc
= new SFReal32::Description(
176 SFReal32::getClassType(),
178 "The far value for the fog, used in GL_LINEAR mode (default: 1.f)\n",
179 EndFieldId
, EndFieldMask
,
181 (Field::SFDefaultFlags
| Field::FStdAccess
),
182 static_cast<FieldEditMethodSig
>(&FogChunk::editHandleEnd
),
183 static_cast<FieldGetMethodSig
>(&FogChunk::getHandleEnd
));
185 oType
.addInitialDesc(pDesc
);
187 pDesc
= new SFReal32::Description(
188 SFReal32::getClassType(),
190 "The denisty of the fog, used in GL_EXP, GL_EXP2 mode (default: 1.f)\n",
191 DensityFieldId
, DensityFieldMask
,
193 (Field::SFDefaultFlags
| Field::FStdAccess
),
194 static_cast<FieldEditMethodSig
>(&FogChunk::editHandleDensity
),
195 static_cast<FieldGetMethodSig
>(&FogChunk::getHandleDensity
));
197 oType
.addInitialDesc(pDesc
);
201 FogChunkBase::TypeObject
FogChunkBase::_type(
202 FogChunkBase::getClassname(),
203 Inherited::getClassname(),
206 reinterpret_cast<PrototypeCreateF
>(&FogChunkBase::createEmptyLocal
),
207 reinterpret_cast<InitContainerF
>(&FogChunk::initMethod
),
208 reinterpret_cast<ExitContainerF
>(&FogChunk::exitMethod
),
209 reinterpret_cast<InitalInsertDescFunc
>(
210 reinterpret_cast<void *>(&FogChunk::classDescInserter
)),
213 "<?xml version=\"1.0\"?>\n"
216 " name=\"FogChunk\"\n"
217 " parent=\"StateChunk\"\n"
218 " library=\"State\"\n"
219 " pointerfieldtypes=\"both\"\n"
220 " structure=\"concrete\"\n"
221 " systemcomponent=\"true\"\n"
222 " parentsystemcomponent=\"true\"\n"
223 " decoratable=\"false\"\n"
224 " docGroupBase=\"GrpStateOpenGL\"\n"
226 " This chunk wraps glFog() (OSG::FogChunk::_sfMode, OSG::FogChunk::_sfFogColor,\n"
227 " OSG::FogChunk::_sfStart, OSG::FogChunk::_sfEnd, OSG::FogChunk::_sfDensity).\n"
232 " category=\"data\"\n"
233 " cardinality=\"single\"\n"
234 " defaultValue=\"GL_EXP\"\n"
235 " defaultHeader=\""OSGGL.h"\"\n"
236 " visibility=\"external\"\n"
237 " access=\"public\"\n"
239 " The fog type to use (GL_LINEAR, GL_EXP, GL_EXP2, default: GL_EXP).\n"
244 " type=\"Color4f\"\n"
245 " category=\"data\"\n"
246 " cardinality=\"single\"\n"
247 " defaultValue=\"0.f, 0.f, 0.f, 0.f\"\n"
248 " visibility=\"external\"\n"
249 " access=\"public\"\n"
251 " The color of the fog (default: 0, 0, 0, 0).\n"
257 " category=\"data\"\n"
258 " cardinality=\"single\"\n"
259 " defaultValue=\"0.f\"\n"
260 " visibility=\"external\"\n"
261 " access=\"public\"\n"
263 " The near value for the fog, used in GL_LINEAR mode (default: 0.f)\n"
269 " category=\"data\"\n"
270 " cardinality=\"single\"\n"
271 " defaultValue=\"1.f\"\n"
272 " visibility=\"external\"\n"
273 " access=\"public\"\n"
275 " The far value for the fog, used in GL_LINEAR mode (default: 1.f)\n"
279 " name=\"density\"\n"
281 " category=\"data\"\n"
282 " cardinality=\"single\"\n"
283 " defaultValue=\"1.f\"\n"
284 " visibility=\"external\"\n"
285 " access=\"public\"\n"
287 " The denisty of the fog, used in GL_EXP, GL_EXP2 mode (default: 1.f)\n"
289 "</FieldContainer>\n",
290 "This chunk wraps glFog() (OSG::FogChunk::_sfMode, OSG::FogChunk::_sfFogColor,\n"
291 "OSG::FogChunk::_sfStart, OSG::FogChunk::_sfEnd, OSG::FogChunk::_sfDensity).\n"
294 /*------------------------------ get -----------------------------------*/
296 FieldContainerType
&FogChunkBase::getType(void)
301 const FieldContainerType
&FogChunkBase::getType(void) const
306 UInt32
FogChunkBase::getContainerSize(void) const
308 return sizeof(FogChunk
);
311 /*------------------------- decorator get ------------------------------*/
314 SFGLenum
*FogChunkBase::editSFMode(void)
316 editSField(ModeFieldMask
);
321 const SFGLenum
*FogChunkBase::getSFMode(void) const
327 SFColor4f
*FogChunkBase::editSFColor(void)
329 editSField(ColorFieldMask
);
334 const SFColor4f
*FogChunkBase::getSFColor(void) const
340 SFReal32
*FogChunkBase::editSFStart(void)
342 editSField(StartFieldMask
);
347 const SFReal32
*FogChunkBase::getSFStart(void) const
353 SFReal32
*FogChunkBase::editSFEnd(void)
355 editSField(EndFieldMask
);
360 const SFReal32
*FogChunkBase::getSFEnd(void) const
366 SFReal32
*FogChunkBase::editSFDensity(void)
368 editSField(DensityFieldMask
);
373 const SFReal32
*FogChunkBase::getSFDensity(void) const
383 /*------------------------------ access -----------------------------------*/
385 SizeT
FogChunkBase::getBinSize(ConstFieldMaskArg whichField
)
387 SizeT returnValue
= Inherited::getBinSize(whichField
);
389 if(FieldBits::NoField
!= (ModeFieldMask
& whichField
))
391 returnValue
+= _sfMode
.getBinSize();
393 if(FieldBits::NoField
!= (ColorFieldMask
& whichField
))
395 returnValue
+= _sfColor
.getBinSize();
397 if(FieldBits::NoField
!= (StartFieldMask
& whichField
))
399 returnValue
+= _sfStart
.getBinSize();
401 if(FieldBits::NoField
!= (EndFieldMask
& whichField
))
403 returnValue
+= _sfEnd
.getBinSize();
405 if(FieldBits::NoField
!= (DensityFieldMask
& whichField
))
407 returnValue
+= _sfDensity
.getBinSize();
413 void FogChunkBase::copyToBin(BinaryDataHandler
&pMem
,
414 ConstFieldMaskArg whichField
)
416 Inherited::copyToBin(pMem
, whichField
);
418 if(FieldBits::NoField
!= (ModeFieldMask
& whichField
))
420 _sfMode
.copyToBin(pMem
);
422 if(FieldBits::NoField
!= (ColorFieldMask
& whichField
))
424 _sfColor
.copyToBin(pMem
);
426 if(FieldBits::NoField
!= (StartFieldMask
& whichField
))
428 _sfStart
.copyToBin(pMem
);
430 if(FieldBits::NoField
!= (EndFieldMask
& whichField
))
432 _sfEnd
.copyToBin(pMem
);
434 if(FieldBits::NoField
!= (DensityFieldMask
& whichField
))
436 _sfDensity
.copyToBin(pMem
);
440 void FogChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
441 ConstFieldMaskArg whichField
)
443 Inherited::copyFromBin(pMem
, whichField
);
445 if(FieldBits::NoField
!= (ModeFieldMask
& whichField
))
447 editSField(ModeFieldMask
);
448 _sfMode
.copyFromBin(pMem
);
450 if(FieldBits::NoField
!= (ColorFieldMask
& whichField
))
452 editSField(ColorFieldMask
);
453 _sfColor
.copyFromBin(pMem
);
455 if(FieldBits::NoField
!= (StartFieldMask
& whichField
))
457 editSField(StartFieldMask
);
458 _sfStart
.copyFromBin(pMem
);
460 if(FieldBits::NoField
!= (EndFieldMask
& whichField
))
462 editSField(EndFieldMask
);
463 _sfEnd
.copyFromBin(pMem
);
465 if(FieldBits::NoField
!= (DensityFieldMask
& whichField
))
467 editSField(DensityFieldMask
);
468 _sfDensity
.copyFromBin(pMem
);
472 //! create a new instance of the class
473 FogChunkTransitPtr
FogChunkBase::createLocal(BitVector bFlags
)
475 FogChunkTransitPtr fc
;
477 if(getClassType().getPrototype() != NULL
)
479 FieldContainerTransitPtr tmpPtr
=
480 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
482 fc
= dynamic_pointer_cast
<FogChunk
>(tmpPtr
);
488 //! create a new instance of the class, copy the container flags
489 FogChunkTransitPtr
FogChunkBase::createDependent(BitVector bFlags
)
491 FogChunkTransitPtr fc
;
493 if(getClassType().getPrototype() != NULL
)
495 FieldContainerTransitPtr tmpPtr
=
496 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
498 fc
= dynamic_pointer_cast
<FogChunk
>(tmpPtr
);
504 //! create a new instance of the class
505 FogChunkTransitPtr
FogChunkBase::create(void)
507 FogChunkTransitPtr fc
;
509 if(getClassType().getPrototype() != NULL
)
511 FieldContainerTransitPtr tmpPtr
=
512 getClassType().getPrototype()-> shallowCopy();
514 fc
= dynamic_pointer_cast
<FogChunk
>(tmpPtr
);
520 FogChunk
*FogChunkBase::createEmptyLocal(BitVector bFlags
)
522 FogChunk
*returnValue
;
524 newPtr
<FogChunk
>(returnValue
, bFlags
);
526 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
531 //! create an empty new instance of the class, do not copy the prototype
532 FogChunk
*FogChunkBase::createEmpty(void)
534 FogChunk
*returnValue
;
536 newPtr
<FogChunk
>(returnValue
, Thread::getCurrentLocalFlags());
538 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
539 ~Thread::getCurrentLocalFlags();
545 FieldContainerTransitPtr
FogChunkBase::shallowCopyLocal(
546 BitVector bFlags
) const
550 newPtr(tmpPtr
, dynamic_cast<const FogChunk
*>(this), bFlags
);
552 FieldContainerTransitPtr
returnValue(tmpPtr
);
554 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
559 FieldContainerTransitPtr
FogChunkBase::shallowCopyDependent(
560 BitVector bFlags
) const
564 newPtr(tmpPtr
, dynamic_cast<const FogChunk
*>(this), ~bFlags
);
566 FieldContainerTransitPtr
returnValue(tmpPtr
);
568 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
573 FieldContainerTransitPtr
FogChunkBase::shallowCopy(void) const
578 dynamic_cast<const FogChunk
*>(this),
579 Thread::getCurrentLocalFlags());
581 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
583 FieldContainerTransitPtr
returnValue(tmpPtr
);
591 /*------------------------- constructors ----------------------------------*/
593 FogChunkBase::FogChunkBase(void) :
595 _sfMode (GLenum(GL_EXP
)),
596 _sfColor (Color4f(0.f
, 0.f
, 0.f
, 0.f
)),
597 _sfStart (Real32(0.f
)),
598 _sfEnd (Real32(1.f
)),
599 _sfDensity (Real32(1.f
))
603 FogChunkBase::FogChunkBase(const FogChunkBase
&source
) :
605 _sfMode (source
._sfMode
),
606 _sfColor (source
._sfColor
),
607 _sfStart (source
._sfStart
),
608 _sfEnd (source
._sfEnd
),
609 _sfDensity (source
._sfDensity
)
614 /*-------------------------- destructors ----------------------------------*/
616 FogChunkBase::~FogChunkBase(void)
621 GetFieldHandlePtr
FogChunkBase::getHandleMode (void) const
623 SFGLenum::GetHandlePtr
returnValue(
624 new SFGLenum::GetHandle(
626 this->getType().getFieldDesc(ModeFieldId
),
627 const_cast<FogChunkBase
*>(this)));
632 EditFieldHandlePtr
FogChunkBase::editHandleMode (void)
634 SFGLenum::EditHandlePtr
returnValue(
635 new SFGLenum::EditHandle(
637 this->getType().getFieldDesc(ModeFieldId
),
641 editSField(ModeFieldMask
);
646 GetFieldHandlePtr
FogChunkBase::getHandleColor (void) const
648 SFColor4f::GetHandlePtr
returnValue(
649 new SFColor4f::GetHandle(
651 this->getType().getFieldDesc(ColorFieldId
),
652 const_cast<FogChunkBase
*>(this)));
657 EditFieldHandlePtr
FogChunkBase::editHandleColor (void)
659 SFColor4f::EditHandlePtr
returnValue(
660 new SFColor4f::EditHandle(
662 this->getType().getFieldDesc(ColorFieldId
),
666 editSField(ColorFieldMask
);
671 GetFieldHandlePtr
FogChunkBase::getHandleStart (void) const
673 SFReal32::GetHandlePtr
returnValue(
674 new SFReal32::GetHandle(
676 this->getType().getFieldDesc(StartFieldId
),
677 const_cast<FogChunkBase
*>(this)));
682 EditFieldHandlePtr
FogChunkBase::editHandleStart (void)
684 SFReal32::EditHandlePtr
returnValue(
685 new SFReal32::EditHandle(
687 this->getType().getFieldDesc(StartFieldId
),
691 editSField(StartFieldMask
);
696 GetFieldHandlePtr
FogChunkBase::getHandleEnd (void) const
698 SFReal32::GetHandlePtr
returnValue(
699 new SFReal32::GetHandle(
701 this->getType().getFieldDesc(EndFieldId
),
702 const_cast<FogChunkBase
*>(this)));
707 EditFieldHandlePtr
FogChunkBase::editHandleEnd (void)
709 SFReal32::EditHandlePtr
returnValue(
710 new SFReal32::EditHandle(
712 this->getType().getFieldDesc(EndFieldId
),
716 editSField(EndFieldMask
);
721 GetFieldHandlePtr
FogChunkBase::getHandleDensity (void) const
723 SFReal32::GetHandlePtr
returnValue(
724 new SFReal32::GetHandle(
726 this->getType().getFieldDesc(DensityFieldId
),
727 const_cast<FogChunkBase
*>(this)));
732 EditFieldHandlePtr
FogChunkBase::editHandleDensity (void)
734 SFReal32::EditHandlePtr
returnValue(
735 new SFReal32::EditHandle(
737 this->getType().getFieldDesc(DensityFieldId
),
741 editSField(DensityFieldMask
);
747 #ifdef OSG_MT_CPTR_ASPECT
748 void FogChunkBase::execSyncV( FieldContainer
&oFrom
,
749 ConstFieldMaskArg whichField
,
750 AspectOffsetStore
&oOffsets
,
751 ConstFieldMaskArg syncMode
,
752 const UInt32 uiSyncInfo
)
754 FogChunk
*pThis
= static_cast<FogChunk
*>(this);
756 pThis
->execSync(static_cast<FogChunk
*>(&oFrom
),
765 #ifdef OSG_MT_CPTR_ASPECT
766 FieldContainer
*FogChunkBase::createAspectCopy(
767 const FieldContainer
*pRefAspect
) const
769 FogChunk
*returnValue
;
771 newAspectCopy(returnValue
,
772 dynamic_cast<const FogChunk
*>(pRefAspect
),
773 dynamic_cast<const FogChunk
*>(this));
779 void FogChunkBase::resolveLinks(void)
781 Inherited::resolveLinks();