1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/devel-api/common/owner-container.h>
23 #include <dali/internal/event/animation/key-frames-impl.h>
24 #include <dali/internal/event/animation/path-impl.h>
25 #include <dali/internal/update/nodes/node.h>
26 #include <dali/internal/update/common/property-base.h>
27 #include <dali/public-api/animation/alpha-function.h>
28 #include <dali/public-api/animation/animation.h>
29 #include <dali/public-api/animation/time-period.h>
30 #include <dali/public-api/common/constants.h>
31 #include <dali/public-api/common/dali-common.h>
32 #include <dali/public-api/math/quaternion.h>
33 #include <dali/public-api/math/radian.h>
34 #include <dali/internal/update/animation/property-accessor.h>
35 #include <dali/integration-api/debug.h>
43 typedef Dali::Animation::Interpolation Interpolation;
45 struct AnimatorFunctionBase;
52 typedef OwnerContainer< AnimatorBase* > AnimatorContainer;
54 typedef AnimatorContainer::Iterator AnimatorIter;
55 typedef AnimatorContainer::ConstIterator AnimatorConstIter;
58 * An abstract base class for Animators, which can be added to scene graph animations.
59 * Each animator changes a single property of an object in the scene graph.
65 typedef float (*AlphaFunc)(float progress); ///< Definition of an alpha function
71 : mDurationSeconds(1.0f),
72 mIntervalDelaySeconds(0.0f),
75 mAlphaFunction(AlphaFunction::DEFAULT),
76 mDisconnectAction(Dali::Animation::BakeFinal),
79 mConnectedToSceneGraph(false),
80 mAutoReverseEnabled( false )
87 virtual ~AnimatorBase()
92 * Called when Animator is added to the scene-graph in update-thread.
94 virtual void ConnectToSceneGraph() = 0;
97 * Set the duration of the animator.
98 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
99 * @param [in] seconds Duration in seconds.
101 void SetDuration(float seconds)
103 DALI_ASSERT_DEBUG(seconds >= 0.0f);
105 mDurationSeconds = seconds;
109 * Retrieve the duration of the animator.
110 * @return The duration in seconds.
112 float GetDuration() const
114 return mDurationSeconds;
117 void SetSpeedFactor( float factor )
119 mSpeedFactor = factor;
122 void SetLoopCount(int loopCount)
124 mLoopCount = loopCount;
127 float SetProgress( float progress )
131 if( mAutoReverseEnabled )
133 if( mSpeedFactor > 0.0f )
135 value = 1.0f - 2.0f * std::abs( progress - 0.5f );
138 else if( mSpeedFactor < 0.0f )
140 value = 2.0f * std::abs( progress - 0.5f );
148 * Set the delay before the animator should take effect.
149 * The default is zero i.e. no delay.
150 * @param [in] seconds The delay in seconds.
152 void SetIntervalDelay(float seconds)
154 mIntervalDelaySeconds = seconds;
158 * Retrieve the delay before the animator should take effect.
159 * @return The delay in seconds.
161 float GetIntervalDelay() const
163 return mIntervalDelaySeconds;
167 * Set the alpha function for an animator.
168 * @param [in] alphaFunc The alpha function to apply to the animation progress.
170 void SetAlphaFunction(const AlphaFunction& alphaFunction)
172 mAlphaFunction = alphaFunction;
176 * Retrieve the alpha function of an animator.
177 * @return The function.
179 AlphaFunction GetAlphaFunction() const
181 return mAlphaFunction;
185 * Applies the alpha function to the specified progress
186 * @param[in] Current progress
187 * @return The progress after the alpha function has been aplied
189 float ApplyAlphaFunction( float progress ) const
191 float result = progress;
193 AlphaFunction::Mode alphaFunctionMode( mAlphaFunction.GetMode() );
194 if( alphaFunctionMode == AlphaFunction::BUILTIN_FUNCTION )
196 switch(mAlphaFunction.GetBuiltinFunction())
198 case AlphaFunction::DEFAULT:
199 case AlphaFunction::LINEAR:
203 case AlphaFunction::REVERSE:
205 result = 1.0f-progress;
208 case AlphaFunction::EASE_IN_SQUARE:
210 result = progress * progress;
213 case AlphaFunction::EASE_OUT_SQUARE:
215 result = 1.0f - (1.0f-progress) * (1.0f-progress);
218 case AlphaFunction::EASE_IN:
220 result = progress * progress * progress;
223 case AlphaFunction::EASE_OUT:
225 result = (progress-1.0f) * (progress-1.0f) * (progress-1.0f) + 1.0f;
228 case AlphaFunction::EASE_IN_OUT:
230 result = progress*progress*(3.0f-2.0f*progress);
233 case AlphaFunction::EASE_IN_SINE:
235 result = -1.0f * cosf(progress * Math::PI_2) + 1.0f;
238 case AlphaFunction::EASE_OUT_SINE:
240 result = sinf(progress * Math::PI_2);
243 case AlphaFunction::EASE_IN_OUT_SINE:
245 result = -0.5f * (cosf(Math::PI * progress) - 1.0f);
248 case AlphaFunction::BOUNCE:
250 result = sinf(progress * Math::PI);
253 case AlphaFunction::SIN:
255 result = 0.5f - cosf(progress * 2.0f * Math::PI) * 0.5f;
258 case AlphaFunction::EASE_OUT_BACK:
260 const float sqrt2 = 1.70158f;
262 result = 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 );
265 case AlphaFunction::COUNT:
271 else if( alphaFunctionMode == AlphaFunction::CUSTOM_FUNCTION )
273 AlphaFunctionPrototype customFunction = mAlphaFunction.GetCustomFunction();
276 result = customFunction(progress);
281 //If progress is very close to 0 or very close to 1 we don't need to evaluate the curve as the result will
282 //be almost 0 or almost 1 respectively
283 if( ( progress > Math::MACHINE_EPSILON_1 ) && ((1.0f - progress) > Math::MACHINE_EPSILON_1) )
285 Dali::Vector4 controlPoints = mAlphaFunction.GetBezierControlPoints();
287 static const float tolerance = 0.001f; //10 iteration max
289 //Perform a binary search on the curve
290 float lowerBound(0.0f);
291 float upperBound(1.0f);
292 float currentT(0.5f);
293 float currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
294 while( fabs( progress - currentX ) > tolerance )
296 if( progress > currentX )
298 lowerBound = currentT;
302 upperBound = currentT;
304 currentT = (upperBound+lowerBound)*0.5f;
305 currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
307 result = EvaluateCubicBezier( controlPoints.y, controlPoints.w, currentT);
315 * Whether to bake the animation if attached property owner is disconnected.
316 * Property is only baked if the animator is active.
317 * @param [in] action The disconnect action.
319 void SetDisconnectAction( Dali::Animation::EndAction action )
321 mDisconnectAction = action;
325 * Retrieve the disconnect action of an animator.
326 * @return The disconnect action.
328 Dali::Animation::EndAction GetDisconnectAction() const
330 return mDisconnectAction;
334 * Whether the animator is active or not.
335 * @param [in] active The new active state.
336 * @post When the animator becomes active, it applies the disconnect-action if the property owner is then disconnected.
337 * @note When the property owner is disconnected, the active state is set to false.
339 void SetActive( bool active )
345 * Retrieve whether the animator has been set to active or not.
346 * @return The active state.
348 bool GetActive() const
354 * Retrive wheter the animator's target object is valid and on the stage.
355 * @return The enabled state.
357 bool IsEnabled() const
363 * @brief Sets the looping mode.
364 * @param[in] loopingMode True when the looping mode is AUTO_REVERSE
366 void SetLoopingMode( bool loopingMode )
368 mAutoReverseEnabled = loopingMode;
372 * Returns wheter the target object of the animator is still valid
373 * or has been destroyed.
374 * @return True if animator is orphan, false otherwise *
375 * @note The SceneGraph::Animation will delete any orphan animator in its Update method.
377 virtual bool Orphan() = 0;
380 * Update the scene object attached to the animator.
381 * @param[in] bufferIndex The buffer to animate.
382 * @param[in] progress A value from 0 to 1, where 0 is the start of the animation, and 1 is the end point.
383 * @param[in] bake Bake.
385 virtual void Update(BufferIndex bufferIndex, float progress, bool bake) = 0;
390 * Helper function to evaluate a cubic bezier curve assuming first point is at 0.0 and last point is at 1.0
391 * @param[in] p0 First control point of the bezier curve
392 * @param[in] p1 Second control point of the bezier curve
393 * @param[in] t A floating point value between 0.0 and 1.0
394 * @return Value of the curve at progress t
396 inline float EvaluateCubicBezier( float p0, float p1, float t ) const
399 return 3.0f*(1.0f-t)*(1.0f-t)*t*p0 + 3.0f*(1.0f-t)*tSquare*p1 + tSquare*t;
402 float mDurationSeconds;
403 float mIntervalDelaySeconds;
408 AlphaFunction mAlphaFunction;
410 Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
411 bool mActive:1; ///< Animator is "active" while it's running.
412 bool mEnabled:1; ///< Animator is "enabled" while its target object is valid and on the stage.
413 bool mConnectedToSceneGraph:1; ///< True if ConnectToSceneGraph() has been called in update-thread.
414 bool mAutoReverseEnabled:1;
418 * An animator for a specific property type PropertyType.
420 template < typename PropertyType, typename PropertyAccessorType >
421 class Animator : public AnimatorBase, public PropertyOwner::Observer
426 * Construct a new property animator.
427 * @param[in] property The animatable property; only valid while the Animator is attached.
428 * @param[in] animatorFunction The function used to animate the property.
429 * @param[in] alphaFunction The alpha function to apply.
430 * @param[in] timePeriod The time period of this animation.
431 * @return A newly allocated animator.
433 static AnimatorBase* New( const PropertyOwner& propertyOwner,
434 const PropertyBase& property,
435 AnimatorFunctionBase* animatorFunction,
436 AlphaFunction alphaFunction,
437 const TimePeriod& timePeriod )
439 typedef Animator< PropertyType, PropertyAccessorType > AnimatorType;
441 // The property was const in the actor-thread, but animators are used in the scene-graph thread.
442 AnimatorType* animator = new AnimatorType( const_cast<PropertyOwner*>( &propertyOwner ),
443 const_cast<PropertyBase*>( &property ),
446 animator->SetAlphaFunction( alphaFunction );
447 animator->SetIntervalDelay( timePeriod.delaySeconds );
448 animator->SetDuration( timePeriod.durationSeconds );
454 * Virtual destructor.
458 if (mPropertyOwner && mConnectedToSceneGraph)
460 mPropertyOwner->RemoveObserver(*this);
463 delete mAnimatorFunction;
467 * Called when Animator is added to the scene-graph in update-thread.
469 virtual void ConnectToSceneGraph()
471 mConnectedToSceneGraph = true;
472 mPropertyOwner->AddObserver(*this);
476 * Called when mPropertyOwner is connected to the scene graph.
478 virtual void PropertyOwnerConnected( PropertyOwner& owner )
484 * Called when mPropertyOwner is disconnected from the scene graph.
486 virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
488 // If we are active, then bake the value if required
489 if ( mActive && mDisconnectAction != Dali::Animation::Discard )
491 // Bake to target-value if BakeFinal, otherwise bake current value
492 Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
500 * Called shortly before mPropertyOwner is destroyed
502 virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
504 mPropertyOwner = NULL;
510 virtual void Update( BufferIndex bufferIndex, float progress, bool bake )
512 if( mLoopCount != 1 ) // Looping mode
514 // Update the progress value
515 progress = SetProgress( progress );
518 float alpha = ApplyAlphaFunction( progress );
520 const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
522 const PropertyType result = (*mAnimatorFunction)( alpha, current );
525 mPropertyAccessor.Bake( bufferIndex, result );
529 mPropertyAccessor.Set( bufferIndex, result );
532 mCurrentProgress = progress;
538 virtual bool Orphan()
540 return (mPropertyOwner == NULL);
546 * Private constructor; see also Animator::New().
548 Animator( PropertyOwner* propertyOwner,
549 PropertyBase* property,
550 AnimatorFunctionBase* animatorFunction )
551 : mPropertyOwner( propertyOwner ),
552 mPropertyAccessor( property ),
553 mAnimatorFunction( animatorFunction ),
554 mCurrentProgress( 0.0f )
556 // WARNING - this object is created in the event-thread
557 // The scene-graph mPropertyOwner object cannot be observed here
561 Animator( const Animator& );
564 Animator& operator=( const Animator& );
568 PropertyOwner* mPropertyOwner;
569 PropertyAccessorType mPropertyAccessor;
571 AnimatorFunctionBase* mAnimatorFunction;
572 float mCurrentProgress;
578 * An animator for a specific property type PropertyType.
580 template <typename T, typename PropertyAccessorType>
581 class AnimatorTransformProperty : public AnimatorBase, public PropertyOwner::Observer
586 * Construct a new property animator.
587 * @param[in] property The animatable property; only valid while the Animator is attached.
588 * @param[in] animatorFunction The function used to animate the property.
589 * @param[in] alphaFunction The alpha function to apply.
590 * @param[in] timePeriod The time period of this animation.
591 * @return A newly allocated animator.
593 static AnimatorBase* New( const PropertyOwner& propertyOwner,
594 const PropertyBase& property,
595 AnimatorFunctionBase* animatorFunction,
596 AlphaFunction alphaFunction,
597 const TimePeriod& timePeriod )
600 // The property was const in the actor-thread, but animators are used in the scene-graph thread.
601 AnimatorTransformProperty* animator = new AnimatorTransformProperty( const_cast<PropertyOwner*>( &propertyOwner ),
602 const_cast<PropertyBase*>( &property ),
605 animator->SetAlphaFunction( alphaFunction );
606 animator->SetIntervalDelay( timePeriod.delaySeconds );
607 animator->SetDuration( timePeriod.durationSeconds );
613 * Virtual destructor.
615 virtual ~AnimatorTransformProperty()
617 if (mPropertyOwner && mConnectedToSceneGraph)
619 mPropertyOwner->RemoveObserver(*this);
622 delete mAnimatorFunction;
626 * Called when Animator is added to the scene-graph in update-thread.
628 virtual void ConnectToSceneGraph()
630 mConnectedToSceneGraph = true;
631 mPropertyOwner->AddObserver(*this);
635 * Called when mPropertyOwner is connected to the scene graph.
637 virtual void PropertyOwnerConnected( PropertyOwner& owner )
643 * Called when mPropertyOwner is disconnected from the scene graph.
645 virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
647 // If we are active, then bake the value if required
648 if ( mActive && mDisconnectAction != Dali::Animation::Discard )
650 // Bake to target-value if BakeFinal, otherwise bake current value
651 Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
659 * Called shortly before mPropertyOwner is destroyed
661 virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
663 mPropertyOwner = NULL;
669 virtual void Update( BufferIndex bufferIndex, float progress, bool bake )
671 if( mLoopCount != 1 ) // Looping mode
673 // Update the progress value
674 progress = SetProgress( progress );
677 float alpha = ApplyAlphaFunction( progress );
679 const T& current = mPropertyAccessor.Get( bufferIndex );
681 const T result = (*mAnimatorFunction)( alpha, current );
686 mPropertyAccessor.Bake( bufferIndex, result );
690 mPropertyAccessor.Set( bufferIndex, result );
693 mCurrentProgress = progress;
699 virtual bool Orphan()
701 return (mPropertyOwner == NULL);
707 * Private constructor; see also Animator::New().
709 AnimatorTransformProperty( PropertyOwner* propertyOwner,
710 PropertyBase* property,
711 AnimatorFunctionBase* animatorFunction )
712 : mPropertyOwner( propertyOwner ),
713 mPropertyAccessor( property ),
714 mAnimatorFunction( animatorFunction ),
715 mCurrentProgress( 0.0f )
717 // WARNING - this object is created in the event-thread
718 // The scene-graph mPropertyOwner object cannot be observed here
722 AnimatorTransformProperty( const AnimatorTransformProperty& );
725 AnimatorTransformProperty& operator=( const AnimatorTransformProperty& );
729 PropertyOwner* mPropertyOwner;
730 PropertyAccessorType mPropertyAccessor;
732 AnimatorFunctionBase* mAnimatorFunction;
733 float mCurrentProgress;
736 } // namespace SceneGraph
739 * AnimatorFunction base class.
740 * All update functions must inherit from AnimatorFunctionBase and overload the appropiate "()" operator
742 struct AnimatorFunctionBase
747 AnimatorFunctionBase(){}
750 * Virtual destructor (Intended as base class)
752 virtual ~AnimatorFunctionBase(){}
754 ///Stub "()" operators.
755 virtual bool operator()(float progress, const bool& property)
760 virtual float operator()(float progress, const int& property)
765 virtual float operator()(float progress, const unsigned int& property)
770 virtual float operator()(float progress, const float& property)
775 virtual Vector2 operator()(float progress, const Vector2& property)
780 virtual Vector3 operator()(float progress, const Vector3& property)
785 virtual Vector4 operator()(float progress, const Vector4& property)
790 virtual Quaternion operator()(float progress, const Quaternion& property)
798 struct AnimateByInteger : public AnimatorFunctionBase
800 AnimateByInteger(const int& relativeValue)
801 : mRelative(relativeValue)
805 using AnimatorFunctionBase::operator();
806 float operator()(float alpha, const int& property)
808 return int(property + mRelative * alpha + 0.5f );
814 struct AnimateToInteger : public AnimatorFunctionBase
816 AnimateToInteger(const int& targetValue)
817 : mTarget(targetValue)
821 using AnimatorFunctionBase::operator();
822 float operator()(float alpha, const int& property)
824 return int(property + ((mTarget - property) * alpha) + 0.5f);
830 struct AnimateByFloat : public AnimatorFunctionBase
832 AnimateByFloat(const float& relativeValue)
833 : mRelative(relativeValue)
837 using AnimatorFunctionBase::operator();
838 float operator()(float alpha, const float& property)
840 return float(property + mRelative * alpha);
846 struct AnimateToFloat : public AnimatorFunctionBase
848 AnimateToFloat(const float& targetValue)
849 : mTarget(targetValue)
853 using AnimatorFunctionBase::operator();
854 float operator()(float alpha, const float& property)
856 return float(property + ((mTarget - property) * alpha));
862 struct AnimateByVector2 : public AnimatorFunctionBase
864 AnimateByVector2(const Vector2& relativeValue)
865 : mRelative(relativeValue)
869 using AnimatorFunctionBase::operator();
870 Vector2 operator()(float alpha, const Vector2& property)
872 return Vector2(property + mRelative * alpha);
878 struct AnimateToVector2 : public AnimatorFunctionBase
880 AnimateToVector2(const Vector2& targetValue)
881 : mTarget(targetValue)
885 using AnimatorFunctionBase::operator();
886 Vector2 operator()(float alpha, const Vector2& property)
888 return Vector2(property + ((mTarget - property) * alpha));
894 struct AnimateByVector3 : public AnimatorFunctionBase
896 AnimateByVector3(const Vector3& relativeValue)
897 : mRelative(relativeValue)
901 using AnimatorFunctionBase::operator();
902 Vector3 operator()(float alpha, const Vector3& property)
904 return Vector3(property + mRelative * alpha);
910 struct AnimateToVector3 : public AnimatorFunctionBase
912 AnimateToVector3(const Vector3& targetValue)
913 : mTarget(targetValue)
917 using AnimatorFunctionBase::operator();
918 Vector3 operator()(float alpha, const Vector3& property)
920 return Vector3(property + ((mTarget - property) * alpha));
926 struct AnimateByVector4 : public AnimatorFunctionBase
928 AnimateByVector4(const Vector4& relativeValue)
929 : mRelative(relativeValue)
933 using AnimatorFunctionBase::operator();
934 Vector4 operator()(float alpha, const Vector4& property)
936 return Vector4(property + mRelative * alpha);
942 struct AnimateToVector4 : public AnimatorFunctionBase
944 AnimateToVector4(const Vector4& targetValue)
945 : mTarget(targetValue)
949 using AnimatorFunctionBase::operator();
950 Vector4 operator()(float alpha, const Vector4& property)
952 return Vector4(property + ((mTarget - property) * alpha));
958 struct AnimateByOpacity : public AnimatorFunctionBase
960 AnimateByOpacity(const float& relativeValue)
961 : mRelative(relativeValue)
965 using AnimatorFunctionBase::operator();
966 Vector4 operator()(float alpha, const Vector4& property)
968 Vector4 result(property);
969 result.a += mRelative * alpha;
977 struct AnimateToOpacity : public AnimatorFunctionBase
979 AnimateToOpacity(const float& targetValue)
980 : mTarget(targetValue)
984 using AnimatorFunctionBase::operator();
985 Vector4 operator()(float alpha, const Vector4& property)
987 Vector4 result(property);
988 result.a = property.a + ((mTarget - property.a) * alpha);
996 struct AnimateByBoolean : public AnimatorFunctionBase
998 AnimateByBoolean(bool relativeValue)
999 : mRelative(relativeValue)
1003 using AnimatorFunctionBase::operator();
1004 bool operator()(float alpha, const bool& property)
1006 // Alpha is not useful here, just keeping to the same template as other update functors
1007 return bool(alpha >= 1.0f ? (property || mRelative) : property);
1013 struct AnimateToBoolean : public AnimatorFunctionBase
1015 AnimateToBoolean(bool targetValue)
1016 : mTarget(targetValue)
1020 using AnimatorFunctionBase::operator();
1021 bool operator()(float alpha, const bool& property)
1023 // Alpha is not useful here, just keeping to the same template as other update functors
1024 return bool(alpha >= 1.0f ? mTarget : property);
1030 struct RotateByAngleAxis : public AnimatorFunctionBase
1032 RotateByAngleAxis(const Radian& angleRadians, const Vector3& axis)
1033 : mAngleRadians( angleRadians ),
1034 mAxis(axis.x, axis.y, axis.z)
1038 using AnimatorFunctionBase::operator();
1039 Quaternion operator()(float alpha, const Quaternion& rotation)
1043 return rotation * Quaternion(mAngleRadians * alpha, mAxis);
1049 Radian mAngleRadians;
1053 struct RotateToQuaternion : public AnimatorFunctionBase
1055 RotateToQuaternion(const Quaternion& targetValue)
1056 : mTarget(targetValue)
1060 using AnimatorFunctionBase::operator();
1061 Quaternion operator()(float alpha, const Quaternion& rotation)
1063 return Quaternion::Slerp(rotation, mTarget, alpha);
1070 struct KeyFrameBooleanFunctor : public AnimatorFunctionBase
1072 KeyFrameBooleanFunctor(KeyFrameBooleanPtr keyFrames)
1073 : mKeyFrames(keyFrames)
1077 using AnimatorFunctionBase::operator();
1078 bool operator()(float progress, const bool& property)
1080 if(mKeyFrames->IsActive(progress))
1082 return mKeyFrames->GetValue(progress, Dali::Animation::Linear);
1087 KeyFrameBooleanPtr mKeyFrames;
1090 struct KeyFrameIntegerFunctor : public AnimatorFunctionBase
1092 KeyFrameIntegerFunctor(KeyFrameIntegerPtr keyFrames, Interpolation interpolation)
1093 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1097 using AnimatorFunctionBase::operator();
1098 float operator()(float progress, const int& property)
1100 if(mKeyFrames->IsActive(progress))
1102 return mKeyFrames->GetValue(progress, mInterpolation);
1107 KeyFrameIntegerPtr mKeyFrames;
1108 Interpolation mInterpolation;
1111 struct KeyFrameNumberFunctor : public AnimatorFunctionBase
1113 KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation)
1114 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1118 using AnimatorFunctionBase::operator();
1119 float operator()(float progress, const float& property)
1121 if(mKeyFrames->IsActive(progress))
1123 return mKeyFrames->GetValue(progress, mInterpolation);
1128 KeyFrameNumberPtr mKeyFrames;
1129 Interpolation mInterpolation;
1132 struct KeyFrameVector2Functor : public AnimatorFunctionBase
1134 KeyFrameVector2Functor(KeyFrameVector2Ptr keyFrames, Interpolation interpolation)
1135 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1139 using AnimatorFunctionBase::operator();
1140 Vector2 operator()(float progress, const Vector2& property)
1142 if(mKeyFrames->IsActive(progress))
1144 return mKeyFrames->GetValue(progress, mInterpolation);
1149 KeyFrameVector2Ptr mKeyFrames;
1150 Interpolation mInterpolation;
1154 struct KeyFrameVector3Functor : public AnimatorFunctionBase
1156 KeyFrameVector3Functor(KeyFrameVector3Ptr keyFrames, Interpolation interpolation)
1157 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1161 using AnimatorFunctionBase::operator();
1162 Vector3 operator()(float progress, const Vector3& property)
1164 if(mKeyFrames->IsActive(progress))
1166 return mKeyFrames->GetValue(progress, mInterpolation);
1171 KeyFrameVector3Ptr mKeyFrames;
1172 Interpolation mInterpolation;
1175 struct KeyFrameVector4Functor : public AnimatorFunctionBase
1177 KeyFrameVector4Functor(KeyFrameVector4Ptr keyFrames, Interpolation interpolation)
1178 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1182 using AnimatorFunctionBase::operator();
1183 Vector4 operator()(float progress, const Vector4& property)
1185 if(mKeyFrames->IsActive(progress))
1187 return mKeyFrames->GetValue(progress, mInterpolation);
1192 KeyFrameVector4Ptr mKeyFrames;
1193 Interpolation mInterpolation;
1196 struct KeyFrameQuaternionFunctor : public AnimatorFunctionBase
1198 KeyFrameQuaternionFunctor(KeyFrameQuaternionPtr keyFrames)
1199 : mKeyFrames(keyFrames)
1203 using AnimatorFunctionBase::operator();
1204 Quaternion operator()(float progress, const Quaternion& property)
1206 if(mKeyFrames->IsActive(progress))
1208 return mKeyFrames->GetValue(progress, Dali::Animation::Linear);
1213 KeyFrameQuaternionPtr mKeyFrames;
1216 struct PathPositionFunctor : public AnimatorFunctionBase
1218 PathPositionFunctor( PathPtr path )
1223 using AnimatorFunctionBase::operator();
1224 Vector3 operator()(float progress, const Vector3& property)
1226 Vector3 position(property);
1227 static_cast<void>( mPath->SamplePosition(progress, position) );
1234 struct PathRotationFunctor : public AnimatorFunctionBase
1236 PathRotationFunctor( PathPtr path, const Vector3& forward )
1240 mForward.Normalize();
1243 using AnimatorFunctionBase::operator();
1244 Quaternion operator()(float progress, const Quaternion& property)
1247 if( mPath->SampleTangent(progress, tangent) )
1249 return Quaternion( mForward, tangent );
1261 } // namespace Internal
1265 #endif // __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__