GlsAnimation Library  1.0.7
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 <string>
45 #include <vector>
46 
47 #include "gls_keyframe.h"
48 #include "weak_reference.h"
49 
50 namespace disti
51 {
52 // Forward declarations
53 class DisplayFrame;
54 class DistiAttributeBase;
55 
58 {
59 public:
60  typedef stdortr1::shared_ptr<GlsAnimation> Ptr;
64 
66  virtual ~GlsAnimation() {}
67 
74  virtual bool SetDisplayFrame( DisplayFrame* displayFrame ) = 0;
75 
77  virtual bool IsReadyToAnimate() const = 0;
78 
81  virtual Key GetKey() const = 0;
82 
86  virtual void SetKey( const Key& key ) = 0;
87 
90  virtual Key GetKeyRange() const = 0;
91 
94  virtual KeyPair GetMinMaxKeys() const = 0;
95 
99  virtual void Reset() = 0;
100 
102  const std::string& GetName() const { return _name; }
103 
105  virtual GlsAnimation::Ptr Clone() const = 0;
106 
108  virtual std::vector<std::string> GetPropertyNames() const = 0;
109 
114  virtual void RetargetPropertyNames( const std::vector<std::string>& propertyNames ) = 0;
115 
121  virtual void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ) = 0;
122 
124  virtual Size CountPropertyNames() const = 0;
125 
126 protected:
128  GlsAnimation( const std::string& name )
129  : _displayFrame( NULL )
130  , _name( name )
131  {}
133  DisplayFrame* _displayFrame;
134 
135 private:
136  // Member data
137  std::string _name;
138 };
139 
148 {
149 public:
150  typedef stdortr1::shared_ptr<GlsKeyframeAnimation> Ptr;
151 
173  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<double>* keyframeCurve );
174 
176  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<Vector>* keyframeCurve );
177 
179  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<GlsQuaternionD>* keyframeCurve );
180 
182  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<std::string>* keyframeCurve );
183 
185  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<glsColor>* keyframeCurve );
186 
189  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<double>::PtrConst& keyframeCurve );
190 
193  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<Vector>::PtrConst& keyframeCurve );
194 
197  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<GlsQuaternionD>::PtrConst& keyframeCurve );
198 
201  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<std::string>::PtrConst& keyframeCurve );
202 
205  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<glsColor>::PtrConst& keyframeCurve );
206 
209  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<double>::Ptr& keyframeCurve );
210 
213  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<Vector>::Ptr& keyframeCurve );
214 
217  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<GlsQuaternionD>::Ptr& keyframeCurve );
218 
221  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<std::string>::Ptr& keyframeCurve );
222 
225  GlsKeyframeAnimation( const std::string& name, const std::string& propertyName, const GlsKeyframeCurve<glsColor>::Ptr& keyframeCurve );
226 
230  bool SetDisplayFrame( DisplayFrame* displayFrame ); // override
231 
233  bool IsReadyToAnimate() const; // override
234 
236  Key GetKey() const; // override
237 
239  void SetKey( const Key& key ); // override
240 
242  Key GetKeyRange() const; // override
243 
245  KeyPair GetMinMaxKeys() const; // override
246 
248  void Reset(); // override
249 
251  GlsAnimation::Ptr Clone() const; // override
252 
254  std::vector<std::string> GetPropertyNames() const; // override
255 
257  void RetargetPropertyNames( const std::vector<std::string>& propertyNames ); // override
258 
260  void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ); // override
261 
263  Size CountPropertyNames() const; // override
264 
265 private:
266  // Member functions
267  DistiAttributeBase& LookupResourceAttribute( DisplayFrame* displayFrame, const std::string& propertyName );
268  bool HandleSpecialCases( DisplayFrame* displayFrame ); // Returns whether a special case was found
269 
270  // Data members
271  // The owned pointers (could use boost::variant or similar to avoid unused pointers)
277 
278  const GlsKeyframeCurveBase* _baseCurve; // Observer of owned shared_ptr
279  std::string _propertyName;
280  WeakRef<DistiAttributeBase> _attr;
281  WeakRef<DisplayObject> _object; // Observer for fill color which can't be set by the Resources API
282  Key _key;
283  bool _isEmitEvent;
284  std::string _lastEmitted;
285 
286 #if GLS_VERSION_MAJOR == 4 && GLS_VERSION_MINOR < 5
287  bool _isDynamicTranslate;
288 #endif // GLS Version < 4.5
289 };
290 
294 {
295 public:
296  typedef stdortr1::shared_ptr<GlsAnimationCollection> Ptr;
299 
305  explicit GlsAnimationCollection( const std::string& name, GlsAnimation* animation = 0 );
306 
312  explicit GlsAnimationCollection( const std::string& name, const GlsAnimation::Ptr& animation );
313 
320  void Add( GlsAnimation* animation );
321 
327  void Add( const GlsAnimation::Ptr& animation );
328 
330  Key GetKeyRange() const; // override
331 
333  KeyPair GetMinMaxKeys() const; // override
334 
338  bool SetDisplayFrame( DisplayFrame* displayFrame ); // override
339 
341  bool IsReadyToAnimate() const; // override
342 
344  Key GetKey() const { return _key; } // override
345 
347  void SetKey( const Key& key ); // override
348 
350  void Reset(); // override
351 
353  GlsAnimation::Ptr Clone() const; // override
354 
356  Size GetAnimationCount() const { return _animationList.size(); }
357 
359  std::vector<std::string> GetPropertyNames() const; // override
360 
362  void RetargetPropertyNames( const std::vector<std::string>& propertyNames ); // override
363 
365  void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ); // override
366 
368  Size CountPropertyNames() const; // override
369 
370 private:
371  // Types
372  typedef std::vector<GlsAnimation::Ptr> AnimationList;
373  typedef AnimationList::const_iterator AnimationIter;
374 
375  // Member data
376  Key _key;
377  Key _minKey;
378  Key _maxKey;
379  AnimationList _animationList; // Owns the animations in it
380  bool _isStarted;
381 };
382 
386 {
387 public:
392  GlsAnimationReversalAdapter( const std::string& name, GlsAnimation* animation )
393  : GlsAnimation( name )
394  , _animation( animation )
395  {
396  DistiAssert( animation );
397  _minMax = animation->GetMinMaxKeys();
398  }
399 
404  GlsAnimationReversalAdapter( const std::string& name, const GlsAnimation::Ptr& animation )
405  : GlsAnimation( name )
406  , _animation( animation )
407  {
408  DistiAssert( animation );
409  _minMax = animation->GetMinMaxKeys();
410  }
411 
413  bool SetDisplayFrame( DisplayFrame* displayFrame ) // override
414  {
415  return _animation->SetDisplayFrame( displayFrame );
416  }
417 
419  bool IsReadyToAnimate() const // override
420  {
421  return _animation->IsReadyToAnimate();
422  }
423 
425  Key GetKey() const // override
426  {
427  return _minMax.second - _animation->GetKey() + _minMax.first;
428  }
429 
431  void SetKey( const Key& key ) // override
432  {
433  _animation->SetKey( _minMax.second - key + _minMax.first );
434  }
435 
437  Key GetKeyRange() const // override
438  {
439  return _animation->GetKeyRange();
440  }
441 
443  KeyPair GetMinMaxKeys() const // override
444  {
445  return _animation->GetMinMaxKeys();
446  }
447 
449  void Reset() // override
450  {
451  _animation->Reset();
452  }
453 
455  virtual std::vector<std::string> GetPropertyNames() const // override
456  {
457  return _animation->GetPropertyNames();
458  }
459 
461  virtual void RetargetPropertyNames( const std::vector<std::string>& propertyNames ) // override
462  {
463  _animation->RetargetPropertyNames( propertyNames );
464  }
465 
467  virtual void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ) // override
468  {
469  _animation->RetargetPropertyNames( findStr, replaceStr );
470  }
471 
473  GlsAnimation::Ptr Clone() const // override
474  {
475  return GlsAnimation::Ptr( new GlsAnimationReversalAdapter( GetName(), _animation->Clone() ) );
476  }
477 
479  Size CountPropertyNames() const // override
480  {
481  return _animation->CountPropertyNames();
482  }
483 
484 private:
485  GlsAnimation::Ptr _animation;
486  KeyPair _minMax;
487 };
488 
489 typedef GlsAnimationReversalAdapter GlsAnimationReverser;
490 
498 {
499 public:
501  static const KeyPair s_nanPair;
502 
513  GlsAnimationSubsetAdapter( const std::string& name, GlsAnimation* animation, const KeyPair& clampLimits, const KeyPair& newMinMax = s_nanPair )
514  : GlsAnimation( name )
515  , _animation( animation )
516  , _currentKey( Detail::g_nan )
517  {
518  DistiAssert( animation );
519  Init( clampLimits, newMinMax );
520  }
521 
533  GlsAnimationSubsetAdapter( const std::string& name, const GlsAnimation::Ptr& animation, const KeyPair& clampLimits, const KeyPair& newMinMax = s_nanPair )
534  : GlsAnimation( name )
535  , _animation( animation )
536  , _currentKey( Detail::g_nan )
537  {
538  DistiAssert( animation );
539  Init( clampLimits, newMinMax );
540  }
541 
543  bool SetDisplayFrame( DisplayFrame* displayFrame ) // override
544  {
545  return _animation->SetDisplayFrame( displayFrame );
546  }
547 
549  bool IsReadyToAnimate() const // override
550  {
551  return _animation->IsReadyToAnimate();
552  }
553 
556  Key GetKey() const // override
557  {
558  return _currentKey;
559  }
560 
562  void SetKey( const Key& key ) // override
563  {
564  _currentKey = key;
565 
566  // Convert incoming key, which is in the remapped key range, to a percentage
567  // then into contained animation's (clamped) key range
568  Key clampedKey = ( key - _remappedMinMax.first )
569  / ( _remappedMinMax.second - _remappedMinMax.first )
570  * ( _animationMinMax.second - _animationMinMax.first )
571  + _animationMinMax.first;
572 
573  clampedKey = ( std::max )( ( std::min )( clampedKey, _clampLimits.second ), _clampLimits.first ); // Extra parens avoid the NOMINMAX issues on Windows
574 
575  _animation->SetKey( clampedKey );
576  }
577 
579  Key GetKeyRange() const // override
580  {
581  const KeyPair minMaxKeys = GetMinMaxKeys();
582  return minMaxKeys.second - minMaxKeys.first;
583  }
584 
586  KeyPair GetMinMaxKeys() const // override
587  {
588  if( _remappedMinMax == _animationMinMax )
589  {
590  return _clampLimits;
591  }
592  else
593  {
594  return _remappedMinMax;
595  }
596  }
597 
599  void Reset() // override
600  {
601  _animation->Reset();
602  }
603 
605  virtual std::vector<std::string> GetPropertyNames() const // override
606  {
607  return _animation->GetPropertyNames();
608  }
609 
611  virtual void RetargetPropertyNames( const std::vector<std::string>& propertyNames ) // override
612  {
613  _animation->RetargetPropertyNames( propertyNames );
614  }
615 
617  virtual void RetargetPropertyNames( const std::string& findStr, const std::string& replaceStr ) // override
618  {
619  _animation->RetargetPropertyNames( findStr, replaceStr );
620  }
621 
623  GlsAnimation::Ptr Clone() const // override
624  {
625  return GlsAnimation::Ptr( new GlsAnimationSubsetAdapter( GetName(), _animation->Clone(), _clampLimits, _remappedMinMax ) );
626  }
627 
629  Size CountPropertyNames() const // override
630  {
631  return _animation->CountPropertyNames();
632  }
633 
634 private:
635  void Init( const KeyPair& clampLimits, const KeyPair& newMinMax )
636  {
637  const bool isMinMaxNaN = Detail::IsNaN( newMinMax.first ) || Detail::IsNaN( newMinMax.second );
638 
639  // Preconditions of the constructors
640  DistiAssert( clampLimits.first <= clampLimits.second );
641  DistiAssert( newMinMax.first <= newMinMax.second || isMinMaxNaN );
642 
643  // Clamps the given begin and end values within the animation's limits
644  // (Extra parens avoid the NOMINMAX issues on Windows)
645  _animationMinMax = _animation->GetMinMaxKeys();
646  _clampLimits = std::make_pair(
647  ( std::max )( clampLimits.first, _animationMinMax.first ),
648  ( std::min )( clampLimits.second, _animationMinMax.second ) );
649 
650  if( isMinMaxNaN )
651  {
652  _remappedMinMax = _animationMinMax;
653  }
654  else
655  {
656  _remappedMinMax = newMinMax;
657  }
658  }
659 
660  // Data members
661  GlsAnimation::Ptr _animation;
662  KeyPair _animationMinMax;
663  KeyPair _clampLimits;
664  KeyPair _remappedMinMax;
665  Key _currentKey;
666 };
667 
672 GlsAnimation::Ptr LoadAnimationScript( const std::string& filename );
673 
678 GlsAnimation::Ptr LoadAnimationScriptFromString( const std::string& script );
679 
680 #ifdef GLS_ANIMATION_ENABLE_ZIP_LOADING
681 std::vector<GlsAnimation::Ptr> LoadAnimationZip( const std::string& filename );
688 #endif
689 
691 // Names of all the interpolators
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";
725 
727 namespace Detail
728 {
730  template<bool B, class T = void>
731  struct enable_if
732  {};
734  template<class T>
735  struct enable_if<true, T>
736  {
737  typedef T type;
738  };
739 
741  template<typename T, typename U>
742  struct is_same
743  {
744  enum
745  {
746  value = false
747  };
748  };
750  template<typename T>
751  struct is_same<T, T>
752  {
753  enum
754  {
755  value = true
756  };
757  };
758 
760  template<typename T, typename U, typename V>
761  struct is_same2
762  {
763  enum
764  {
766  };
767  };
768 
783  template<class T, class U>
785  {
786  private:
787  typedef char Small;
788  struct Big
789  {
790  char dummy[ 2 ];
791  };
792  static Big Test( ... );
793  static Small Test( U );
794  static T MakeT();
795 
796  public:
797  enum
798  {
799  value = sizeof( Small ) == sizeof( ( Test( MakeT() ) ) )
800  };
801  };
802 
803  template<class T>
804  struct is_convertible<T, T>
805  {
806  enum
807  {
808  value = true
809  };
810  }; //< Replacement for std::is_convertible, adapted from Loki 0.1.7.
811  template<class T>
812  struct is_convertible<void, T>
813  {
814  enum
815  {
816  value = false
817  };
818  }; //< Replacement for std::is_convertible, adapted from Loki 0.1.7.
819  template<class T>
820  struct is_convertible<T, void>
821  {
822  enum
823  {
824  value = false
825  };
826  }; //< Replacement for std::is_convertible, adapted from Loki 0.1.7.
827  template<>
828  struct is_convertible<void, void>
829  {
830  enum
831  {
832  value = true
833  };
834  }; //< Replacement for std::is_convertible, adapted from Loki 0.1.7.
835 
838  template<class Value>
840  {
842  }
843 
846  template<class Value>
847  typename GlsKeyframeInterpolator<Value>::Ptr CreateSlerp( typename enable_if<!is_same2<Value, Vector, GlsQuaternionD>::value>::type* = 0 )
848  {
849  std::cerr << "GlsAnimation: Slerp requested for a type that does not support it.\n";
850  return typename GlsKeyframeInterpolator<Value>::Ptr();
851  }
852 } // namespace Detail
853 
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 )
861 {
862  if( name.empty() )
863  {
864  return typename GlsKeyframeInterpolator<Value>::Ptr( new typename Detail::DefaultInterpolator<Value>::Type() );
865  }
866  else if( name == g_linearInterpTag )
867  {
868  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsLinearInterpolator<Value>() );
869  }
870  else if( name == g_gatedInterpTag )
871  {
872  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsGatedInterpolator<Value>() );
873  }
874  else if( name == g_slerpTag )
875  {
876  return Detail::CreateSlerp<Value>();
877  }
878  else if( name == g_quadInTag )
879  {
880  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuadraticEaseInInterpolator<Value>() );
881  }
882  else if( name == g_quadOutTag )
883  {
884  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuadraticEaseOutInterpolator<Value>() );
885  }
886  else if( name == g_quadInOUtTag )
887  {
888  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuadraticEaseInOutInterpolator<Value>() );
889  }
890  else if( name == g_cubeInTag )
891  {
892  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCubicEaseInInterpolator<Value>() );
893  }
894  else if( name == g_cubeOutTag )
895  {
896  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCubicEaseOutInterpolator<Value>() );
897  }
898  else if( name == g_cubeInOutTag )
899  {
900  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCubicEaseInOutInterpolator<Value>() );
901  }
902  else if( name == g_quartInTag )
903  {
904  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuarticEaseInInterpolator<Value>() );
905  }
906  else if( name == g_quartOutTag )
907  {
908  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuarticEaseOutInterpolator<Value>() );
909  }
910  else if( name == g_quartInOutTag )
911  {
912  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuarticEaseInOutInterpolator<Value>() );
913  }
914  else if( name == g_quintInTag )
915  {
916  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuinticEaseInInterpolator<Value>() );
917  }
918  else if( name == g_quintOutTag )
919  {
920  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuinticEaseOutInterpolator<Value>() );
921  }
922  else if( name == g_quintInOutTag )
923  {
924  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuinticEaseInOutInterpolator<Value>() );
925  }
926  else if( name == g_sinInTag )
927  {
928  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsSinusoidalEaseInInterpolator<Value>() );
929  }
930  else if( name == g_sinOutTag )
931  {
932  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsSinusoidalEaseOutInterpolator<Value>() );
933  }
934  else if( name == g_sinInOutTag )
935  {
936  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsSinusoidalEaseInOutInterpolator<Value>() );
937  }
938  else if( name == g_expoInTag )
939  {
940  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsExponentialEaseInInterpolator<Value>() );
941  }
942  else if( name == g_expoOutTag )
943  {
944  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsExponentialEaseOutInterpolator<Value>() );
945  }
946  else if( name == g_expoInOutTag )
947  {
948  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsExponentialEaseInOutInterpolator<Value>() );
949  }
950  else if( name == g_circleInTag )
951  {
952  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCircularEaseInInterpolator<Value>() );
953  }
954  else if( name == g_circleOutTag )
955  {
956  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCircularEaseOutInterpolator<Value>() );
957  }
958  else if( name == g_circleInOutTag )
959  {
960  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCircularEaseInOutInterpolator<Value>() );
961  }
962  else if( name == g_elasticInTag )
963  {
964  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsElasticEaseInInterpolator<Value>() );
965  }
966  else if( name == g_elasticOutTag )
967  {
968  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsElasticEaseOutInterpolator<Value>() );
969  }
970  else if( name == g_elasticInOutTag )
971  {
972  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsElasticEaseInOutInterpolator<Value>() );
973  }
974  else if( name == g_bounceInTag )
975  {
976  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBounceEaseInInterpolator<Value>() );
977  }
978  else if( name == g_bounceOutTag )
979  {
980  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBounceEaseOutInterpolator<Value>() );
981  }
982  else if( name == g_bounceInOutTag )
983  {
984  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBounceEaseInOutInterpolator<Value>() );
985  }
986  else if( name == g_backInTag )
987  {
988  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBackEaseInInterpolator<Value>() );
989  }
990  else if( name == g_backOutTag )
991  {
992  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBackEaseOutInterpolator<Value>() );
993  }
994  else if( name == g_backInOutTag )
995  {
996  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBackEaseInOutInterpolator<Value>() );
997  }
998 
999  std::cerr << "GlsAnimation: Unreqcognized interpolator requested: " << name << ".\n";
1000  return typename GlsKeyframeInterpolator<Value>::Ptr();
1001 }
1002 
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 )
1011 {
1012  typename GlsKeyframeInterpolator<double>::Ptr interpolator = CreateInterpolator<double>( name );
1013  if( !interpolator )
1014  {
1015  return typename GlsKeyframeInterpolator<Value>::Ptr();
1016  }
1017  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsColorInterpolationAdapter( interpolator ) );
1018 }
1019 
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 )
1028 {
1029  if( !name.empty() && name != g_gatedInterpTag )
1030  {
1031  std::cerr << "LoadAnimationScript(): Strings may only use gated interpolation, not " << name << ".\n";
1032  }
1033  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsGatedInterpolator<Value>() );
1034 }
1035 
1044 template<class Value>
1045 typename GlsKeyframeCurve<Value>::Ptr CreateTweenerCurve( const Value& begin, const Value& end, const GlsAnimation::Key& duration, const std::string& tweenerName )
1046 {
1047  DistiAssert( duration >= 0.0 );
1048  const typename GlsKeyframeInterpolator<Value>::Ptr interpolator = CreateInterpolator<Value>( tweenerName );
1049  if( !interpolator )
1050  {
1051  return typename GlsKeyframeCurve<Value>::Ptr();
1052  }
1053  typename GlsKeyframeCurve<Value>::Ptr curve( new GlsKeyframeCurve<Value>( interpolator ) );
1054  curve->AddKeyframe( 0, begin );
1055  curve->AddKeyframe( duration, end );
1056  return curve;
1057 }
1058 
1076 void SetGlsAnimationParentChildRelationship( DisplayObject* parent, DisplayObject* child );
1077 
1083 void DumpResourceNames( DisplayFrame* displayFrame, std::ostream& stream );
1084 } // namespace disti
1085 
1086 #endif
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
virtual void Reset()=0
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