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"
65 #include "OSGAnimation.h" // Animation Class
67 #include "OSGAnimChannelBase.h"
68 #include "OSGAnimChannel.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::AnimChannel
79 Base for animation data sinks.
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var Animation * AnimChannelBase::_sfAnimation
90 /*! \var Real32 AnimChannelBase::_sfWeight
94 /*! \var Real32 AnimChannelBase::_sfInValue
99 /***************************************************************************\
100 * FieldType/FieldTrait Instantiation *
101 \***************************************************************************/
103 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
104 PointerType FieldTraits
<AnimChannel
*, nsOSG
>::_type(
107 AnimChannel::getClassType(),
111 OSG_FIELDTRAITS_GETTYPE_NS(AnimChannel
*, nsOSG
)
113 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
117 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
121 DataType
&FieldTraits
< AnimChannel
*, nsOSG
+ 1 >::getType(void)
123 return FieldTraits
<AnimChannel
*, nsOSG
>::getType();
127 OSG_EXPORT_PTR_SFIELD(ChildPointerSField
,
129 UnrecordedRefCountPolicy
,
133 OSG_EXPORT_PTR_MFIELD(ChildPointerMField
,
135 UnrecordedRefCountPolicy
,
139 /***************************************************************************\
140 * Field Description *
141 \***************************************************************************/
143 void AnimChannelBase::classDescInserter(TypeObject
&oType
)
145 FieldDescriptionBase
*pDesc
= NULL
;
148 pDesc
= new SFParentAnimationPtr::Description(
149 SFParentAnimationPtr::getClassType(),
152 AnimationFieldId
, AnimationFieldMask
,
154 (Field::FClusterLocal
),
155 static_cast <FieldEditMethodSig
>(&AnimChannel::invalidEditField
),
156 static_cast <FieldGetMethodSig
>(&AnimChannel::invalidGetField
));
158 oType
.addInitialDesc(pDesc
);
160 pDesc
= new SFReal32::Description(
161 SFReal32::getClassType(),
164 WeightFieldId
, WeightFieldMask
,
166 (Field::FClusterLocal
),
167 static_cast<FieldEditMethodSig
>(&AnimChannel::editHandleWeight
),
168 static_cast<FieldGetMethodSig
>(&AnimChannel::getHandleWeight
));
170 oType
.addInitialDesc(pDesc
);
172 pDesc
= new SFReal32::Description(
173 SFReal32::getClassType(),
176 InValueFieldId
, InValueFieldMask
,
178 (Field::FClusterLocal
),
179 static_cast<FieldEditMethodSig
>(&AnimChannel::editHandleInValue
),
180 static_cast<FieldGetMethodSig
>(&AnimChannel::getHandleInValue
));
182 oType
.addInitialDesc(pDesc
);
186 AnimChannelBase::TypeObject
AnimChannelBase::_type(
187 AnimChannelBase::getClassname(),
188 Inherited::getClassname(),
192 reinterpret_cast<InitContainerF
>(&AnimChannel::initMethod
),
193 reinterpret_cast<ExitContainerF
>(&AnimChannel::exitMethod
),
194 reinterpret_cast<InitalInsertDescFunc
>(
195 reinterpret_cast<void *>(&AnimChannel::classDescInserter
)),
198 "<?xml version=\"1.0\"?>\n"
201 " name=\"AnimChannel\"\n"
202 " parent=\"NodeCore\"\n"
203 " library=\"Dynamics\"\n"
204 " pointerfieldtypes=\"both\"\n"
205 " structure=\"abstract\"\n"
206 " systemcomponent=\"true\"\n"
207 " parentsystemcomponent=\"true\"\n"
208 " decoratable=\"false\"\n"
209 " useLocalIncludes=\"false\"\n"
210 " isNodeCore=\"true\"\n"
211 " isBundle=\"false\"\n"
212 " childFields=\"both\"\n"
213 " parentFields=\"none\"\n"
215 " Base for animation data sinks.\n"
218 " name=\"animation\"\n"
219 " category=\"parentpointer\"\n"
220 " type=\"Animation\"\n"
221 " cardinality=\"single\"\n"
222 " visibility=\"external\"\n"
224 " fieldFlags=\"FClusterLocal\"\n"
229 " category=\"data\"\n"
231 " cardinality=\"single\"\n"
232 " visibility=\"external\"\n"
233 " access=\"public\"\n"
234 " defaultValue=\"1.f\"\n"
235 " fieldFlags=\"FClusterLocal\"\n"
239 " name=\"inValue\"\n"
240 " category=\"data\"\n"
242 " cardinality=\"single\"\n"
243 " visibility=\"external\"\n"
244 " access=\"public\"\n"
245 " defaultValue=\"0.0\"\n"
246 " fieldFlags=\"FClusterLocal\"\n"
249 "</FieldContainer>\n",
250 "Base for animation data sinks.\n"
253 /*------------------------------ get -----------------------------------*/
255 FieldContainerType
&AnimChannelBase::getType(void)
260 const FieldContainerType
&AnimChannelBase::getType(void) const
265 UInt32
AnimChannelBase::getContainerSize(void) const
267 return sizeof(AnimChannel
);
270 /*------------------------- decorator get ------------------------------*/
274 SFReal32
*AnimChannelBase::editSFWeight(void)
276 editSField(WeightFieldMask
);
281 const SFReal32
*AnimChannelBase::getSFWeight(void) const
287 SFReal32
*AnimChannelBase::editSFInValue(void)
289 editSField(InValueFieldMask
);
294 const SFReal32
*AnimChannelBase::getSFInValue(void) const
304 /*------------------------------ access -----------------------------------*/
306 SizeT
AnimChannelBase::getBinSize(ConstFieldMaskArg whichField
)
308 SizeT returnValue
= Inherited::getBinSize(whichField
);
310 if(FieldBits::NoField
!= (AnimationFieldMask
& whichField
))
312 returnValue
+= _sfAnimation
.getBinSize();
314 if(FieldBits::NoField
!= (WeightFieldMask
& whichField
))
316 returnValue
+= _sfWeight
.getBinSize();
318 if(FieldBits::NoField
!= (InValueFieldMask
& whichField
))
320 returnValue
+= _sfInValue
.getBinSize();
326 void AnimChannelBase::copyToBin(BinaryDataHandler
&pMem
,
327 ConstFieldMaskArg whichField
)
329 Inherited::copyToBin(pMem
, whichField
);
331 if(FieldBits::NoField
!= (AnimationFieldMask
& whichField
))
333 _sfAnimation
.copyToBin(pMem
);
335 if(FieldBits::NoField
!= (WeightFieldMask
& whichField
))
337 _sfWeight
.copyToBin(pMem
);
339 if(FieldBits::NoField
!= (InValueFieldMask
& whichField
))
341 _sfInValue
.copyToBin(pMem
);
345 void AnimChannelBase::copyFromBin(BinaryDataHandler
&pMem
,
346 ConstFieldMaskArg whichField
)
348 Inherited::copyFromBin(pMem
, whichField
);
350 if(FieldBits::NoField
!= (AnimationFieldMask
& whichField
))
352 editSField(AnimationFieldMask
);
353 _sfAnimation
.copyFromBin(pMem
);
355 if(FieldBits::NoField
!= (WeightFieldMask
& whichField
))
357 editSField(WeightFieldMask
);
358 _sfWeight
.copyFromBin(pMem
);
360 if(FieldBits::NoField
!= (InValueFieldMask
& whichField
))
362 editSField(InValueFieldMask
);
363 _sfInValue
.copyFromBin(pMem
);
370 /*------------------------- constructors ----------------------------------*/
372 AnimChannelBase::AnimChannelBase(void) :
375 _sfWeight (Real32(1.f
)),
376 _sfInValue (Real32(0.0))
380 AnimChannelBase::AnimChannelBase(const AnimChannelBase
&source
) :
383 _sfWeight (source
._sfWeight
),
384 _sfInValue (source
._sfInValue
)
389 /*-------------------------- destructors ----------------------------------*/
391 AnimChannelBase::~AnimChannelBase(void)
394 /*-------------------------------------------------------------------------*/
397 bool AnimChannelBase::linkParent(
398 FieldContainer
* const pParent
,
399 UInt16
const childFieldId
,
400 UInt16
const parentFieldId
)
402 if(parentFieldId
== AnimationFieldId
)
404 Animation
* pTypedParent
=
405 dynamic_cast< Animation
* >(pParent
);
407 if(pTypedParent
!= NULL
)
409 FieldContainer
*pOldParent
=
410 _sfAnimation
.getValue ();
412 UInt16 oldChildFieldId
=
413 _sfAnimation
.getParentFieldPos();
415 if(pOldParent
!= NULL
)
417 pOldParent
->unlinkChild(this, oldChildFieldId
);
420 editSField(AnimationFieldMask
);
422 _sfAnimation
.setValue(static_cast<Animation
*>(pParent
), childFieldId
);
430 return Inherited::linkParent(pParent
, childFieldId
, parentFieldId
);
433 bool AnimChannelBase::unlinkParent(
434 FieldContainer
* const pParent
,
435 UInt16
const parentFieldId
)
437 if(parentFieldId
== AnimationFieldId
)
439 Animation
* pTypedParent
=
440 dynamic_cast< Animation
* >(pParent
);
442 if(pTypedParent
!= NULL
)
444 if(_sfAnimation
.getValue() == pTypedParent
)
446 editSField(AnimationFieldMask
);
448 _sfAnimation
.setValue(NULL
, 0xFFFF);
453 SWARNING
<< "Child ([" << this
454 << "] id [" << this->getId()
455 << "] type [" << this->getType().getCName()
456 << "] parentFieldId [" << parentFieldId
457 << "]) - Parent ([" << pParent
458 << "] id [" << pParent
->getId()
459 << "] type [" << pParent
->getType().getCName()
460 << "]): link inconsistent!"
469 return Inherited::unlinkParent(pParent
, parentFieldId
);
474 GetFieldHandlePtr
AnimChannelBase::getHandleAnimation (void) const
476 SFParentAnimationPtr::GetHandlePtr returnValue
;
481 EditFieldHandlePtr
AnimChannelBase::editHandleAnimation (void)
483 EditFieldHandlePtr returnValue
;
488 GetFieldHandlePtr
AnimChannelBase::getHandleWeight (void) const
490 SFReal32::GetHandlePtr
returnValue(
491 new SFReal32::GetHandle(
493 this->getType().getFieldDesc(WeightFieldId
),
494 const_cast<AnimChannelBase
*>(this)));
499 EditFieldHandlePtr
AnimChannelBase::editHandleWeight (void)
501 SFReal32::EditHandlePtr
returnValue(
502 new SFReal32::EditHandle(
504 this->getType().getFieldDesc(WeightFieldId
),
508 editSField(WeightFieldMask
);
513 GetFieldHandlePtr
AnimChannelBase::getHandleInValue (void) const
515 SFReal32::GetHandlePtr
returnValue(
516 new SFReal32::GetHandle(
518 this->getType().getFieldDesc(InValueFieldId
),
519 const_cast<AnimChannelBase
*>(this)));
524 EditFieldHandlePtr
AnimChannelBase::editHandleInValue (void)
526 SFReal32::EditHandlePtr
returnValue(
527 new SFReal32::EditHandle(
529 this->getType().getFieldDesc(InValueFieldId
),
533 editSField(InValueFieldMask
);
539 #ifdef OSG_MT_CPTR_ASPECT
540 void AnimChannelBase::execSyncV( FieldContainer
&oFrom
,
541 ConstFieldMaskArg whichField
,
542 AspectOffsetStore
&oOffsets
,
543 ConstFieldMaskArg syncMode
,
544 const UInt32 uiSyncInfo
)
546 AnimChannel
*pThis
= static_cast<AnimChannel
*>(this);
548 pThis
->execSync(static_cast<AnimChannel
*>(&oFrom
),
558 void AnimChannelBase::resolveLinks(void)
560 Inherited::resolveLinks();