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 DynamicStateGenerator!
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 "OSGFrameBufferObject.h" // RenderTarget Class
67 #include "OSGDynamicStateGeneratorBase.h"
68 #include "OSGDynamicStateGenerator.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::DynamicStateGenerator
79 Base for dynamic materials like dynamic cube env maps
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var FrameBufferObject * DynamicStateGeneratorBase::_sfRenderTarget
87 The FBO to target for rendering this subtree.
91 /***************************************************************************\
92 * FieldType/FieldTrait Instantiation *
93 \***************************************************************************/
95 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
96 PointerType FieldTraits
<DynamicStateGenerator
*, nsOSG
>::_type(
97 "DynamicStateGeneratorPtr",
98 "ChunkOverrideGroupPtr",
99 DynamicStateGenerator::getClassType(),
103 OSG_FIELDTRAITS_GETTYPE_NS(DynamicStateGenerator
*, nsOSG
)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
106 DynamicStateGenerator
*,
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
110 DynamicStateGenerator
*,
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void DynamicStateGeneratorBase::classDescInserter(TypeObject
&oType
)
119 Inherited::classDescInserter(oType
);
121 FieldDescriptionBase
*pDesc
= NULL
;
124 pDesc
= new SFUnrecFrameBufferObjectPtr::Description(
125 SFUnrecFrameBufferObjectPtr::getClassType(),
127 "The FBO to target for rendering this subtree.\n",
128 RenderTargetFieldId
, RenderTargetFieldMask
,
130 (Field::SFDefaultFlags
| Field::FStdAccess
),
131 static_cast<FieldEditMethodSig
>(&DynamicStateGenerator::editHandleRenderTarget
),
132 static_cast<FieldGetMethodSig
>(&DynamicStateGenerator::getHandleRenderTarget
));
134 oType
.addInitialDesc(pDesc
);
138 DynamicStateGeneratorBase::TypeObject
DynamicStateGeneratorBase::_type(
139 DynamicStateGeneratorBase::getClassname(),
140 Inherited::getClassname(),
143 reinterpret_cast<PrototypeCreateF
>(&DynamicStateGeneratorBase::createEmptyLocal
),
144 reinterpret_cast<InitContainerF
>(&DynamicStateGenerator::initMethod
),
145 reinterpret_cast<ExitContainerF
>(&DynamicStateGenerator::exitMethod
),
146 reinterpret_cast<InitalInsertDescFunc
>(
147 reinterpret_cast<void *>(&DynamicStateGenerator::classDescInserter
)),
150 "<?xml version=\"1.0\"?>\n"
153 " name=\"DynamicStateGenerator\"\n"
154 " parent=\"ChunkOverrideGroup\"\n"
155 " mixinparent=\"DynamicStateGeneratorParent\"\n"
156 " library=\"Group\"\n"
157 " pointerfieldtypes=\"both\"\n"
158 " structure=\"concrete\"\n"
159 " systemcomponent=\"true\"\n"
160 " parentsystemcomponent=\"true\"\n"
161 " decoratable=\"false\"\n"
162 " useLocalIncludes=\"false\"\n"
163 " isNodeCore=\"true\"\n"
164 " docGroupBase=\"GrpGroupDynamicStateGenerators\"\n"
166 " Base for dynamic materials like dynamic cube env maps\n"
168 " name=\"renderTarget\"\n"
169 " type=\"FrameBufferObjectPtr\"\n"
170 " cardinality=\"single\"\n"
171 " visibility=\"external\"\n"
172 " defaultValue=\"NULL\"\n"
173 " access=\"protected\"\n"
175 " The FBO to target for rendering this subtree.\n"
177 "</FieldContainer>\n",
178 "Base for dynamic materials like dynamic cube env maps\n"
181 /*------------------------------ get -----------------------------------*/
183 FieldContainerType
&DynamicStateGeneratorBase::getType(void)
188 const FieldContainerType
&DynamicStateGeneratorBase::getType(void) const
193 UInt32
DynamicStateGeneratorBase::getContainerSize(void) const
195 return sizeof(DynamicStateGenerator
);
198 /*------------------------- decorator get ------------------------------*/
201 //! Get the DynamicStateGenerator::_sfRenderTarget field.
202 const SFUnrecFrameBufferObjectPtr
*DynamicStateGeneratorBase::getSFRenderTarget(void) const
204 return &_sfRenderTarget
;
207 SFUnrecFrameBufferObjectPtr
*DynamicStateGeneratorBase::editSFRenderTarget (void)
209 editSField(RenderTargetFieldMask
);
211 return &_sfRenderTarget
;
214 //! Get the value of the DynamicStateGenerator::_sfRenderTarget field.
215 FrameBufferObject
* DynamicStateGeneratorBase::getRenderTarget(void) const
217 return _sfRenderTarget
.getValue();
220 //! Set the value of the DynamicStateGenerator::_sfRenderTarget field.
221 void DynamicStateGeneratorBase::setRenderTarget(FrameBufferObject
* const value
)
223 editSField(RenderTargetFieldMask
);
225 _sfRenderTarget
.setValue(value
);
233 /*------------------------------ access -----------------------------------*/
235 SizeT
DynamicStateGeneratorBase::getBinSize(ConstFieldMaskArg whichField
)
237 SizeT returnValue
= Inherited::getBinSize(whichField
);
239 if(FieldBits::NoField
!= (RenderTargetFieldMask
& whichField
))
241 returnValue
+= _sfRenderTarget
.getBinSize();
247 void DynamicStateGeneratorBase::copyToBin(BinaryDataHandler
&pMem
,
248 ConstFieldMaskArg whichField
)
250 Inherited::copyToBin(pMem
, whichField
);
252 if(FieldBits::NoField
!= (RenderTargetFieldMask
& whichField
))
254 _sfRenderTarget
.copyToBin(pMem
);
258 void DynamicStateGeneratorBase::copyFromBin(BinaryDataHandler
&pMem
,
259 ConstFieldMaskArg whichField
)
261 Inherited::copyFromBin(pMem
, whichField
);
263 if(FieldBits::NoField
!= (RenderTargetFieldMask
& whichField
))
265 editSField(RenderTargetFieldMask
);
266 _sfRenderTarget
.copyFromBin(pMem
);
270 //! create a new instance of the class
271 DynamicStateGeneratorTransitPtr
DynamicStateGeneratorBase::createLocal(BitVector bFlags
)
273 DynamicStateGeneratorTransitPtr fc
;
275 if(getClassType().getPrototype() != NULL
)
277 FieldContainerTransitPtr tmpPtr
=
278 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
280 fc
= dynamic_pointer_cast
<DynamicStateGenerator
>(tmpPtr
);
286 //! create a new instance of the class, copy the container flags
287 DynamicStateGeneratorTransitPtr
DynamicStateGeneratorBase::createDependent(BitVector bFlags
)
289 DynamicStateGeneratorTransitPtr fc
;
291 if(getClassType().getPrototype() != NULL
)
293 FieldContainerTransitPtr tmpPtr
=
294 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
296 fc
= dynamic_pointer_cast
<DynamicStateGenerator
>(tmpPtr
);
302 //! create a new instance of the class
303 DynamicStateGeneratorTransitPtr
DynamicStateGeneratorBase::create(void)
305 DynamicStateGeneratorTransitPtr fc
;
307 if(getClassType().getPrototype() != NULL
)
309 FieldContainerTransitPtr tmpPtr
=
310 getClassType().getPrototype()-> shallowCopy();
312 fc
= dynamic_pointer_cast
<DynamicStateGenerator
>(tmpPtr
);
318 DynamicStateGenerator
*DynamicStateGeneratorBase::createEmptyLocal(BitVector bFlags
)
320 DynamicStateGenerator
*returnValue
;
322 newPtr
<DynamicStateGenerator
>(returnValue
, bFlags
);
324 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
329 //! create an empty new instance of the class, do not copy the prototype
330 DynamicStateGenerator
*DynamicStateGeneratorBase::createEmpty(void)
332 DynamicStateGenerator
*returnValue
;
334 newPtr
<DynamicStateGenerator
>(returnValue
, Thread::getCurrentLocalFlags());
336 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
337 ~Thread::getCurrentLocalFlags();
343 FieldContainerTransitPtr
DynamicStateGeneratorBase::shallowCopyLocal(
344 BitVector bFlags
) const
346 DynamicStateGenerator
*tmpPtr
;
348 newPtr(tmpPtr
, dynamic_cast<const DynamicStateGenerator
*>(this), bFlags
);
350 FieldContainerTransitPtr
returnValue(tmpPtr
);
352 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
357 FieldContainerTransitPtr
DynamicStateGeneratorBase::shallowCopyDependent(
358 BitVector bFlags
) const
360 DynamicStateGenerator
*tmpPtr
;
362 newPtr(tmpPtr
, dynamic_cast<const DynamicStateGenerator
*>(this), ~bFlags
);
364 FieldContainerTransitPtr
returnValue(tmpPtr
);
366 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
371 FieldContainerTransitPtr
DynamicStateGeneratorBase::shallowCopy(void) const
373 DynamicStateGenerator
*tmpPtr
;
376 dynamic_cast<const DynamicStateGenerator
*>(this),
377 Thread::getCurrentLocalFlags());
379 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
381 FieldContainerTransitPtr
returnValue(tmpPtr
);
389 /*------------------------- constructors ----------------------------------*/
391 DynamicStateGeneratorBase::DynamicStateGeneratorBase(void) :
393 _sfRenderTarget (NULL
)
397 DynamicStateGeneratorBase::DynamicStateGeneratorBase(const DynamicStateGeneratorBase
&source
) :
399 _sfRenderTarget (NULL
)
404 /*-------------------------- destructors ----------------------------------*/
406 DynamicStateGeneratorBase::~DynamicStateGeneratorBase(void)
410 void DynamicStateGeneratorBase::onCreate(const DynamicStateGenerator
*source
)
412 Inherited::onCreate(source
);
416 DynamicStateGenerator
*pThis
= static_cast<DynamicStateGenerator
*>(this);
418 pThis
->setRenderTarget(source
->getRenderTarget());
422 GetFieldHandlePtr
DynamicStateGeneratorBase::getHandleRenderTarget (void) const
424 SFUnrecFrameBufferObjectPtr::GetHandlePtr
returnValue(
425 new SFUnrecFrameBufferObjectPtr::GetHandle(
427 this->getType().getFieldDesc(RenderTargetFieldId
),
428 const_cast<DynamicStateGeneratorBase
*>(this)));
433 EditFieldHandlePtr
DynamicStateGeneratorBase::editHandleRenderTarget (void)
435 SFUnrecFrameBufferObjectPtr::EditHandlePtr
returnValue(
436 new SFUnrecFrameBufferObjectPtr::EditHandle(
438 this->getType().getFieldDesc(RenderTargetFieldId
),
441 returnValue
->setSetMethod(
442 boost::bind(&DynamicStateGenerator::setRenderTarget
,
443 static_cast<DynamicStateGenerator
*>(this), _1
));
445 editSField(RenderTargetFieldMask
);
451 #ifdef OSG_MT_CPTR_ASPECT
452 void DynamicStateGeneratorBase::execSyncV( FieldContainer
&oFrom
,
453 ConstFieldMaskArg whichField
,
454 AspectOffsetStore
&oOffsets
,
455 ConstFieldMaskArg syncMode
,
456 const UInt32 uiSyncInfo
)
458 DynamicStateGenerator
*pThis
= static_cast<DynamicStateGenerator
*>(this);
460 pThis
->execSync(static_cast<DynamicStateGenerator
*>(&oFrom
),
469 #ifdef OSG_MT_CPTR_ASPECT
470 FieldContainer
*DynamicStateGeneratorBase::createAspectCopy(
471 const FieldContainer
*pRefAspect
) const
473 DynamicStateGenerator
*returnValue
;
475 newAspectCopy(returnValue
,
476 dynamic_cast<const DynamicStateGenerator
*>(pRefAspect
),
477 dynamic_cast<const DynamicStateGenerator
*>(this));
483 void DynamicStateGeneratorBase::resolveLinks(void)
485 Inherited::resolveLinks();
487 static_cast<DynamicStateGenerator
*>(this)->setRenderTarget(NULL
);