GlsAnimation Library  1.0.5
Provides classes and functions to support animating GL Studio objects programmatically or with script files
gls_animation.h
Go to the documentation of this file.
1 
41 #ifndef INCLUDED_GLS_ANIMATION_H
42 #define INCLUDED_GLS_ANIMATION_H
43 
44 #include <vector>
45 #include <string>
46 
47 #include "gls_keyframe.h"
48 
49 namespace disti
50 {
51  // Forward declarations
52  class DisplayFrame;
53  class DistiAttributeBase;
54 
57  {
58  public:
59  typedef stdortr1::shared_ptr<GlsAnimation> Ptr;
63 
65  virtual ~GlsAnimation() {}
66 
73  virtual bool SetDisplayFrame( DisplayFrame* displayFrame ) = 0;
74 
76  virtual bool IsReadyToAnimate() const = 0;
77 
80  virtual Key GetKey() const = 0;
81 
85  virtual void SetKey( const Key& key ) = 0;
86 
89  virtual Key GetKeyRange() const = 0;
90 
93  virtual KeyPair GetMinMaxKeys() const = 0;
94 
98  virtual void Reset() = 0;
99 
101  const std::string& GetName() const { return _name; }
102 
104  virtual GlsAnimation::Ptr Clone() const = 0;
105 
107  virtual std::vector<std::string> GetPropertyNames() const = 0;
108 
113  virtual void RetargetPropertyNames( const std::vector<std::string>& propertyNames ) = 0;
114 
120  virtual void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ) = 0;
121 
123  virtual Size CountPropertyNames() const = 0;
124 
125  protected:
126 
128  GlsAnimation( const std::string& name ) : _displayFrame( NULL ), _name( name ) {}
130  DisplayFrame* _displayFrame;
131 
132  private:
133 
134  // Member data
135  std::string _name;
136  };
137 
146  {
147  public:
148  typedef stdortr1::shared_ptr<GlsKeyframeAnimation> Ptr;
149 
171  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<double>* keyframeCurve );
172 
174  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<Vector>* keyframeCurve );
175 
177  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<GlsQuaternionD>* keyframeCurve );
178 
180  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<std::string>* keyframeCurve );
181 
183  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<glsColor>* keyframeCurve );
184 
187  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<double>::PtrConst& keyframeCurve );
188 
191  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<Vector>::PtrConst& keyframeCurve );
192 
195  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<GlsQuaternionD>::PtrConst& keyframeCurve );
196 
199  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<std::string>::PtrConst& keyframeCurve );
200 
203  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<glsColor>::PtrConst& keyframeCurve );
204 
207  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<double>::Ptr& keyframeCurve );
208 
211  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<Vector>::Ptr& keyframeCurve );
212 
215  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<GlsQuaternionD>::Ptr& keyframeCurve );
216 
219  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<std::string>::Ptr& keyframeCurve );
220 
223  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<glsColor>::Ptr& keyframeCurve );
224 
228  bool SetDisplayFrame( DisplayFrame* displayFrame ); // override
229 
231  bool IsReadyToAnimate() const; // override
232 
234  Key GetKey() const; // override
235 
237  void SetKey( const Key& key ); // override
238 
240  Key GetKeyRange() const; // override
241 
243  KeyPair GetMinMaxKeys() const; // override
244 
246  void Reset(); // override
247 
249  GlsAnimation::Ptr Clone() const; // override
250 
252  std::vector<std::string> GetPropertyNames() const; // override
253 
255  void RetargetPropertyNames( const std::vector<std::string>& propertyNames ); // override
256 
258  void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ); // override
259 
261  Size CountPropertyNames() const; // override
262 
263  private:
264  // Member functions
265  DistiAttributeBase& LookupResourceAttribute( DisplayFrame* displayFrame, const std::string& propertyName );
266  bool HandleSpecialCases( DisplayFrame* displayFrame ); // Returns whether a special case was found
267 
268  // Data members
269  // The owned pointers (could use boost::variant or similar to avoid unused pointers)
275 
276  const GlsKeyframeCurveBase* _baseCurve; // Observer of owned shared_ptr
277  std::string _propertyName;
278  DistiAttributeBase* _attr;
279  DisplayObject* _object; // Observer for fill color which can't be set by the Resources API
280  Key _key;
281  bool _isEmitEvent;
282  std::string _lastEmitted;
283 
284  #if GLS_VERSION_MAJOR == 4 && GLS_VERSION_MINOR < 5
285  bool _isDynamicTranslate;
286  #endif // GLS Version < 4.5
287  };
288 
292  {
293  public:
294  typedef stdortr1::shared_ptr<GlsAnimationCollection> Ptr;
297 
303  explicit GlsAnimationCollection( const std::string& name, GlsAnimation* animation = 0 );
304 
310  explicit GlsAnimationCollection( const std::string& name, const GlsAnimation::Ptr& animation );
311 
318  void Add( GlsAnimation* animation );
319 
325  void Add( const GlsAnimation::Ptr& animation );
326 
328  Key GetKeyRange() const; // override
329 
331  KeyPair GetMinMaxKeys() const; // override
332 
336  bool SetDisplayFrame( DisplayFrame* displayFrame ); // override
337 
339  bool IsReadyToAnimate() const; // override
340 
342  Key GetKey() const { return _key; } // override
343 
345  void SetKey( const Key& key ); // override
346 
348  void Reset(); // override
349 
351  GlsAnimation::Ptr Clone() const; // override
352 
354  Size GetAnimationCount() const { return _animationList.size(); }
355 
357  std::vector<std::string> GetPropertyNames() const; // override
358 
360  void RetargetPropertyNames( const std::vector<std::string>& propertyNames ); // override
361 
363  void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ); // override
364 
366  Size CountPropertyNames() const; // override
367 
368  private:
369  // Types
370  typedef std::vector< GlsAnimation::Ptr > AnimationList;
371  typedef AnimationList::const_iterator AnimationIter;
372 
373  // Member data
374  Key _key;
375  Key _minKey;
376  Key _maxKey;
377  AnimationList _animationList; // Owns the animations in it
378  bool _isStarted;
379  };
380 
384  {
385  public:
390  GlsAnimationReversalAdapter( const std::string& name, GlsAnimation* animation )
391  : GlsAnimation( name )
392  , _animation( animation )
393  {
394  DistiAssert( animation );
395  _minMax = animation->GetMinMaxKeys();
396  }
397 
402  GlsAnimationReversalAdapter( const std::string& name, const GlsAnimation::Ptr& animation )
403  : GlsAnimation( name )
404  , _animation( animation )
405  {
406  DistiAssert( animation );
407  _minMax = animation->GetMinMaxKeys();
408  }
409 
411  bool SetDisplayFrame( DisplayFrame* displayFrame ) // override
412  {
413  return _animation->SetDisplayFrame( displayFrame );
414  }
415 
417  bool IsReadyToAnimate() const // override
418  {
419  return _animation->IsReadyToAnimate();
420  }
421 
423  Key GetKey() const // override
424  {
425  return _minMax.second - _animation->GetKey() + _minMax.first;
426  }
427 
429  void SetKey( const Key& key ) // override
430  {
431  _animation->SetKey( _minMax.second - key + _minMax.first );
432  }
433 
435  Key GetKeyRange() const // override
436  {
437  return _animation->GetKeyRange();
438  }
439 
441  KeyPair GetMinMaxKeys() const // override
442  {
443  return _animation->GetMinMaxKeys();
444  }
445 
447  void Reset() // override
448  {
449  _animation->Reset();
450  }
451 
453  virtual std::vector<std::string> GetPropertyNames() const // override
454  {
455  return _animation->GetPropertyNames();
456  }
457 
459  virtual void RetargetPropertyNames( const std::vector<std::string>& propertyNames ) // override
460  {
461  _animation->RetargetPropertyNames(propertyNames);
462  }
463 
465  virtual void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ) // override
466  {
467  _animation->RetargetPropertyNames(findStr, replaceStr);
468  }
469 
471  GlsAnimation::Ptr Clone() const // override
472  {
473  return GlsAnimation::Ptr( new GlsAnimationReversalAdapter( GetName(), _animation->Clone() ) );
474  }
475 
477  Size CountPropertyNames() const // override
478  {
479  return _animation->CountPropertyNames();
480  }
481 
482  private:
483  GlsAnimation::Ptr _animation;
484  KeyPair _minMax;
485  };
486 
487  typedef GlsAnimationReversalAdapter GlsAnimationReverser;
488 
496  {
497  public:
499  static const KeyPair s_nanPair;
500 
511  GlsAnimationSubsetAdapter( const std::string& name, GlsAnimation* animation, const KeyPair& clampLimits, const KeyPair& newMinMax = s_nanPair )
512  : GlsAnimation( name )
513  , _animation( animation )
514  , _currentKey( Detail::g_nan )
515  {
516  DistiAssert( animation );
517  Init( clampLimits, newMinMax );
518  }
519 
531  GlsAnimationSubsetAdapter( const std::string& name, const GlsAnimation::Ptr& animation, const KeyPair& clampLimits, const KeyPair& newMinMax = s_nanPair )
532  : GlsAnimation( name )
533  , _animation( animation )
534  , _currentKey( Detail::g_nan )
535  {
536  DistiAssert( animation );
537  Init( clampLimits, newMinMax );
538  }
539 
541  bool SetDisplayFrame( DisplayFrame* displayFrame ) // override
542  {
543  return _animation->SetDisplayFrame( displayFrame );
544  }
545 
547  bool IsReadyToAnimate() const // override
548  {
549  return _animation->IsReadyToAnimate();
550  }
551 
554  Key GetKey() const // override
555  {
556  return _currentKey;
557  }
558 
560  void SetKey( const Key& key ) // override
561  {
562  _currentKey = key;
563 
564  // Convert incoming key, which is in the remapped key range, to a percentage
565  // then into contained animation's (clamped) key range
566  Key clampedKey = ( key - _remappedMinMax.first )
567  / ( _remappedMinMax.second - _remappedMinMax.first )
568  * ( _animationMinMax.second - _animationMinMax.first )
569  + _animationMinMax.first;
570 
571  clampedKey = (std::max)( (std::min)( clampedKey, _clampLimits.second ), _clampLimits.first ); // Extra parens avoid the NOMINMAX issues on Windows
572 
573  _animation->SetKey( clampedKey );
574  }
575 
577  Key GetKeyRange() const // override
578  {
579  const KeyPair minMaxKeys = GetMinMaxKeys();
580  return minMaxKeys.second - minMaxKeys.first;
581  }
582 
584  KeyPair GetMinMaxKeys() const // override
585  {
586  if( _remappedMinMax == _animationMinMax )
587  {
588  return _clampLimits;
589  }
590  else
591  {
592  return _remappedMinMax;
593  }
594  }
595 
597  void Reset() // override
598  {
599  _animation->Reset();
600  }
601 
603  virtual std::vector<std::string> GetPropertyNames() const // override
604  {
605  return _animation->GetPropertyNames();
606  }
607 
609  virtual void RetargetPropertyNames( const std::vector<std::string>& propertyNames ) // override
610  {
611  _animation->RetargetPropertyNames(propertyNames);
612  }
613 
615  virtual void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ) // override
616  {
617  _animation->RetargetPropertyNames(findStr, replaceStr);
618  }
619 
621  GlsAnimation::Ptr Clone() const // override
622  {
623  return GlsAnimation::Ptr( new GlsAnimationSubsetAdapter( GetName(), _animation->Clone(), _clampLimits, _remappedMinMax ) );
624  }
625 
627  Size CountPropertyNames() const // override
628  {
629  return _animation->CountPropertyNames();
630  }
631 
632  private:
633  void Init( const KeyPair& clampLimits, const KeyPair& newMinMax )
634  {
635  const bool isMinMaxNaN = Detail::IsNaN( newMinMax.first ) || Detail::IsNaN( newMinMax.second );
636 
637  // Preconditions of the constructors
638  DistiAssert( clampLimits.first <= clampLimits.second );
639  DistiAssert( newMinMax.first <= newMinMax.second || isMinMaxNaN );
640 
641  // Clamps the given begin and end values within the animation's limits
642  // (Extra parens avoid the NOMINMAX issues on Windows)
643  _animationMinMax = _animation->GetMinMaxKeys();
644  _clampLimits = std::make_pair(
645  (std::max)( clampLimits.first, _animationMinMax.first ),
646  (std::min)( clampLimits.second, _animationMinMax.second ) );
647 
648  if( isMinMaxNaN )
649  {
650  _remappedMinMax = _animationMinMax;
651  }
652  else
653  {
654  _remappedMinMax = newMinMax;
655  }
656  }
657 
658  // Data members
659  GlsAnimation::Ptr _animation;
660  KeyPair _animationMinMax;
661  KeyPair _clampLimits;
662  KeyPair _remappedMinMax;
663  Key _currentKey;
664  };
665 
670  GlsAnimation::Ptr LoadAnimationScript( const std::string& filename );
671 
676  GlsAnimation::Ptr LoadAnimationScriptFromString(const std::string& script);
677 
678 #ifdef GLS_ANIMATION_ENABLE_ZIP_LOADING
679  std::vector< GlsAnimation::Ptr > LoadAnimationZip( const std::string& filename );
686 #endif
687 
689  // Names of all the interpolators
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";
723 
725  namespace Detail
726  {
728  template<bool B, class T = void> struct enable_if {};
730  template<class T> struct enable_if<true, T> { typedef T type; };
731 
733  template <typename T, typename U> struct is_same { enum { value = false }; };
735  template <typename T> struct is_same<T,T> { enum { value = true }; };
736 
738  template <typename T, typename U, typename V> struct is_same2 { enum { value = is_same<T,U>::value || is_same<T,V>::value }; };
739 
754  template <class T, class U>
756  {
757  private:
758  typedef char Small;
759  struct Big { char dummy[2]; };
760  static Big Test(...);
761  static Small Test(U);
762  static T MakeT();
763  public:
764  enum { value = sizeof(Small) == sizeof((Test(MakeT()))) };
765  };
766 
767  template <class T> struct is_convertible<T, T > { enum { value = true }; }; //< Replacement for std::is_convertible, adapted from Loki 0.1.7.
768  template <class T> struct is_convertible<void, T > { enum { value = false }; }; //< Replacement for std::is_convertible, adapted from Loki 0.1.7.
769  template <class T> struct is_convertible<T, void> { enum { value = false }; }; //< Replacement for std::is_convertible, adapted from Loki 0.1.7.
770  template<> struct is_convertible<void, void> { enum { value = true }; }; //< Replacement for std::is_convertible, adapted from Loki 0.1.7.
771 
774  template<class Value>
776  {
778  }
779 
782  template<class Value>
783  typename GlsKeyframeInterpolator<Value>::Ptr CreateSlerp( typename enable_if< !is_same2< Value, Vector, GlsQuaternionD >::value >::type* = 0 )
784  {
785  std::cerr << "GlsAnimation: Slerp requested for a type that does not support it.\n";
786  return typename GlsKeyframeInterpolator<Value>::Ptr();
787  }
788  }
789 
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 )
797  {
798  if( name.empty() )
799  {
800  return typename GlsKeyframeInterpolator<Value>::Ptr( new typename Detail::DefaultInterpolator<Value>::Type() );
801  }
802  else if( name == g_linearInterpTag )
803  {
804  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsLinearInterpolator<Value>() );
805  }
806  else if( name == g_gatedInterpTag )
807  {
808  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsGatedInterpolator<Value>() );
809  }
810  else if( name == g_slerpTag )
811  {
812  return Detail::CreateSlerp<Value>();
813  }
814  else if( name == g_quadInTag )
815  {
816  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuadraticEaseInInterpolator<Value>() );
817  }
818  else if( name == g_quadOutTag )
819  {
820  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuadraticEaseOutInterpolator<Value>() );
821  }
822  else if( name == g_quadInOUtTag )
823  {
824  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuadraticEaseInOutInterpolator<Value>() );
825  }
826  else if( name == g_cubeInTag )
827  {
828  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCubicEaseInInterpolator<Value>() );
829  }
830  else if( name == g_cubeOutTag )
831  {
832  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCubicEaseOutInterpolator<Value>() );
833  }
834  else if( name == g_cubeInOutTag )
835  {
836  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCubicEaseInOutInterpolator<Value>() );
837  }
838  else if( name == g_quartInTag )
839  {
840  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuarticEaseInInterpolator<Value>() );
841  }
842  else if( name == g_quartOutTag )
843  {
844  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuarticEaseOutInterpolator<Value>() );
845  }
846  else if( name == g_quartInOutTag )
847  {
848  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuarticEaseInOutInterpolator<Value>() );
849  }
850  else if( name == g_quintInTag )
851  {
852  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuinticEaseInInterpolator<Value>() );
853  }
854  else if( name == g_quintOutTag )
855  {
856  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuinticEaseOutInterpolator<Value>() );
857  }
858  else if( name == g_quintInOutTag )
859  {
860  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuinticEaseInOutInterpolator<Value>() );
861  }
862  else if( name == g_sinInTag )
863  {
864  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsSinusoidalEaseInInterpolator<Value>() );
865  }
866  else if( name == g_sinOutTag )
867  {
868  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsSinusoidalEaseOutInterpolator<Value>() );
869  }
870  else if( name == g_sinInOutTag )
871  {
872  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsSinusoidalEaseInOutInterpolator<Value>() );
873  }
874  else if( name == g_expoInTag )
875  {
876  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsExponentialEaseInInterpolator<Value>() );
877  }
878  else if( name == g_expoOutTag )
879  {
880  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsExponentialEaseOutInterpolator<Value>() );
881  }
882  else if( name == g_expoInOutTag )
883  {
884  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsExponentialEaseInOutInterpolator<Value>() );
885  }
886  else if( name == g_circleInTag )
887  {
888  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCircularEaseInInterpolator<Value>() );
889  }
890  else if( name == g_circleOutTag )
891  {
892  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCircularEaseOutInterpolator<Value>() );
893  }
894  else if( name == g_circleInOutTag )
895  {
896  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCircularEaseInOutInterpolator<Value>() );
897  }
898  else if( name == g_elasticInTag )
899  {
900  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsElasticEaseInInterpolator<Value>() );
901  }
902  else if( name == g_elasticOutTag )
903  {
904  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsElasticEaseOutInterpolator<Value>() );
905  }
906  else if( name == g_elasticInOutTag )
907  {
908  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsElasticEaseInOutInterpolator<Value>() );
909  }
910  else if( name == g_bounceInTag )
911  {
912  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBounceEaseInInterpolator<Value>() );
913  }
914  else if( name == g_bounceOutTag )
915  {
916  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBounceEaseOutInterpolator<Value>() );
917  }
918  else if( name == g_bounceInOutTag )
919  {
920  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBounceEaseInOutInterpolator<Value>() );
921  }
922  else if( name == g_backInTag )
923  {
924  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBackEaseInInterpolator<Value>() );
925  }
926  else if( name == g_backOutTag )
927  {
928  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBackEaseOutInterpolator<Value>() );
929  }
930  else if( name == g_backInOutTag )
931  {
932  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBackEaseInOutInterpolator<Value>() );
933  }
934 
935  std::cerr << "GlsAnimation: Unreqcognized interpolator requested: " << name << ".\n";
936  return typename GlsKeyframeInterpolator<Value>::Ptr();
937  }
938 
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 )
947  {
948  typename GlsKeyframeInterpolator<double>::Ptr interpolator = CreateInterpolator<double>( name );
949  if( !interpolator )
950  {
951  return typename GlsKeyframeInterpolator<Value>::Ptr();
952  }
953  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsColorInterpolationAdapter( interpolator ) );
954  }
955 
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 )
964  {
965  if( !name.empty() && name != g_gatedInterpTag )
966  {
967  std::cerr << "LoadAnimationScript(): Strings may only use gated interpolation, not " << name << ".\n";
968  }
969  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsGatedInterpolator<Value>() );
970  }
971 
980  template<class Value>
981  typename GlsKeyframeCurve<Value>::Ptr CreateTweenerCurve( const Value& begin, const Value& end, const GlsAnimation::Key& duration, const std::string& tweenerName )
982  {
983  DistiAssert( duration >= 0.0 );
984  const typename GlsKeyframeInterpolator<Value>::Ptr interpolator = CreateInterpolator<Value>( tweenerName );
985  if( !interpolator )
986  {
987  return typename GlsKeyframeCurve<Value>::Ptr();
988  }
989  typename GlsKeyframeCurve<Value>::Ptr curve( new GlsKeyframeCurve<Value>( interpolator ) );
990  curve->AddKeyframe( 0, begin );
991  curve->AddKeyframe( duration, end );
992  return curve;
993  }
994 
1012  void SetGlsAnimationParentChildRelationship( DisplayObject* parent, DisplayObject* child );
1013 
1019  void DumpResourceNames( DisplayFrame* displayFrame, std::ostream& stream );
1020 }
1021 
1022 #endif
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
virtual void Reset()=0
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