1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
5 * Copyright (c) 2014 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>
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 mInitialDelaySeconds(0.0f),
73 mAlphaFunction(AlphaFunction::DEFAULT),
74 mDisconnectAction(Dali::Animation::BakeFinal),
77 mConnectedToSceneGraph(false)
84 virtual ~AnimatorBase()
89 * Called when Animator is added to the scene-graph in update-thread.
91 virtual void ConnectToSceneGraph() = 0;
94 * Set the duration of the animator.
95 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
96 * @param [in] seconds Duration in seconds.
98 void SetDuration(float seconds)
100 DALI_ASSERT_DEBUG(seconds >= 0.0f);
102 mDurationSeconds = seconds;
106 * Retrieve the duration of the animator.
107 * @return The duration in seconds.
111 return mDurationSeconds;
115 * Set the delay before the animator should take effect.
116 * The default is zero i.e. no delay.
117 * @param [in] seconds The delay in seconds.
119 void SetInitialDelay(float seconds)
121 mInitialDelaySeconds = seconds;
125 * Retrieve the initial delay of the animator.
126 * @return The delay in seconds.
128 float GetInitialDelay()
130 return mInitialDelaySeconds;
134 * Set the alpha function for an animator.
135 * @param [in] alphaFunc The alpha function to apply to the animation progress.
137 void SetAlphaFunction(const AlphaFunction& alphaFunction)
139 mAlphaFunction = alphaFunction;
143 * Retrieve the alpha function of an animator.
144 * @return The function.
146 AlphaFunction GetAlphaFunction() const
148 return mAlphaFunction;
152 * Applies the alpha function to the specified progress
153 * @param[in] Current progress
154 * @return The progress after the alpha function has been aplied
156 float ApplyAlphaFunction( float progress ) const
158 float result = progress;
160 AlphaFunction::Mode alphaFunctionMode( mAlphaFunction.GetMode() );
161 if( alphaFunctionMode == AlphaFunction::BUILTIN_FUNCTION )
163 switch(mAlphaFunction.GetBuiltinFunction())
165 case AlphaFunction::DEFAULT:
166 case AlphaFunction::LINEAR:
170 case AlphaFunction::REVERSE:
172 result = 1.0f-progress;
175 case AlphaFunction::EASE_IN_SQUARE:
177 result = progress * progress;
180 case AlphaFunction::EASE_OUT_SQUARE:
182 result = 1.0f - (1.0f-progress) * (1.0f-progress);
185 case AlphaFunction::EASE_IN:
187 result = progress * progress * progress;
190 case AlphaFunction::EASE_OUT:
192 result = (progress-1.0f) * (progress-1.0f) * (progress-1.0f) + 1.0f;
195 case AlphaFunction::EASE_IN_OUT:
197 result = progress*progress*(3.0f-2.0f*progress);
200 case AlphaFunction::EASE_IN_SINE:
202 result = -1.0f * cosf(progress * Math::PI_2) + 1.0f;
205 case AlphaFunction::EASE_OUT_SINE:
207 result = sinf(progress * Math::PI_2);
210 case AlphaFunction::EASE_IN_OUT_SINE:
212 result = -0.5f * (cosf(Math::PI * progress) - 1.0f);
215 case AlphaFunction::BOUNCE:
217 result = sinf(progress * Math::PI);
220 case AlphaFunction::SIN:
222 result = 0.5f - cosf(progress * 2.0f * Math::PI) * 0.5f;
225 case AlphaFunction::EASE_OUT_BACK:
227 const float sqrt2 = 1.70158f;
229 result = 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 );
232 case AlphaFunction::COUNT:
238 else if( alphaFunctionMode == AlphaFunction::CUSTOM_FUNCTION )
240 AlphaFunctionPrototype customFunction = mAlphaFunction.GetCustomFunction();
243 result = customFunction(progress);
248 //If progress is very close to 0 or very close to 1 we don't need to evaluate the curve as the result will
249 //be almost 0 or almost 1 respectively
250 if( ( progress > Math::MACHINE_EPSILON_1 ) && ((1.0f - progress) > Math::MACHINE_EPSILON_1) )
252 Dali::Vector4 controlPoints = mAlphaFunction.GetBezierControlPoints();
254 static const float tolerance = 0.001f; //10 iteration max
256 //Perform a binary search on the curve
257 float lowerBound(0.0f);
258 float upperBound(1.0f);
259 float currentT(0.5f);
260 float currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
261 while( fabs( progress - currentX ) > tolerance )
263 if( progress > currentX )
265 lowerBound = currentT;
269 upperBound = currentT;
271 currentT = (upperBound+lowerBound)*0.5f;
272 currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
274 result = EvaluateCubicBezier( controlPoints.y, controlPoints.w, currentT);
282 * Whether to bake the animation if attached property owner is disconnected.
283 * Property is only baked if the animator is active.
284 * @param [in] action The disconnect action.
286 void SetDisconnectAction( Dali::Animation::EndAction action )
288 mDisconnectAction = action;
292 * Retrieve the disconnect action of an animator.
293 * @return The disconnect action.
295 Dali::Animation::EndAction GetDisconnectAction() const
297 return mDisconnectAction;
301 * Whether the animator is active or not.
302 * @param [in] active The new active state.
303 * @post When the animator becomes active, it applies the disconnect-action if the property owner is then disconnected.
304 * @note When the property owner is disconnected, the active state is set to false.
306 void SetActive( bool active )
312 * Retrieve whether the animator has been set to active or not.
313 * @return The active state.
315 bool GetActive() const
321 * Retrive wheter the animator's target object is valid and on the stage.
322 * @return The enabled state.
324 bool IsEnabled() const
329 * Returns wheter the target object of the animator is still valid
330 * or has been destroyed.
331 * @return True if animator is orphan, false otherwise *
332 * @note The SceneGraph::Animation will delete any orphan animator in its Update method.
334 virtual bool Orphan() = 0;
337 * Update the scene object attached to the animator.
338 * @param[in] bufferIndex The buffer to animate.
339 * @param[in] progress A value from 0 to 1, where 0 is the start of the animation, and 1 is the end point.
340 * @param[in] bake Bake.
342 virtual void Update(BufferIndex bufferIndex, float progress, bool bake) = 0;
347 * Helper function to evaluate a cubic bezier curve assuming first point is at 0.0 and last point is at 1.0
348 * @param[in] p0 First control point of the bezier curve
349 * @param[in] p1 Second control point of the bezier curve
350 * @param[in] t A floating point value between 0.0 and 1.0
351 * @return Value of the curve at progress t
353 inline float EvaluateCubicBezier( float p0, float p1, float t ) const
356 return 3.0f*(1.0f-t)*(1.0f-t)*t*p0 + 3.0f*(1.0f-t)*tSquare*p1 + tSquare*t;
359 float mDurationSeconds;
360 float mInitialDelaySeconds;
362 AlphaFunction mAlphaFunction;
364 Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
365 bool mActive:1; ///< Animator is "active" while it's running.
366 bool mEnabled:1; ///< Animator is "enabled" while its target object is valid and on the stage.
367 bool mConnectedToSceneGraph:1; ///< True if ConnectToSceneGraph() has been called in update-thread.
371 * An animator for a specific property type PropertyType.
373 template < typename PropertyType, typename PropertyAccessorType >
374 class Animator : public AnimatorBase, public PropertyOwner::Observer
379 * Construct a new property animator.
380 * @param[in] property The animatable property; only valid while the Animator is attached.
381 * @param[in] animatorFunction The function used to animate the property.
382 * @param[in] alphaFunction The alpha function to apply.
383 * @param[in] timePeriod The time period of this animation.
384 * @return A newly allocated animator.
386 static AnimatorBase* New( const PropertyOwner& propertyOwner,
387 const PropertyBase& property,
388 AnimatorFunctionBase* animatorFunction,
389 AlphaFunction alphaFunction,
390 const TimePeriod& timePeriod )
392 typedef Animator< PropertyType, PropertyAccessorType > AnimatorType;
394 // The property was const in the actor-thread, but animators are used in the scene-graph thread.
395 AnimatorType* animator = new AnimatorType( const_cast<PropertyOwner*>( &propertyOwner ),
396 const_cast<PropertyBase*>( &property ),
399 animator->SetAlphaFunction( alphaFunction );
400 animator->SetInitialDelay( timePeriod.delaySeconds );
401 animator->SetDuration( timePeriod.durationSeconds );
407 * Virtual destructor.
411 if (mPropertyOwner && mConnectedToSceneGraph)
413 mPropertyOwner->RemoveObserver(*this);
416 delete mAnimatorFunction;
420 * Called when Animator is added to the scene-graph in update-thread.
422 virtual void ConnectToSceneGraph()
424 mConnectedToSceneGraph = true;
425 mPropertyOwner->AddObserver(*this);
429 * Called when mPropertyOwner is connected to the scene graph.
431 virtual void PropertyOwnerConnected( PropertyOwner& owner )
437 * Called when mPropertyOwner is disconnected from the scene graph.
439 virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
441 // If we are active, then bake the value if required
442 if ( mActive && mDisconnectAction != Dali::Animation::Discard )
444 // Bake to target-value if BakeFinal, otherwise bake current value
445 Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
453 * Called shortly before mPropertyOwner is destroyed
455 virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
457 mPropertyOwner = NULL;
463 virtual void Update( BufferIndex bufferIndex, float progress, bool bake )
465 float alpha = ApplyAlphaFunction(progress);
467 const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
469 const PropertyType result = (*mAnimatorFunction)( alpha, current );
472 mPropertyAccessor.Bake( bufferIndex, result );
476 mPropertyAccessor.Set( bufferIndex, result );
479 mCurrentProgress = progress;
485 virtual bool Orphan()
487 return (mPropertyOwner == NULL);
493 * Private constructor; see also Animator::New().
495 Animator( PropertyOwner* propertyOwner,
496 PropertyBase* property,
497 AnimatorFunctionBase* animatorFunction )
498 : mPropertyOwner( propertyOwner ),
499 mPropertyAccessor( property ),
500 mAnimatorFunction( animatorFunction ),
501 mCurrentProgress( 0.0f )
503 // WARNING - this object is created in the event-thread
504 // The scene-graph mPropertyOwner object cannot be observed here
508 Animator( const Animator& );
511 Animator& operator=( const Animator& );
515 PropertyOwner* mPropertyOwner;
516 PropertyAccessorType mPropertyAccessor;
518 AnimatorFunctionBase* mAnimatorFunction;
519 float mCurrentProgress;
525 * An animator for a specific property type PropertyType.
527 template <typename T, typename PropertyAccessorType>
528 class AnimatorTransformProperty : public AnimatorBase, public PropertyOwner::Observer
533 * Construct a new property animator.
534 * @param[in] property The animatable property; only valid while the Animator is attached.
535 * @param[in] animatorFunction The function used to animate the property.
536 * @param[in] alphaFunction The alpha function to apply.
537 * @param[in] timePeriod The time period of this animation.
538 * @return A newly allocated animator.
540 static AnimatorBase* New( const PropertyOwner& propertyOwner,
541 const PropertyBase& property,
542 AnimatorFunctionBase* animatorFunction,
543 AlphaFunction alphaFunction,
544 const TimePeriod& timePeriod )
547 // The property was const in the actor-thread, but animators are used in the scene-graph thread.
548 AnimatorTransformProperty* animator = new AnimatorTransformProperty( const_cast<PropertyOwner*>( &propertyOwner ),
549 const_cast<PropertyBase*>( &property ),
552 animator->SetAlphaFunction( alphaFunction );
553 animator->SetInitialDelay( timePeriod.delaySeconds );
554 animator->SetDuration( timePeriod.durationSeconds );
560 * Virtual destructor.
562 virtual ~AnimatorTransformProperty()
564 if (mPropertyOwner && mConnectedToSceneGraph)
566 mPropertyOwner->RemoveObserver(*this);
569 delete mAnimatorFunction;
573 * Called when Animator is added to the scene-graph in update-thread.
575 virtual void ConnectToSceneGraph()
577 mConnectedToSceneGraph = true;
578 mPropertyOwner->AddObserver(*this);
582 * Called when mPropertyOwner is connected to the scene graph.
584 virtual void PropertyOwnerConnected( PropertyOwner& owner )
590 * Called when mPropertyOwner is disconnected from the scene graph.
592 virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
594 // If we are active, then bake the value if required
595 if ( mActive && mDisconnectAction != Dali::Animation::Discard )
597 // Bake to target-value if BakeFinal, otherwise bake current value
598 Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
606 * Called shortly before mPropertyOwner is destroyed
608 virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
610 mPropertyOwner = NULL;
616 virtual void Update( BufferIndex bufferIndex, float progress, bool bake )
618 float alpha = ApplyAlphaFunction(progress);
620 const T& current = mPropertyAccessor.Get( bufferIndex );
622 const T result = (*mAnimatorFunction)( alpha, current );
627 mPropertyAccessor.Bake( bufferIndex, result );
631 mPropertyAccessor.Set( bufferIndex, result );
634 mCurrentProgress = progress;
640 virtual bool Orphan()
642 return (mPropertyOwner == NULL);
648 * Private constructor; see also Animator::New().
650 AnimatorTransformProperty( PropertyOwner* propertyOwner,
651 PropertyBase* property,
652 AnimatorFunctionBase* animatorFunction )
653 : mPropertyOwner( propertyOwner ),
654 mPropertyAccessor( property ),
655 mAnimatorFunction( animatorFunction ),
656 mCurrentProgress( 0.0f )
658 // WARNING - this object is created in the event-thread
659 // The scene-graph mPropertyOwner object cannot be observed here
663 AnimatorTransformProperty( const AnimatorTransformProperty& );
666 AnimatorTransformProperty& operator=( const AnimatorTransformProperty& );
670 PropertyOwner* mPropertyOwner;
671 PropertyAccessorType mPropertyAccessor;
673 AnimatorFunctionBase* mAnimatorFunction;
674 float mCurrentProgress;
677 } // namespace SceneGraph
680 * AnimatorFunction base class.
681 * All update functions must inherit from AnimatorFunctionBase and overload the appropiate "()" operator
683 struct AnimatorFunctionBase
688 AnimatorFunctionBase(){}
691 * Virtual destructor (Intended as base class)
693 virtual ~AnimatorFunctionBase(){}
695 ///Stub "()" operators.
696 virtual bool operator()(float progress, const bool& property)
701 virtual float operator()(float progress, const int& property)
706 virtual float operator()(float progress, const unsigned int& property)
711 virtual float operator()(float progress, const float& property)
716 virtual Vector2 operator()(float progress, const Vector2& property)
721 virtual Vector3 operator()(float progress, const Vector3& property)
726 virtual Vector4 operator()(float progress, const Vector4& property)
731 virtual Quaternion operator()(float progress, const Quaternion& property)
739 struct AnimateByInteger : public AnimatorFunctionBase
741 AnimateByInteger(const int& relativeValue)
742 : mRelative(relativeValue)
746 float operator()(float alpha, const int& property)
748 return int(property + mRelative * alpha + 0.5f );
754 struct AnimateToInteger : public AnimatorFunctionBase
756 AnimateToInteger(const int& targetValue)
757 : mTarget(targetValue)
761 float operator()(float alpha, const int& property)
763 return int(property + ((mTarget - property) * alpha) + 0.5f);
769 struct AnimateByFloat : public AnimatorFunctionBase
771 AnimateByFloat(const float& relativeValue)
772 : mRelative(relativeValue)
776 float operator()(float alpha, const float& property)
778 return float(property + mRelative * alpha);
784 struct AnimateToFloat : public AnimatorFunctionBase
786 AnimateToFloat(const float& targetValue)
787 : mTarget(targetValue)
791 float operator()(float alpha, const float& property)
793 return float(property + ((mTarget - property) * alpha));
799 struct AnimateByVector2 : public AnimatorFunctionBase
801 AnimateByVector2(const Vector2& relativeValue)
802 : mRelative(relativeValue)
806 Vector2 operator()(float alpha, const Vector2& property)
808 return Vector2(property + mRelative * alpha);
814 struct AnimateToVector2 : public AnimatorFunctionBase
816 AnimateToVector2(const Vector2& targetValue)
817 : mTarget(targetValue)
821 Vector2 operator()(float alpha, const Vector2& property)
823 return Vector2(property + ((mTarget - property) * alpha));
829 struct AnimateByVector3 : public AnimatorFunctionBase
831 AnimateByVector3(const Vector3& relativeValue)
832 : mRelative(relativeValue)
836 Vector3 operator()(float alpha, const Vector3& property)
838 return Vector3(property + mRelative * alpha);
844 struct AnimateToVector3 : public AnimatorFunctionBase
846 AnimateToVector3(const Vector3& targetValue)
847 : mTarget(targetValue)
851 Vector3 operator()(float alpha, const Vector3& property)
853 return Vector3(property + ((mTarget - property) * alpha));
859 struct AnimateByVector4 : public AnimatorFunctionBase
861 AnimateByVector4(const Vector4& relativeValue)
862 : mRelative(relativeValue)
866 Vector4 operator()(float alpha, const Vector4& property)
868 return Vector4(property + mRelative * alpha);
874 struct AnimateToVector4 : public AnimatorFunctionBase
876 AnimateToVector4(const Vector4& targetValue)
877 : mTarget(targetValue)
881 Vector4 operator()(float alpha, const Vector4& property)
883 return Vector4(property + ((mTarget - property) * alpha));
889 struct AnimateByOpacity : public AnimatorFunctionBase
891 AnimateByOpacity(const float& relativeValue)
892 : mRelative(relativeValue)
896 Vector4 operator()(float alpha, const Vector4& property)
898 Vector4 result(property);
899 result.a += mRelative * alpha;
907 struct AnimateToOpacity : public AnimatorFunctionBase
909 AnimateToOpacity(const float& targetValue)
910 : mTarget(targetValue)
914 Vector4 operator()(float alpha, const Vector4& property)
916 Vector4 result(property);
917 result.a = property.a + ((mTarget - property.a) * alpha);
925 struct AnimateByBoolean : public AnimatorFunctionBase
927 AnimateByBoolean(bool relativeValue)
928 : mRelative(relativeValue)
932 bool operator()(float alpha, const bool& property)
934 // Alpha is not useful here, just keeping to the same template as other update functors
935 return bool(alpha >= 1.0f ? (property || mRelative) : property);
941 struct AnimateToBoolean : public AnimatorFunctionBase
943 AnimateToBoolean(bool targetValue)
944 : mTarget(targetValue)
948 bool operator()(float alpha, const bool& property)
950 // Alpha is not useful here, just keeping to the same template as other update functors
951 return bool(alpha >= 1.0f ? mTarget : property);
957 struct RotateByAngleAxis : public AnimatorFunctionBase
959 RotateByAngleAxis(const Radian& angleRadians, const Vector3& axis)
960 : mAngleRadians( angleRadians ),
961 mAxis(axis.x, axis.y, axis.z)
965 Quaternion operator()(float alpha, const Quaternion& rotation)
969 return rotation * Quaternion(mAngleRadians * alpha, mAxis);
975 Radian mAngleRadians;
979 struct RotateToQuaternion : public AnimatorFunctionBase
981 RotateToQuaternion(const Quaternion& targetValue)
982 : mTarget(targetValue)
986 Quaternion operator()(float alpha, const Quaternion& rotation)
988 return Quaternion::Slerp(rotation, mTarget, alpha);
995 struct KeyFrameBooleanFunctor : public AnimatorFunctionBase
997 KeyFrameBooleanFunctor(KeyFrameBooleanPtr keyFrames)
998 : mKeyFrames(keyFrames)
1002 bool operator()(float progress, const bool& property)
1004 if(mKeyFrames->IsActive(progress))
1006 return mKeyFrames->GetValue(progress, Dali::Animation::Linear);
1011 KeyFrameBooleanPtr mKeyFrames;
1014 struct KeyFrameIntegerFunctor : public AnimatorFunctionBase
1016 KeyFrameIntegerFunctor(KeyFrameIntegerPtr keyFrames, Interpolation interpolation)
1017 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1021 float operator()(float progress, const int& property)
1023 if(mKeyFrames->IsActive(progress))
1025 return mKeyFrames->GetValue(progress, mInterpolation);
1030 KeyFrameIntegerPtr mKeyFrames;
1031 Interpolation mInterpolation;
1034 struct KeyFrameNumberFunctor : public AnimatorFunctionBase
1036 KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation)
1037 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1041 float operator()(float progress, const float& property)
1043 if(mKeyFrames->IsActive(progress))
1045 return mKeyFrames->GetValue(progress, mInterpolation);
1050 KeyFrameNumberPtr mKeyFrames;
1051 Interpolation mInterpolation;
1054 struct KeyFrameVector2Functor : public AnimatorFunctionBase
1056 KeyFrameVector2Functor(KeyFrameVector2Ptr keyFrames, Interpolation interpolation)
1057 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1061 Vector2 operator()(float progress, const Vector2& property)
1063 if(mKeyFrames->IsActive(progress))
1065 return mKeyFrames->GetValue(progress, mInterpolation);
1070 KeyFrameVector2Ptr mKeyFrames;
1071 Interpolation mInterpolation;
1075 struct KeyFrameVector3Functor : public AnimatorFunctionBase
1077 KeyFrameVector3Functor(KeyFrameVector3Ptr keyFrames, Interpolation interpolation)
1078 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1082 Vector3 operator()(float progress, const Vector3& property)
1084 if(mKeyFrames->IsActive(progress))
1086 return mKeyFrames->GetValue(progress, mInterpolation);
1091 KeyFrameVector3Ptr mKeyFrames;
1092 Interpolation mInterpolation;
1095 struct KeyFrameVector4Functor : public AnimatorFunctionBase
1097 KeyFrameVector4Functor(KeyFrameVector4Ptr keyFrames, Interpolation interpolation)
1098 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1102 Vector4 operator()(float progress, const Vector4& property)
1104 if(mKeyFrames->IsActive(progress))
1106 return mKeyFrames->GetValue(progress, mInterpolation);
1111 KeyFrameVector4Ptr mKeyFrames;
1112 Interpolation mInterpolation;
1115 struct KeyFrameQuaternionFunctor : public AnimatorFunctionBase
1117 KeyFrameQuaternionFunctor(KeyFrameQuaternionPtr keyFrames)
1118 : mKeyFrames(keyFrames)
1122 Quaternion operator()(float progress, const Quaternion& property)
1124 if(mKeyFrames->IsActive(progress))
1126 return mKeyFrames->GetValue(progress, Dali::Animation::Linear);
1131 KeyFrameQuaternionPtr mKeyFrames;
1134 struct PathPositionFunctor : public AnimatorFunctionBase
1136 PathPositionFunctor( PathPtr path )
1141 Vector3 operator()(float progress, const Vector3& property)
1143 Vector3 position(property);
1144 static_cast<void>( mPath->SamplePosition(progress, position) );
1151 struct PathRotationFunctor : public AnimatorFunctionBase
1153 PathRotationFunctor( PathPtr path, const Vector3& forward )
1157 mForward.Normalize();
1160 Quaternion operator()(float progress, const Quaternion& property)
1163 if( mPath->SampleTangent(progress, tangent) )
1165 return Quaternion( mForward, tangent );
1177 } // namespace Internal
1181 #endif // __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__