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 SkinningAlgorithm!
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 "OSGSkinnedGeometry.h" // Skin Class
66 #include "OSGSkeleton.h" // Skeleton Class
68 #include "OSGSkinningAlgorithmBase.h"
69 #include "OSGSkinningAlgorithm.h"
71 #include <boost/bind.hpp>
75 /***************************************************************************\
77 \***************************************************************************/
79 /*! \class OSG::SkinningAlgorithm
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var SkinnedGeometry * SkinningAlgorithmBase::_sfSkin
91 /*! \var Skeleton * SkinningAlgorithmBase::_sfSkeleton
96 /***************************************************************************\
97 * FieldType/FieldTrait Instantiation *
98 \***************************************************************************/
100 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
101 PointerType FieldTraits
<SkinningAlgorithm
*, nsOSG
>::_type(
102 "SkinningAlgorithmPtr",
104 SkinningAlgorithm::getClassType(),
108 OSG_FIELDTRAITS_GETTYPE_NS(SkinningAlgorithm
*, nsOSG
)
110 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
114 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
118 DataType
&FieldTraits
< SkinningAlgorithm
*, nsOSG
+ 1 >::getType(void)
120 return FieldTraits
<SkinningAlgorithm
*, nsOSG
>::getType();
124 OSG_EXPORT_PTR_SFIELD(ChildPointerSField
,
126 UnrecordedRefCountPolicy
,
130 OSG_EXPORT_PTR_MFIELD(ChildPointerMField
,
132 UnrecordedRefCountPolicy
,
136 /***************************************************************************\
137 * Field Description *
138 \***************************************************************************/
140 void SkinningAlgorithmBase::classDescInserter(TypeObject
&oType
)
142 FieldDescriptionBase
*pDesc
= NULL
;
145 pDesc
= new SFParentSkinnedGeometryPtr::Description(
146 SFParentSkinnedGeometryPtr::getClassType(),
149 SkinFieldId
, SkinFieldMask
,
151 (Field::SFDefaultFlags
| Field::FStdAccess
),
152 static_cast <FieldEditMethodSig
>(&SkinningAlgorithm::invalidEditField
),
153 static_cast <FieldGetMethodSig
>(&SkinningAlgorithm::invalidGetField
));
155 oType
.addInitialDesc(pDesc
);
157 pDesc
= new SFUnrecSkeletonPtr::Description(
158 SFUnrecSkeletonPtr::getClassType(),
161 SkeletonFieldId
, SkeletonFieldMask
,
163 (Field::SFDefaultFlags
| Field::FStdAccess
),
164 static_cast<FieldEditMethodSig
>(&SkinningAlgorithm::editHandleSkeleton
),
165 static_cast<FieldGetMethodSig
>(&SkinningAlgorithm::getHandleSkeleton
));
167 oType
.addInitialDesc(pDesc
);
171 SkinningAlgorithmBase::TypeObject
SkinningAlgorithmBase::_type(
172 SkinningAlgorithmBase::getClassname(),
173 Inherited::getClassname(),
177 reinterpret_cast<InitContainerF
>(&SkinningAlgorithm::initMethod
),
178 reinterpret_cast<ExitContainerF
>(&SkinningAlgorithm::exitMethod
),
179 reinterpret_cast<InitalInsertDescFunc
>(
180 reinterpret_cast<void *>(&SkinningAlgorithm::classDescInserter
)),
183 "<?xml version=\"1.0\"?>\n"
186 " name=\"SkinningAlgorithm\"\n"
187 " parent=\"Algorithm\"\n"
188 " library=\"Dynamics\"\n"
189 " pointerfieldtypes=\"both\"\n"
190 " structure=\"abstract\"\n"
191 " systemcomponent=\"true\"\n"
192 " parentsystemcomponent=\"true\"\n"
193 " decoratable=\"false\"\n"
194 " childFields=\"both\"\n"
195 " parentFields=\"none\"\n"
199 " type=\"SkinnedGeometry\"\n"
200 " category=\"parentpointer\"\n"
201 " cardinality=\"single\"\n"
202 " visibility=\"external\"\n"
204 " defaultValue=\"NULL\"\n"
209 " name=\"skeleton\"\n"
210 " type=\"Skeleton\"\n"
211 " category=\"pointer\"\n"
212 " cardinality=\"single\"\n"
213 " visibility=\"external\"\n"
214 " access=\"public\"\n"
215 " defaultValue=\"NULL\"\n"
219 "</FieldContainer>\n",
223 /*------------------------------ get -----------------------------------*/
225 FieldContainerType
&SkinningAlgorithmBase::getType(void)
230 const FieldContainerType
&SkinningAlgorithmBase::getType(void) const
235 UInt32
SkinningAlgorithmBase::getContainerSize(void) const
237 return sizeof(SkinningAlgorithm
);
240 /*------------------------- decorator get ------------------------------*/
244 //! Get the SkinningAlgorithm::_sfSkeleton field.
245 const SFUnrecSkeletonPtr
*SkinningAlgorithmBase::getSFSkeleton(void) const
250 SFUnrecSkeletonPtr
*SkinningAlgorithmBase::editSFSkeleton (void)
252 editSField(SkeletonFieldMask
);
257 //! Get the value of the SkinningAlgorithm::_sfSkeleton field.
258 Skeleton
* SkinningAlgorithmBase::getSkeleton(void) const
260 return _sfSkeleton
.getValue();
263 //! Set the value of the SkinningAlgorithm::_sfSkeleton field.
264 void SkinningAlgorithmBase::setSkeleton(Skeleton
* const value
)
266 editSField(SkeletonFieldMask
);
268 _sfSkeleton
.setValue(value
);
276 /*------------------------------ access -----------------------------------*/
278 SizeT
SkinningAlgorithmBase::getBinSize(ConstFieldMaskArg whichField
)
280 SizeT returnValue
= Inherited::getBinSize(whichField
);
282 if(FieldBits::NoField
!= (SkinFieldMask
& whichField
))
284 returnValue
+= _sfSkin
.getBinSize();
286 if(FieldBits::NoField
!= (SkeletonFieldMask
& whichField
))
288 returnValue
+= _sfSkeleton
.getBinSize();
294 void SkinningAlgorithmBase::copyToBin(BinaryDataHandler
&pMem
,
295 ConstFieldMaskArg whichField
)
297 Inherited::copyToBin(pMem
, whichField
);
299 if(FieldBits::NoField
!= (SkinFieldMask
& whichField
))
301 _sfSkin
.copyToBin(pMem
);
303 if(FieldBits::NoField
!= (SkeletonFieldMask
& whichField
))
305 _sfSkeleton
.copyToBin(pMem
);
309 void SkinningAlgorithmBase::copyFromBin(BinaryDataHandler
&pMem
,
310 ConstFieldMaskArg whichField
)
312 Inherited::copyFromBin(pMem
, whichField
);
314 if(FieldBits::NoField
!= (SkinFieldMask
& whichField
))
316 editSField(SkinFieldMask
);
317 _sfSkin
.copyFromBin(pMem
);
319 if(FieldBits::NoField
!= (SkeletonFieldMask
& whichField
))
321 editSField(SkeletonFieldMask
);
322 _sfSkeleton
.copyFromBin(pMem
);
329 /*------------------------- constructors ----------------------------------*/
331 SkinningAlgorithmBase::SkinningAlgorithmBase(void) :
338 SkinningAlgorithmBase::SkinningAlgorithmBase(const SkinningAlgorithmBase
&source
) :
346 /*-------------------------- destructors ----------------------------------*/
348 SkinningAlgorithmBase::~SkinningAlgorithmBase(void)
351 /*-------------------------------------------------------------------------*/
354 bool SkinningAlgorithmBase::linkParent(
355 FieldContainer
* const pParent
,
356 UInt16
const childFieldId
,
357 UInt16
const parentFieldId
)
359 if(parentFieldId
== SkinFieldId
)
361 SkinnedGeometry
* pTypedParent
=
362 dynamic_cast< SkinnedGeometry
* >(pParent
);
364 if(pTypedParent
!= NULL
)
366 FieldContainer
*pOldParent
=
369 UInt16 oldChildFieldId
=
370 _sfSkin
.getParentFieldPos();
372 if(pOldParent
!= NULL
)
374 pOldParent
->unlinkChild(this, oldChildFieldId
);
377 editSField(SkinFieldMask
);
379 _sfSkin
.setValue(static_cast<SkinnedGeometry
*>(pParent
), childFieldId
);
387 return Inherited::linkParent(pParent
, childFieldId
, parentFieldId
);
390 bool SkinningAlgorithmBase::unlinkParent(
391 FieldContainer
* const pParent
,
392 UInt16
const parentFieldId
)
394 if(parentFieldId
== SkinFieldId
)
396 SkinnedGeometry
* pTypedParent
=
397 dynamic_cast< SkinnedGeometry
* >(pParent
);
399 if(pTypedParent
!= NULL
)
401 if(_sfSkin
.getValue() == pTypedParent
)
403 editSField(SkinFieldMask
);
405 _sfSkin
.setValue(NULL
, 0xFFFF);
410 SWARNING
<< "Child ([" << this
411 << "] id [" << this->getId()
412 << "] type [" << this->getType().getCName()
413 << "] parentFieldId [" << parentFieldId
414 << "]) - Parent ([" << pParent
415 << "] id [" << pParent
->getId()
416 << "] type [" << pParent
->getType().getCName()
417 << "]): link inconsistent!"
426 return Inherited::unlinkParent(pParent
, parentFieldId
);
430 void SkinningAlgorithmBase::onCreate(const SkinningAlgorithm
*source
)
432 Inherited::onCreate(source
);
436 SkinningAlgorithm
*pThis
= static_cast<SkinningAlgorithm
*>(this);
438 pThis
->setSkeleton(source
->getSkeleton());
442 GetFieldHandlePtr
SkinningAlgorithmBase::getHandleSkin (void) const
444 SFParentSkinnedGeometryPtr::GetHandlePtr returnValue
;
449 EditFieldHandlePtr
SkinningAlgorithmBase::editHandleSkin (void)
451 EditFieldHandlePtr returnValue
;
456 GetFieldHandlePtr
SkinningAlgorithmBase::getHandleSkeleton (void) const
458 SFUnrecSkeletonPtr::GetHandlePtr
returnValue(
459 new SFUnrecSkeletonPtr::GetHandle(
461 this->getType().getFieldDesc(SkeletonFieldId
),
462 const_cast<SkinningAlgorithmBase
*>(this)));
467 EditFieldHandlePtr
SkinningAlgorithmBase::editHandleSkeleton (void)
469 SFUnrecSkeletonPtr::EditHandlePtr
returnValue(
470 new SFUnrecSkeletonPtr::EditHandle(
472 this->getType().getFieldDesc(SkeletonFieldId
),
475 returnValue
->setSetMethod(
476 boost::bind(&SkinningAlgorithm::setSkeleton
,
477 static_cast<SkinningAlgorithm
*>(this), _1
));
479 editSField(SkeletonFieldMask
);
485 #ifdef OSG_MT_CPTR_ASPECT
486 void SkinningAlgorithmBase::execSyncV( FieldContainer
&oFrom
,
487 ConstFieldMaskArg whichField
,
488 AspectOffsetStore
&oOffsets
,
489 ConstFieldMaskArg syncMode
,
490 const UInt32 uiSyncInfo
)
492 SkinningAlgorithm
*pThis
= static_cast<SkinningAlgorithm
*>(this);
494 pThis
->execSync(static_cast<SkinningAlgorithm
*>(&oFrom
),
504 void SkinningAlgorithmBase::resolveLinks(void)
506 Inherited::resolveLinks();
508 static_cast<SkinningAlgorithm
*>(this)->setSkeleton(NULL
);