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 "OSGScreenLODBase.h"
67 #include "OSGScreenLOD.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::ScreenLOD
78 A ScreenLOD node enables smart LOD selection based on screen size. It must
79 be used in combination with the RenderTraversal Action.
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var Real32 ScreenLODBase::_mfCoverageOverride
89 A list of percentages to override the default LOD behavior. These
90 percentages are used to determine which lod to use based on screen size
91 percentage. If the percentage covered by the node bounding volume is less
92 then entry 0, we use child 0. If is is greater then entry 0 less then
93 entry 1, then we use child 1 and so on. Ex: [0.05, 0.01, 0.001]
97 /***************************************************************************\
98 * FieldType/FieldTrait Instantiation *
99 \***************************************************************************/
101 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
102 PointerType FieldTraits
<ScreenLOD
*, nsOSG
>::_type(
105 ScreenLOD::getClassType(),
109 OSG_FIELDTRAITS_GETTYPE_NS(ScreenLOD
*, nsOSG
)
111 /***************************************************************************\
112 * Field Description *
113 \***************************************************************************/
115 void ScreenLODBase::classDescInserter(TypeObject
&oType
)
117 FieldDescriptionBase
*pDesc
= NULL
;
120 pDesc
= new MFReal32::Description(
121 MFReal32::getClassType(),
123 "A list of percentages to override the default LOD behavior. These\n"
124 "percentages are used to determine which lod to use based on screen size\n"
125 "percentage. If the percentage covered by the node bounding volume is less\n"
126 "then entry 0, we use child 0. If is is greater then entry 0 less then\n"
127 "entry 1, then we use child 1 and so on. Ex: [0.05, 0.01, 0.001]\n",
128 CoverageOverrideFieldId
, CoverageOverrideFieldMask
,
130 (Field::MFDefaultFlags
| Field::FStdAccess
),
131 static_cast<FieldEditMethodSig
>(&ScreenLOD::editHandleCoverageOverride
),
132 static_cast<FieldGetMethodSig
>(&ScreenLOD::getHandleCoverageOverride
));
134 oType
.addInitialDesc(pDesc
);
138 ScreenLODBase::TypeObject
ScreenLODBase::_type(
139 ScreenLODBase::getClassname(),
140 Inherited::getClassname(),
143 reinterpret_cast<PrototypeCreateF
>(&ScreenLODBase::createEmptyLocal
),
144 reinterpret_cast<InitContainerF
>(&ScreenLOD::initMethod
),
145 reinterpret_cast<ExitContainerF
>(&ScreenLOD::exitMethod
),
146 reinterpret_cast<InitalInsertDescFunc
>(
147 reinterpret_cast<void *>(&ScreenLOD::classDescInserter
)),
150 "<?xml version=\"1.0\"?>\n"
153 " name=\"ScreenLOD\"\n"
154 " parent=\"Group\"\n"
155 " library=\"Group\"\n"
156 " pointerfieldtypes=\"none\"\n"
157 " structure=\"concrete\"\n"
158 " systemcomponent=\"true\"\n"
159 " parentsystemcomponent=\"true\"\n"
160 " isNodeCore=\"true\"\n"
161 " docGroupBase=\"GrpGroupMisc\"\n"
163 " A ScreenLOD node enables smart LOD selection based on screen size. It must\n"
164 " be used in combination with the RenderTraversal Action.\n"
166 " See Ref:ScreenLOD\n"
168 "\t name=\"coverageOverride\"\n"
169 "\t type=\"Real32\"\n"
170 "\t cardinality=\"multi\"\n"
171 "\t visibility=\"external\"\n"
172 "\t access=\"public\"\n"
174 "\tA list of percentages to override the default LOD behavior. These\n"
175 "\tpercentages are used to determine which lod to use based on screen size\n"
176 "\tpercentage. If the percentage covered by the node bounding volume is less\n"
177 "\tthen entry 0, we use child 0. If is is greater then entry 0 less then\n"
178 "\tentry 1, then we use child 1 and so on. Ex: [0.05, 0.01, 0.001]\n"
180 "</FieldContainer>\n",
181 "A ScreenLOD node enables smart LOD selection based on screen size. It must\n"
182 "be used in combination with the RenderTraversal Action.\n"
184 "See Ref:ScreenLOD\n"
187 /*------------------------------ get -----------------------------------*/
189 FieldContainerType
&ScreenLODBase::getType(void)
194 const FieldContainerType
&ScreenLODBase::getType(void) const
199 UInt32
ScreenLODBase::getContainerSize(void) const
201 return sizeof(ScreenLOD
);
204 /*------------------------- decorator get ------------------------------*/
207 MFReal32
*ScreenLODBase::editMFCoverageOverride(void)
209 editMField(CoverageOverrideFieldMask
, _mfCoverageOverride
);
211 return &_mfCoverageOverride
;
214 const MFReal32
*ScreenLODBase::getMFCoverageOverride(void) const
216 return &_mfCoverageOverride
;
224 /*------------------------------ access -----------------------------------*/
226 SizeT
ScreenLODBase::getBinSize(ConstFieldMaskArg whichField
)
228 SizeT returnValue
= Inherited::getBinSize(whichField
);
230 if(FieldBits::NoField
!= (CoverageOverrideFieldMask
& whichField
))
232 returnValue
+= _mfCoverageOverride
.getBinSize();
238 void ScreenLODBase::copyToBin(BinaryDataHandler
&pMem
,
239 ConstFieldMaskArg whichField
)
241 Inherited::copyToBin(pMem
, whichField
);
243 if(FieldBits::NoField
!= (CoverageOverrideFieldMask
& whichField
))
245 _mfCoverageOverride
.copyToBin(pMem
);
249 void ScreenLODBase::copyFromBin(BinaryDataHandler
&pMem
,
250 ConstFieldMaskArg whichField
)
252 Inherited::copyFromBin(pMem
, whichField
);
254 if(FieldBits::NoField
!= (CoverageOverrideFieldMask
& whichField
))
256 editMField(CoverageOverrideFieldMask
, _mfCoverageOverride
);
257 _mfCoverageOverride
.copyFromBin(pMem
);
261 //! create a new instance of the class
262 ScreenLODTransitPtr
ScreenLODBase::createLocal(BitVector bFlags
)
264 ScreenLODTransitPtr fc
;
266 if(getClassType().getPrototype() != NULL
)
268 FieldContainerTransitPtr tmpPtr
=
269 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
271 fc
= dynamic_pointer_cast
<ScreenLOD
>(tmpPtr
);
277 //! create a new instance of the class, copy the container flags
278 ScreenLODTransitPtr
ScreenLODBase::createDependent(BitVector bFlags
)
280 ScreenLODTransitPtr fc
;
282 if(getClassType().getPrototype() != NULL
)
284 FieldContainerTransitPtr tmpPtr
=
285 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
287 fc
= dynamic_pointer_cast
<ScreenLOD
>(tmpPtr
);
293 //! create a new instance of the class
294 ScreenLODTransitPtr
ScreenLODBase::create(void)
296 ScreenLODTransitPtr fc
;
298 if(getClassType().getPrototype() != NULL
)
300 FieldContainerTransitPtr tmpPtr
=
301 getClassType().getPrototype()-> shallowCopy();
303 fc
= dynamic_pointer_cast
<ScreenLOD
>(tmpPtr
);
309 ScreenLOD
*ScreenLODBase::createEmptyLocal(BitVector bFlags
)
311 ScreenLOD
*returnValue
;
313 newPtr
<ScreenLOD
>(returnValue
, bFlags
);
315 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
320 //! create an empty new instance of the class, do not copy the prototype
321 ScreenLOD
*ScreenLODBase::createEmpty(void)
323 ScreenLOD
*returnValue
;
325 newPtr
<ScreenLOD
>(returnValue
, Thread::getCurrentLocalFlags());
327 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
328 ~Thread::getCurrentLocalFlags();
334 FieldContainerTransitPtr
ScreenLODBase::shallowCopyLocal(
335 BitVector bFlags
) const
339 newPtr(tmpPtr
, dynamic_cast<const ScreenLOD
*>(this), bFlags
);
341 FieldContainerTransitPtr
returnValue(tmpPtr
);
343 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
348 FieldContainerTransitPtr
ScreenLODBase::shallowCopyDependent(
349 BitVector bFlags
) const
353 newPtr(tmpPtr
, dynamic_cast<const ScreenLOD
*>(this), ~bFlags
);
355 FieldContainerTransitPtr
returnValue(tmpPtr
);
357 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
362 FieldContainerTransitPtr
ScreenLODBase::shallowCopy(void) const
367 dynamic_cast<const ScreenLOD
*>(this),
368 Thread::getCurrentLocalFlags());
370 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
372 FieldContainerTransitPtr
returnValue(tmpPtr
);
380 /*------------------------- constructors ----------------------------------*/
382 ScreenLODBase::ScreenLODBase(void) :
384 _mfCoverageOverride ()
388 ScreenLODBase::ScreenLODBase(const ScreenLODBase
&source
) :
390 _mfCoverageOverride (source
._mfCoverageOverride
)
395 /*-------------------------- destructors ----------------------------------*/
397 ScreenLODBase::~ScreenLODBase(void)
402 GetFieldHandlePtr
ScreenLODBase::getHandleCoverageOverride (void) const
404 MFReal32::GetHandlePtr
returnValue(
405 new MFReal32::GetHandle(
406 &_mfCoverageOverride
,
407 this->getType().getFieldDesc(CoverageOverrideFieldId
),
408 const_cast<ScreenLODBase
*>(this)));
413 EditFieldHandlePtr
ScreenLODBase::editHandleCoverageOverride(void)
415 MFReal32::EditHandlePtr
returnValue(
416 new MFReal32::EditHandle(
417 &_mfCoverageOverride
,
418 this->getType().getFieldDesc(CoverageOverrideFieldId
),
422 editMField(CoverageOverrideFieldMask
, _mfCoverageOverride
);
428 #ifdef OSG_MT_CPTR_ASPECT
429 void ScreenLODBase::execSyncV( FieldContainer
&oFrom
,
430 ConstFieldMaskArg whichField
,
431 AspectOffsetStore
&oOffsets
,
432 ConstFieldMaskArg syncMode
,
433 const UInt32 uiSyncInfo
)
435 ScreenLOD
*pThis
= static_cast<ScreenLOD
*>(this);
437 pThis
->execSync(static_cast<ScreenLOD
*>(&oFrom
),
446 #ifdef OSG_MT_CPTR_ASPECT
447 FieldContainer
*ScreenLODBase::createAspectCopy(
448 const FieldContainer
*pRefAspect
) const
450 ScreenLOD
*returnValue
;
452 newAspectCopy(returnValue
,
453 dynamic_cast<const ScreenLOD
*>(pRefAspect
),
454 dynamic_cast<const ScreenLOD
*>(this));
460 void ScreenLODBase::resolveLinks(void)
462 Inherited::resolveLinks();
464 #ifdef OSG_MT_CPTR_ASPECT
465 AspectOffsetStore oOffsets
;
467 _pAspectStore
->fillOffsetArray(oOffsets
, this);
470 #ifdef OSG_MT_CPTR_ASPECT
471 _mfCoverageOverride
.terminateShare(Thread::getCurrentAspect(),