41 #ifndef INCLUDED_GLS_ANIMATION_H
42 #define INCLUDED_GLS_ANIMATION_H
53 class DistiAttributeBase;
59 typedef stdortr1::shared_ptr<GlsAnimation>
Ptr;
80 virtual Key
GetKey()
const = 0;
85 virtual void SetKey(
const Key& key ) = 0;
98 virtual void Reset() = 0;
101 const std::string&
GetName()
const {
return _name; }
148 typedef stdortr1::shared_ptr<GlsKeyframeAnimation>
Ptr;
265 DistiAttributeBase& LookupResourceAttribute( DisplayFrame* displayFrame,
const std::string& propertyName );
266 bool HandleSpecialCases( DisplayFrame* displayFrame );
277 std::string _propertyName;
278 DistiAttributeBase* _attr;
279 DisplayObject* _object;
282 std::string _lastEmitted;
284 #if GLS_VERSION_MAJOR == 4 && GLS_VERSION_MINOR < 5
285 bool _isDynamicTranslate;
286 #endif // GLS Version < 4.5
294 typedef stdortr1::shared_ptr<GlsAnimationCollection>
Ptr;
345 void SetKey(
const Key& key );
370 typedef std::vector< GlsAnimation::Ptr > AnimationList;
371 typedef AnimationList::const_iterator AnimationIter;
377 AnimationList _animationList;
392 , _animation( animation )
394 DistiAssert( animation );
404 , _animation( animation )
406 DistiAssert( animation );
407 _minMax = animation->GetMinMaxKeys();
413 return _animation->SetDisplayFrame( displayFrame );
419 return _animation->IsReadyToAnimate();
425 return _minMax.second - _animation->GetKey() + _minMax.first;
431 _animation->SetKey( _minMax.second - key + _minMax.first );
437 return _animation->GetKeyRange();
443 return _animation->GetMinMaxKeys();
455 return _animation->GetPropertyNames();
461 _animation->RetargetPropertyNames(propertyNames);
467 _animation->RetargetPropertyNames(findStr, replaceStr);
479 return _animation->CountPropertyNames();
487 typedef GlsAnimationReversalAdapter GlsAnimationReverser;
513 , _animation( animation )
514 , _currentKey( Detail::g_nan )
516 DistiAssert( animation );
517 Init( clampLimits, newMinMax );
533 , _animation( animation )
534 , _currentKey( Detail::g_nan )
536 DistiAssert( animation );
537 Init( clampLimits, newMinMax );
543 return _animation->SetDisplayFrame( displayFrame );
549 return _animation->IsReadyToAnimate();
566 Key clampedKey = ( key - _remappedMinMax.first )
567 / ( _remappedMinMax.second - _remappedMinMax.first )
568 * ( _animationMinMax.second - _animationMinMax.first )
569 + _animationMinMax.first;
571 clampedKey = (std::max)( (std::min)( clampedKey, _clampLimits.second ), _clampLimits.first );
573 _animation->SetKey( clampedKey );
580 return minMaxKeys.second - minMaxKeys.first;
586 if( _remappedMinMax == _animationMinMax )
592 return _remappedMinMax;
605 return _animation->GetPropertyNames();
611 _animation->RetargetPropertyNames(propertyNames);
617 _animation->RetargetPropertyNames(findStr, replaceStr);
629 return _animation->CountPropertyNames();
635 const bool isMinMaxNaN = Detail::IsNaN( newMinMax.first ) || Detail::IsNaN( newMinMax.second );
638 DistiAssert( clampLimits.first <= clampLimits.second );
639 DistiAssert( newMinMax.first <= newMinMax.second || isMinMaxNaN );
643 _animationMinMax = _animation->GetMinMaxKeys();
644 _clampLimits = std::make_pair(
645 (std::max)( clampLimits.first, _animationMinMax.first ),
646 (std::min)( clampLimits.second, _animationMinMax.second ) );
650 _remappedMinMax = _animationMinMax;
654 _remappedMinMax = newMinMax;
678 #ifdef GLS_ANIMATION_ENABLE_ZIP_LOADING
679 std::vector< GlsAnimation::Ptr > LoadAnimationZip(
const std::string& filename );
690 const std::string g_linearInterpTag =
"linear";
691 const std::string g_gatedInterpTag =
"gated";
692 const std::string g_slerpTag =
"slerp";
693 const std::string g_quadInTag =
"quadraticIn";
694 const std::string g_quadOutTag =
"quadraticOut";
695 const std::string g_quadInOUtTag =
"quadraticInAndOut";
696 const std::string g_cubeInTag =
"cubicIn";
697 const std::string g_cubeOutTag =
"cubicOut";
698 const std::string g_cubeInOutTag =
"cubicInAndOut";
699 const std::string g_quartInTag =
"quarticIn";
700 const std::string g_quartOutTag =
"quarticOut";
701 const std::string g_quartInOutTag =
"quarticInAndOut";
702 const std::string g_quintInTag =
"quinticIn";
703 const std::string g_quintOutTag =
"quinticOut";
704 const std::string g_quintInOutTag =
"quinticInAndOut";
705 const std::string g_sinInTag =
"sinusoidalIn";
706 const std::string g_sinOutTag =
"sinusoidalOut";
707 const std::string g_sinInOutTag =
"sinusoidalInAndOut";
708 const std::string g_expoInTag =
"exponentIn";
709 const std::string g_expoOutTag =
"exponentOut";
710 const std::string g_expoInOutTag =
"exponentInAndOut";
711 const std::string g_circleInTag =
"circularIn";
712 const std::string g_circleOutTag =
"circularOut";
713 const std::string g_circleInOutTag =
"circularInAndOut";
714 const std::string g_elasticInTag =
"elasticIn";
715 const std::string g_elasticOutTag =
"elasticOut";
716 const std::string g_elasticInOutTag =
"elasticInAndOut";
717 const std::string g_bounceInTag =
"bounceIn";
718 const std::string g_bounceOutTag =
"bounceOut";
719 const std::string g_bounceInOutTag =
"bounceInAndOut";
720 const std::string g_backInTag =
"backIn";
721 const std::string g_backOutTag =
"backOut";
722 const std::string g_backInOutTag =
"backInAndOut";
730 template<
class T>
struct enable_if<true, T> {
typedef T type; };
733 template <
typename T,
typename U>
struct is_same {
enum { value =
false }; };
735 template <
typename T>
struct is_same<T,T> {
enum { value =
true }; };
754 template <
class T,
class U>
759 struct Big {
char dummy[2]; };
760 static Big Test(...);
761 static Small Test(U);
764 enum { value =
sizeof(Small) ==
sizeof((Test(MakeT()))) };
774 template<
class Value>
782 template<
class Value>
785 std::cerr <<
"GlsAnimation: Slerp requested for a type that does not support it.\n";
795 template<
class Value>
796 typename GlsKeyframeInterpolator<Value>::Ptr CreateInterpolator(
const std::string& name,
typename Detail::enable_if< !Detail::is_same2< Value, glsColor, std::string >::value >::type* = 0 )
802 else if( name == g_linearInterpTag )
806 else if( name == g_gatedInterpTag )
810 else if( name == g_slerpTag )
812 return Detail::CreateSlerp<Value>();
814 else if( name == g_quadInTag )
818 else if( name == g_quadOutTag )
822 else if( name == g_quadInOUtTag )
826 else if( name == g_cubeInTag )
830 else if( name == g_cubeOutTag )
834 else if( name == g_cubeInOutTag )
838 else if( name == g_quartInTag )
842 else if( name == g_quartOutTag )
846 else if( name == g_quartInOutTag )
850 else if( name == g_quintInTag )
854 else if( name == g_quintOutTag )
858 else if( name == g_quintInOutTag )
862 else if( name == g_sinInTag )
866 else if( name == g_sinOutTag )
870 else if( name == g_sinInOutTag )
874 else if( name == g_expoInTag )
878 else if( name == g_expoOutTag )
882 else if( name == g_expoInOutTag )
886 else if( name == g_circleInTag )
890 else if( name == g_circleOutTag )
894 else if( name == g_circleInOutTag )
898 else if( name == g_elasticInTag )
902 else if( name == g_elasticOutTag )
906 else if( name == g_elasticInOutTag )
910 else if( name == g_bounceInTag )
914 else if( name == g_bounceOutTag )
918 else if( name == g_bounceInOutTag )
922 else if( name == g_backInTag )
926 else if( name == g_backOutTag )
930 else if( name == g_backInOutTag )
935 std::cerr <<
"GlsAnimation: Unreqcognized interpolator requested: " << name <<
".\n";
945 template<
class Value>
946 typename GlsKeyframeInterpolator<Value>::Ptr CreateInterpolator(
const std::string& name,
typename Detail::enable_if< Detail::is_same< Value, glsColor >::value >::type* = 0 )
962 template<
class Value>
963 typename GlsKeyframeInterpolator<Value>::Ptr CreateInterpolator(
const std::string& name,
typename Detail::enable_if< Detail::is_same< Value, std::string >::value >::type* = 0 )
965 if( !name.empty() && name != g_gatedInterpTag )
967 std::cerr <<
"LoadAnimationScript(): Strings may only use gated interpolation, not " << name <<
".\n";
980 template<
class Value>
981 typename GlsKeyframeCurve<Value>::Ptr CreateTweenerCurve(
const Value& begin,
const Value& end,
const GlsAnimation::Key& duration,
const std::string& tweenerName )
983 DistiAssert( duration >= 0.0 );
989 typename GlsKeyframeCurve<Value>::Ptr curve(
new GlsKeyframeCurve<Value>( interpolator ) );
990 curve->AddKeyframe( 0, begin );
991 curve->AddKeyframe( duration, end );
1012 void SetGlsAnimationParentChildRelationship( DisplayObject* parent, DisplayObject* child );
1019 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:447
static const KeyPair s_nanPair
Default value for remapping constructor parameter.
Definition: gls_animation.h:499
Definition: gls_animation.h:145
Key GetKey() const
Override from GlsAnimation.
Definition: gls_animation.h:342
void Reset()
Override from GlsAnimation.
Definition: gls_animation.h:597
Key GetKeyRange() const
Override from GlsAnimation.
Definition: gls_animation.h:577
stdortr1::shared_ptr< const GlsKeyframeCurve > PtrConst
Alias for easier reading.
Definition: gls_keyframe.h:1276
Size CountPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.cpp:415
stdortr1::shared_ptr< GlsAnimationCollection > Ptr
Alias for easier reading.
Definition: gls_animation.h:294
std::vector< std::string > GetPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.cpp:380
Create our own version of meta-function which is not available on all our target platfo...
Definition: gls_animation.h:733
GlsKeyframeCurveBase::Key Key
Alias for easier reading.
Definition: gls_animation.h:295
virtual void RetargetPropertyNames(const std::vector< std::string > &propertyNames)
Override from GlsAnimation.
Definition: gls_animation.h:459
void SetKey(const Key &key)
Override from GlsAnimation.
Definition: gls_animation.cpp:624
For easier reading, test whether T is either the same type as U or the same as V. ...
Definition: gls_animation.h:738
bool IsReadyToAnimate() const
Override from GlsAnimation.
Definition: gls_animation.cpp:511
GlsAnimation::Ptr Clone() const
Override from GlsAnimation.
Definition: gls_animation.cpp:728
virtual Key GetKey() const =0
virtual void SetKey(const Key &key)=0
GlsKeyframeCurveBase::Key Key
Alias for easier reading.
Definition: gls_animation.h:60
void Reset()
Override from GlsAnimation.
Definition: gls_animation.cpp:650
GlsAnimationSubsetAdapter(const std::string &name, const GlsAnimation::Ptr &animation, const KeyPair &clampLimits, const KeyPair &newMinMax=s_nanPair)
Definition: gls_animation.h:531
bool SetDisplayFrame(DisplayFrame *displayFrame)
Override from GlsAnimation.
Definition: gls_animation.h:411
bool SetDisplayFrame(DisplayFrame *displayFrame)
Override from GlsAnimation.
Definition: gls_animation.h:541
KeyPair GetMinMaxKeys() const
Override from GlsAnimation.
Definition: gls_animation.h:441
GlsAnimation::Ptr Clone() const
Override from GlsAnimation.
Definition: gls_animation.h:471
Definition: gls_animation.h:495
Definition: gls_keyframe.h:300
stdortr1::shared_ptr< GlsKeyframeAnimation > Ptr
Alias for easier reading.
Definition: gls_animation.h:148
GlsAnimationCollection(const std::string &name, GlsAnimation *animation=0)
Definition: gls_animation.cpp:524
bool IsReadyToAnimate() const
Override from GlsAnimation.
Definition: gls_animation.cpp:606
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:354
An abstract base class for all keyframe interpolators.
Definition: gls_keyframe.h:164
KeyPair GetMinMaxKeys() const
Override from GlsAnimation.
Definition: gls_animation.cpp:581
Create our own version of meta-function which is not available on all our target platfo...
Definition: gls_animation.h:728
stdortr1::shared_ptr< GlsAnimation > Ptr
Alias for easier reading.
Definition: gls_animation.h:59
GlsKeyframeCurveBase::Size Size
Alias for easier reading.
Definition: gls_animation.h:62
Key GetKeyRange() const
Override from GlsAnimation.
Definition: gls_animation.h:435
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:291
bool SetDisplayFrame(DisplayFrame *displayFrame)
Definition: gls_animation.cpp:480
GlsKeyframeCurveBase::KeyPair KeyPair
Alias for easier reading.
Definition: gls_animation.h:296
bool IsReadyToAnimate() const
Override from GlsAnimation.
Definition: gls_animation.h:547
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:429
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:673
Key GetKey() const
Override from GlsAnimation.
Definition: gls_animation.h:423
Key GetKeyRange() const
Override from GlsAnimation.
Definition: gls_animation.cpp:571
GlsAnimationReversalAdapter(const std::string &name, GlsAnimation *animation)
Definition: gls_animation.h:390
Base class for the keyframe curve class template.
Definition: gls_keyframe.h:73
bool SetDisplayFrame(DisplayFrame *displayFrame)
Definition: gls_animation.cpp:591
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:518
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:130
GlsKeyframeCurveBase::KeyPair KeyPair
Alias for easier reading.
Definition: gls_animation.h:61
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:56
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:603
void RetargetPropertyNames(const std::vector< std::string > &propertyNames)
Override from GlsAnimation.
Definition: gls_animation.cpp:386
Size CountPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.h:627
Key GetKey() const
Definition: gls_animation.h:554
GlsAnimationReversalAdapter(const std::string &name, const GlsAnimation::Ptr &animation)
Definition: gls_animation.h:402
The GL Studio keyframe animation classes.
KeyPair GetMinMaxKeys() const
Override from GlsAnimation.
Definition: gls_animation.h:584
virtual void RetargetPropertyNames(const std::string &findStr, const std::string &replaceStr)
Override from GlsAnimation.
Definition: gls_animation.h:615
KeyPair GetMinMaxKeys() const
Override from GlsAnimation.
Definition: gls_animation.cpp:287
virtual ~GlsAnimation()
Destructor.
Definition: gls_animation.h:65
Definition: gls_animation.h:383
void Reset()
Override from GlsAnimation.
Definition: gls_animation.cpp:374
Size CountPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.h:477
GlsAnimation::Ptr Clone() const
Override from GlsAnimation.
Definition: gls_animation.h:621
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:560
virtual GlsAnimation::Ptr Clone() const =0
Clones an animation.
void Add(GlsAnimation *animation)
Definition: gls_animation.cpp:548
const std::string & GetName() const
Returns the given name of this animation sequence.
Definition: gls_animation.h:101
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:755
Size CountPropertyNames() const
Override from GlsAnimation.
Definition: gls_animation.cpp:716
Definition: gls_animation.cpp:64
virtual void RetargetPropertyNames(const std::string &findStr, const std::string &replaceStr)
Override from GlsAnimation.
Definition: gls_animation.h:465
GlsAnimationSubsetAdapter(const std::string &name, GlsAnimation *animation, const KeyPair &clampLimits, const KeyPair &newMinMax=s_nanPair)
Definition: gls_animation.h:511
virtual void RetargetPropertyNames(const std::vector< std::string > &propertyNames)
Override from GlsAnimation.
Definition: gls_animation.h:609
bool IsReadyToAnimate() const
Override from GlsAnimation.
Definition: gls_animation.h:417
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:453
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:660