41 #ifndef INCLUDED_GLS_ANIMATION_H
42 #define INCLUDED_GLS_ANIMATION_H
48 #include "weak_reference.h"
54 class DistiAttributeBase;
60 typedef stdortr1::shared_ptr<GlsAnimation>
Ptr;
81 virtual Key
GetKey()
const = 0;
86 virtual void SetKey(
const Key& key ) = 0;
99 virtual void Reset() = 0;
102 const std::string&
GetName()
const {
return _name; }
150 typedef stdortr1::shared_ptr<GlsKeyframeAnimation>
Ptr;
267 DistiAttributeBase& LookupResourceAttribute( DisplayFrame* displayFrame,
const std::string& propertyName );
268 bool HandleSpecialCases( DisplayFrame* displayFrame );
279 std::string _propertyName;
280 WeakRef<DistiAttributeBase> _attr;
281 WeakRef<DisplayObject> _object;
284 std::string _lastEmitted;
286 #if GLS_VERSION_MAJOR == 4 && GLS_VERSION_MINOR < 5
287 bool _isDynamicTranslate;
288 #endif // GLS Version < 4.5
296 typedef stdortr1::shared_ptr<GlsAnimationCollection>
Ptr;
347 void SetKey(
const Key& key );
372 typedef std::vector<GlsAnimation::Ptr> AnimationList;
373 typedef AnimationList::const_iterator AnimationIter;
379 AnimationList _animationList;
394 , _animation( animation )
396 DistiAssert( animation );
406 , _animation( animation )
408 DistiAssert( animation );
409 _minMax = animation->GetMinMaxKeys();
415 return _animation->SetDisplayFrame( displayFrame );
421 return _animation->IsReadyToAnimate();
427 return _minMax.second - _animation->GetKey() + _minMax.first;
433 _animation->SetKey( _minMax.second - key + _minMax.first );
439 return _animation->GetKeyRange();
445 return _animation->GetMinMaxKeys();
457 return _animation->GetPropertyNames();
463 _animation->RetargetPropertyNames( propertyNames );
469 _animation->RetargetPropertyNames( findStr, replaceStr );
481 return _animation->CountPropertyNames();
489 typedef GlsAnimationReversalAdapter GlsAnimationReverser;
515 , _animation( animation )
516 , _currentKey( Detail::g_nan )
518 DistiAssert( animation );
519 Init( clampLimits, newMinMax );
535 , _animation( animation )
536 , _currentKey( Detail::g_nan )
538 DistiAssert( animation );
539 Init( clampLimits, newMinMax );
545 return _animation->SetDisplayFrame( displayFrame );
551 return _animation->IsReadyToAnimate();
568 Key clampedKey = ( key - _remappedMinMax.first )
569 / ( _remappedMinMax.second - _remappedMinMax.first )
570 * ( _animationMinMax.second - _animationMinMax.first )
571 + _animationMinMax.first;
573 clampedKey = ( std::max )( ( std::min )( clampedKey, _clampLimits.second ), _clampLimits.first );
575 _animation->SetKey( clampedKey );
582 return minMaxKeys.second - minMaxKeys.first;
588 if( _remappedMinMax == _animationMinMax )
594 return _remappedMinMax;
607 return _animation->GetPropertyNames();
613 _animation->RetargetPropertyNames( propertyNames );
619 _animation->RetargetPropertyNames( findStr, replaceStr );
631 return _animation->CountPropertyNames();
637 const bool isMinMaxNaN = Detail::IsNaN( newMinMax.first ) || Detail::IsNaN( newMinMax.second );
640 DistiAssert( clampLimits.first <= clampLimits.second );
641 DistiAssert( newMinMax.first <= newMinMax.second || isMinMaxNaN );
645 _animationMinMax = _animation->GetMinMaxKeys();
646 _clampLimits = std::make_pair(
647 ( std::max )( clampLimits.first, _animationMinMax.first ),
648 ( std::min )( clampLimits.second, _animationMinMax.second ) );
652 _remappedMinMax = _animationMinMax;
656 _remappedMinMax = newMinMax;
680 #ifdef GLS_ANIMATION_ENABLE_ZIP_LOADING
681 std::vector<GlsAnimation::Ptr> LoadAnimationZip(
const std::string& filename );
692 const std::string g_linearInterpTag =
"linear";
693 const std::string g_gatedInterpTag =
"gated";
694 const std::string g_slerpTag =
"slerp";
695 const std::string g_quadInTag =
"quadraticIn";
696 const std::string g_quadOutTag =
"quadraticOut";
697 const std::string g_quadInOUtTag =
"quadraticInAndOut";
698 const std::string g_cubeInTag =
"cubicIn";
699 const std::string g_cubeOutTag =
"cubicOut";
700 const std::string g_cubeInOutTag =
"cubicInAndOut";
701 const std::string g_quartInTag =
"quarticIn";
702 const std::string g_quartOutTag =
"quarticOut";
703 const std::string g_quartInOutTag =
"quarticInAndOut";
704 const std::string g_quintInTag =
"quinticIn";
705 const std::string g_quintOutTag =
"quinticOut";
706 const std::string g_quintInOutTag =
"quinticInAndOut";
707 const std::string g_sinInTag =
"sinusoidalIn";
708 const std::string g_sinOutTag =
"sinusoidalOut";
709 const std::string g_sinInOutTag =
"sinusoidalInAndOut";
710 const std::string g_expoInTag =
"exponentIn";
711 const std::string g_expoOutTag =
"exponentOut";
712 const std::string g_expoInOutTag =
"exponentInAndOut";
713 const std::string g_circleInTag =
"circularIn";
714 const std::string g_circleOutTag =
"circularOut";
715 const std::string g_circleInOutTag =
"circularInAndOut";
716 const std::string g_elasticInTag =
"elasticIn";
717 const std::string g_elasticOutTag =
"elasticOut";
718 const std::string g_elasticInOutTag =
"elasticInAndOut";
719 const std::string g_bounceInTag =
"bounceIn";
720 const std::string g_bounceOutTag =
"bounceOut";
721 const std::string g_bounceInOutTag =
"bounceInAndOut";
722 const std::string g_backInTag =
"backIn";
723 const std::string g_backOutTag =
"backOut";
724 const std::string g_backInOutTag =
"backInAndOut";
730 template<
bool B,
class T =
void>
741 template<
typename T,
typename U>
760 template<
typename T,
typename U,
typename V>
783 template<
class T,
class U>
792 static Big Test( ... );
793 static Small Test( U );
799 value =
sizeof( Small ) ==
sizeof( ( Test( MakeT() ) ) )
838 template<
class Value>
846 template<
class Value>
849 std::cerr <<
"GlsAnimation: Slerp requested for a type that does not support it.\n";
859 template<
class Value>
860 typename GlsKeyframeInterpolator<Value>::Ptr CreateInterpolator(
const std::string& name,
typename Detail::enable_if<!Detail::is_same2<Value, glsColor, std::string>::value>::type* = 0 )
866 else if( name == g_linearInterpTag )
870 else if( name == g_gatedInterpTag )
874 else if( name == g_slerpTag )
876 return Detail::CreateSlerp<Value>();
878 else if( name == g_quadInTag )
882 else if( name == g_quadOutTag )
886 else if( name == g_quadInOUtTag )
890 else if( name == g_cubeInTag )
894 else if( name == g_cubeOutTag )
898 else if( name == g_cubeInOutTag )
902 else if( name == g_quartInTag )
906 else if( name == g_quartOutTag )
910 else if( name == g_quartInOutTag )
914 else if( name == g_quintInTag )
918 else if( name == g_quintOutTag )
922 else if( name == g_quintInOutTag )
926 else if( name == g_sinInTag )
930 else if( name == g_sinOutTag )
934 else if( name == g_sinInOutTag )
938 else if( name == g_expoInTag )
942 else if( name == g_expoOutTag )
946 else if( name == g_expoInOutTag )
950 else if( name == g_circleInTag )
954 else if( name == g_circleOutTag )
958 else if( name == g_circleInOutTag )
962 else if( name == g_elasticInTag )
966 else if( name == g_elasticOutTag )
970 else if( name == g_elasticInOutTag )
974 else if( name == g_bounceInTag )
978 else if( name == g_bounceOutTag )
982 else if( name == g_bounceInOutTag )
986 else if( name == g_backInTag )
990 else if( name == g_backOutTag )
994 else if( name == g_backInOutTag )
999 std::cerr <<
"GlsAnimation: Unreqcognized interpolator requested: " << name <<
".\n";
1009 template<
class Value>
1010 typename GlsKeyframeInterpolator<Value>::Ptr CreateInterpolator(
const std::string& name,
typename Detail::enable_if<Detail::is_same<Value, glsColor>::value>::type* = 0 )
1026 template<
class Value>
1027 typename GlsKeyframeInterpolator<Value>::Ptr CreateInterpolator(
const std::string& name,
typename Detail::enable_if<Detail::is_same<Value, std::string>::value>::type* = 0 )
1029 if( !name.empty() && name != g_gatedInterpTag )
1031 std::cerr <<
"LoadAnimationScript(): Strings may only use gated interpolation, not " << name <<
".\n";
1044 template<
class Value>
1045 typename GlsKeyframeCurve<Value>::Ptr CreateTweenerCurve(
const Value& begin,
const Value& end,
const GlsAnimation::Key& duration,
const std::string& tweenerName )
1047 DistiAssert( duration >= 0.0 );
1053 typename GlsKeyframeCurve<Value>::Ptr curve(
new GlsKeyframeCurve<Value>( interpolator ) );
1054 curve->AddKeyframe( 0, begin );
1055 curve->AddKeyframe( duration, end );
1076 void SetGlsAnimationParentChildRelationship( DisplayObject* parent, DisplayObject* child );
1083 void DumpResourceNames( DisplayFrame* displayFrame, std::ostream& stream );
virtual Size CountPropertyNames() const =0
Returns number of property names referenced by this animation.
void Reset()
Override from GlsAnimation.
Definition: gls_animation.h:449
static const KeyPair s_nanPair
Default value for remapping constructor parameter.
Definition: gls_animation.h:501
Definition: gls_animation.h:147
Key GetKey() const
Override from GlsAnimation.
Definition: gls_animation.h:344
void Reset()
Override from GlsAnimation.
Definition: gls_animation.h:599
Key GetKeyRange() const
Override from GlsAnimation.
Definition: gls_animation.h:579
Size CountPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.cpp:430
stdortr1::shared_ptr< GlsAnimationCollection > Ptr
Alias for easier reading.
Definition: gls_animation.h:296
std::vector< std::string > GetPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.cpp:395
Create our own version of meta-function which is not available on all our target platfo...
Definition: gls_animation.h:742
GlsKeyframeCurveBase::Key Key
Alias for easier reading.
Definition: gls_animation.h:297
virtual void RetargetPropertyNames(const std::vector< std::string > &propertyNames)
Override from GlsAnimation.
Definition: gls_animation.h:461
void SetKey(const Key &key)
Override from GlsAnimation.
Definition: gls_animation.cpp:639
For easier reading, test whether T is either the same type as U or the same as V. ...
Definition: gls_animation.h:761
bool IsReadyToAnimate() const
Override from GlsAnimation.
Definition: gls_animation.cpp:526
GlsAnimation::Ptr Clone() const
Override from GlsAnimation.
Definition: gls_animation.cpp:743
virtual Key GetKey() const =0
virtual void SetKey(const Key &key)=0
GlsKeyframeCurveBase::Key Key
Alias for easier reading.
Definition: gls_animation.h:61
void Reset()
Override from GlsAnimation.
Definition: gls_animation.cpp:665
GlsAnimationSubsetAdapter(const std::string &name, const GlsAnimation::Ptr &animation, const KeyPair &clampLimits, const KeyPair &newMinMax=s_nanPair)
Definition: gls_animation.h:533
bool SetDisplayFrame(DisplayFrame *displayFrame)
Override from GlsAnimation.
Definition: gls_animation.h:413
bool SetDisplayFrame(DisplayFrame *displayFrame)
Override from GlsAnimation.
Definition: gls_animation.h:543
KeyPair GetMinMaxKeys() const
Override from GlsAnimation.
Definition: gls_animation.h:443
GlsAnimation::Ptr Clone() const
Override from GlsAnimation.
Definition: gls_animation.h:473
Definition: gls_animation.h:497
Definition: gls_keyframe.h:300
stdortr1::shared_ptr< GlsKeyframeAnimation > Ptr
Alias for easier reading.
Definition: gls_animation.h:150
GlsAnimationCollection(const std::string &name, GlsAnimation *animation=0)
Definition: gls_animation.cpp:539
bool IsReadyToAnimate() const
Override from GlsAnimation.
Definition: gls_animation.cpp:621
virtual bool SetDisplayFrame(DisplayFrame *displayFrame)=0
stdortr1::shared_ptr< GlsKeyframeCurve > Ptr
Alias for easier reading.
Definition: gls_keyframe.h:1275
Size GetAnimationCount() const
Gets the number of animations currently in the collection.
Definition: gls_animation.h:356
An abstract base class for all keyframe interpolators.
Definition: gls_keyframe.h:164
KeyPair GetMinMaxKeys() const
Override from GlsAnimation.
Definition: gls_animation.cpp:596
Create our own version of meta-function which is not available on all our target platfo...
Definition: gls_animation.h:731
stdortr1::shared_ptr< GlsAnimation > Ptr
Alias for easier reading.
Definition: gls_animation.h:60
GlsKeyframeCurveBase::Size Size
Alias for easier reading.
Definition: gls_animation.h:63
Key GetKeyRange() const
Override from GlsAnimation.
Definition: gls_animation.h:437
GlsKeyframeAnimation(const std::string &name, const std::string &propertyName, const GlsKeyframeCurve< double > *keyframeCurve)
Definition: gls_animation.cpp:70
Contains a set of animations that are played in parallel with the SetKey() method.
Definition: gls_animation.h:293
bool SetDisplayFrame(DisplayFrame *displayFrame)
Definition: gls_animation.cpp:495
GlsKeyframeCurveBase::KeyPair KeyPair
Alias for easier reading.
Definition: gls_animation.h:298
bool IsReadyToAnimate() const
Override from GlsAnimation.
Definition: gls_animation.h:549
GlsAnimation(const std::string &name)
Constructor - for base classes only.
Definition: gls_animation.h:128
void SetKey(const Key &key)
Override from GlsAnimation.
Definition: gls_animation.h:431
virtual Key GetKeyRange() const =0
std::size_t Size
The size type for sizes and indices.
Definition: gls_keyframe.h:77
virtual KeyPair GetMinMaxKeys() const =0
void RetargetPropertyNames(const std::vector< std::string > &propertyNames)
Override from GlsAnimation.
Definition: gls_animation.cpp:688
Key GetKey() const
Override from GlsAnimation.
Definition: gls_animation.h:425
Key GetKeyRange() const
Override from GlsAnimation.
Definition: gls_animation.cpp:586
GlsAnimationReversalAdapter(const std::string &name, GlsAnimation *animation)
Definition: gls_animation.h:392
Base class for the keyframe curve class template.
Definition: gls_keyframe.h:73
bool SetDisplayFrame(DisplayFrame *displayFrame)
Definition: gls_animation.cpp:606
stdortr1::shared_ptr< GlsKeyframeInterpolator > Ptr
Alias for easier reading.
Definition: gls_keyframe.h:166
GlsAnimation::Ptr Clone() const
Override from GlsAnimation.
Definition: gls_animation.cpp:533
void SetKey(const Key &key)
Override from GlsAnimation.
Definition: gls_animation.cpp:299
DisplayFrame * _displayFrame
The display frame used for retargeting.
Definition: gls_animation.h:133
GlsKeyframeCurveBase::KeyPair KeyPair
Alias for easier reading.
Definition: gls_animation.h:62
virtual bool IsReadyToAnimate() const =0
Returns whether the display frame has been set and all the properties have been found.
Base class for all animations.
Definition: gls_animation.h:57
Key GetKeyRange() const
Override from GlsAnimation.
Definition: gls_animation.cpp:280
virtual std::vector< std::string > GetPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.h:605
void RetargetPropertyNames(const std::vector< std::string > &propertyNames)
Override from GlsAnimation.
Definition: gls_animation.cpp:401
Size CountPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.h:629
Key GetKey() const
Definition: gls_animation.h:556
GlsAnimationReversalAdapter(const std::string &name, const GlsAnimation::Ptr &animation)
Definition: gls_animation.h:404
The GL Studio keyframe animation classes.
KeyPair GetMinMaxKeys() const
Override from GlsAnimation.
Definition: gls_animation.h:586
virtual void RetargetPropertyNames(const std::string &findStr, const std::string &replaceStr)
Override from GlsAnimation.
Definition: gls_animation.h:617
KeyPair GetMinMaxKeys() const
Override from GlsAnimation.
Definition: gls_animation.cpp:287
virtual ~GlsAnimation()
Destructor.
Definition: gls_animation.h:66
Definition: gls_animation.h:385
void Reset()
Override from GlsAnimation.
Definition: gls_animation.cpp:389
Size CountPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.h:479
GlsAnimation::Ptr Clone() const
Override from GlsAnimation.
Definition: gls_animation.h:623
std::pair< Key, Key > KeyPair
Alias for easier reading.
Definition: gls_keyframe.h:78
void SetKey(const Key &key)
Override from GlsAnimation.
Definition: gls_animation.h:562
virtual GlsAnimation::Ptr Clone() const =0
Clones an animation.
void Add(GlsAnimation *animation)
Definition: gls_animation.cpp:563
const std::string & GetName() const
Returns the given name of this animation sequence.
Definition: gls_animation.h:102
Key GetKey() const
Override from GlsAnimation.
Definition: gls_animation.cpp:293
Replacement for std::is_convertible, adapted from Loki 0.1.7.
Definition: gls_animation.h:784
Size CountPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.cpp:731
Definition: gls_animation.cpp:64
virtual void RetargetPropertyNames(const std::string &findStr, const std::string &replaceStr)
Override from GlsAnimation.
Definition: gls_animation.h:467
GlsAnimationSubsetAdapter(const std::string &name, GlsAnimation *animation, const KeyPair &clampLimits, const KeyPair &newMinMax=s_nanPair)
Definition: gls_animation.h:513
virtual void RetargetPropertyNames(const std::vector< std::string > &propertyNames)
Override from GlsAnimation.
Definition: gls_animation.h:611
bool IsReadyToAnimate() const
Override from GlsAnimation.
Definition: gls_animation.h:419
virtual void RetargetPropertyNames(const std::vector< std::string > &propertyNames)=0
double Key
The key type (usually time, but not always)
Definition: gls_keyframe.h:76
virtual std::vector< std::string > GetPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.h:455
virtual std::vector< std::string > GetPropertyNames() const =0
Returns a list of the property name(s) referenced by this animation.
std::vector< std::string > GetPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.cpp:675