GlsAnimation Library  1.0.6
Provides classes and functions to support animating GL Studio objects programmatically or with script files
gls_keyframe.h
Go to the documentation of this file.
1 
41 #ifndef INCLUDED_GLS_KEYFRAME_H
42 #define INCLUDED_GLS_KEYFRAME_H
43 
44 #include <algorithm>
45 #include <cfloat>
46 #include <cmath>
47 #include <cstring> // for memcmp()
48 #include <limits>
49 #include <memory>
50 #include <string>
51 #include <utility>
52 #include <vector>
53 #if defined(LINUX) && (__GNUC__ >= 4) && !defined(QNX)
54 # include <tr1/memory>
55 #endif
56 
57 #include "disti_assert.h"
58 #include "gls_color.h"
59 #include "util.h"
60 #include "vertex.h"
61 #include "gls_quaternion.h" // Must follow "vertex.h" because of include problems
62 
63 namespace disti
64 {
65  #ifdef GLS_ANIMATION_USE_STD_SHARED_PTR
66  namespace stdortr1 = std; //< Alias for cross-platform portability
67  #else
68  namespace stdortr1 = std::tr1; //< Alias for cross-platform portability
69  #endif
70 
74  {
75  public:
76  typedef double Key;
77  typedef std::size_t Size;
78  typedef std::pair<Key,Key> KeyPair;
79 
81  virtual ~GlsKeyframeCurveBase() {}
82 
84  virtual Size GetKeyframeCount() const = 0;
85 
90  virtual KeyPair GetMinMaxKeys() const = 0;
91 
92  protected:
94  };
95 
97  namespace Detail
98  {
100  typedef unsigned int ID;
101 
103  const float g_glsAnimationFloatTolerance = 1e-5f;
104 
106  const double g_pi = 3.14159265358979323846;
107 
109  template<class T> struct FloatSelector { typedef GlsKeyframeCurveBase::Key Type; };
110  template<> struct FloatSelector<Vector> { typedef float Type; };
111 
116  inline unsigned char ToColorElement( const double d )
117  {
118  const unsigned int trunc = static_cast<unsigned int>( d + 0.5 );
119  // Extra parens avoid the NOMINMAX problems on Windows
120  return static_cast<unsigned char>( (std::min)( (std::max)( trunc, 0u ), 255u ) );
121  }
122 
128  inline bool FloatGreaterThan( const double lhs, const double rhs, const float tolerance = g_glsAnimationFloatTolerance )
129  {
130  return lhs > rhs && !Equal( lhs, rhs, tolerance );
131  }
132 
137  inline bool FloatLessThan( const double lhs, const double rhs, const float tolerance = g_glsAnimationFloatTolerance )
138  {
139  return lhs < rhs && !Equal( lhs, rhs, tolerance );
140  }
141 
146  inline bool FloatGreaterThanOrEqualTo( const double lhs, const double rhs, const float tolerance = g_glsAnimationFloatTolerance )
147  {
148  return lhs > rhs || Equal( lhs, rhs, tolerance );
149  }
150 
155  inline bool FloatLessThanOrEqualTo( const double lhs, const double rhs, const float tolerance = g_glsAnimationFloatTolerance )
156  {
157  return lhs < rhs || Equal( lhs, rhs, tolerance );
158  }
159  } // namespace Detail
160 
163  template<class T>
165  {
166  typedef stdortr1::shared_ptr< GlsKeyframeInterpolator> Ptr;
167  typedef stdortr1::shared_ptr<const GlsKeyframeInterpolator> PtrConst;
169  typedef T Value;
171 
174 
182  virtual Value operator()(
183  const Key& key,
184  const Key& lowerKey, const Key& upperKey,
185  const Value& lowerValue, const Value& upperValue ) const = 0;
186  };
187 
191  template<class Value>
193  {
194  // Define dependent names for GCC's two-phase lookup
197 
200  const Key& key,
201  const Key& lowerKey, const Key& upperKey,
202  const Value& lowerValue, const Value& upperValue ) const // override
203  {
204  const Float percent = static_cast<Float>( (key - lowerKey) / (upperKey - lowerKey) );
205  const Value interpVal = (upperValue - lowerValue) * percent + lowerValue;
206  return interpVal;
207  }
208  };
209 
214  {
217  : _interpolator( CreateDefaultInterpolator() )
218  {}
219 
223  : _interpolator( interpolator ? interpolator : CreateDefaultInterpolator() )
224  {}
225 
230  : _interpolator( interpolator ? interpolator : GlsKeyframeInterpolator<double>::PtrConst( CreateDefaultInterpolator() ) )
231  {}
232 
234  glsColor operator()(
235  const Key& key,
236  const Key& lowerKey, const Key& upperKey,
237  const glsColor& lowerValue, const glsColor& upperValue ) const // override
238  {
239  // Convert to doubles
240  struct { double r, g, b, a; } lower, upper, interpVal;
241  lowerValue.GetRGBA4d( lower.r, lower.g, lower.b, lower.a );
242  upperValue.GetRGBA4d( upper.r, upper.g, upper.b, upper.a );
243 
244  // Interpolate doubles as usual
245  interpVal.r = (*_interpolator)( key, lowerKey, upperKey, lower.r, upper.r );
246  interpVal.g = (*_interpolator)( key, lowerKey, upperKey, lower.g, upper.g );
247  interpVal.b = (*_interpolator)( key, lowerKey, upperKey, lower.b, upper.b );
248  interpVal.a = (*_interpolator)( key, lowerKey, upperKey, lower.a, upper.a );
249 
250  // Convert back to color (note: values from GetRGBA4d() are 0-1.0, not 0-255, so scale up)
251  return glsColor(
252  Detail::ToColorElement( interpVal.r * 255 ),
253  Detail::ToColorElement( interpVal.g * 255 ),
254  Detail::ToColorElement( interpVal.b * 255 ),
255  Detail::ToColorElement( interpVal.a * 255 ) );
256  }
257 
258  private:
259  static GlsKeyframeInterpolator<double>* CreateDefaultInterpolator() { return new GlsLinearInterpolator<double>(); }
260 
261  // Data members
263  };
264 
269  template<class Value>
271  {
272  // Define dependent names for GCC's two-phase lookup
274 
277  const Key& key,
278  const Key& /*lowerKey*/, const Key& upperKey,
279  const Value& lowerValue, const Value& upperValue ) const // override
280  {
281  // Send the lower value unless we've hit the upper value.
282  if( Equal( key, upperKey, Detail::g_glsAnimationFloatTolerance ) )
283  {
284  return upperValue;
285  }
286  else
287  {
288  return lowerValue;
289  }
290  }
291  };
292 
300  template<class Value> struct GlsSphericalLinearInterpolator;
301 
303  template<>
304  struct GlsSphericalLinearInterpolator<GlsQuaternionD> : GlsKeyframeInterpolator<GlsQuaternionD>
305  {
306  // Define dependent names for GCC's two-phase lookup
309 
311  Value operator()(
312  const Key& key,
313  const Key& lowerKey, const Key& upperKey,
314  const Value& lowerValue, const Value& upperValue ) const // override
315  {
316  const float interpPercent = static_cast<float>( (key - lowerKey) / (upperKey - lowerKey) );
317  Value interpVal;
318  interpVal.SetFromSlerp( interpPercent, lowerValue, upperValue );
319  return interpVal;
320  }
321  };
322 
328  template<>
330  {
331  // Define dependent names for GCC's two-phase lookup
335 
338  {
339  for( Size n = 0; n < s_cacheSize; ++n )
340  {
341  _cache[n].second = GlsQuaternionD( _cache[n].first );
342  }
343  }
344 
348  Value operator()(
349  const Key& key,
350  const Key& lowerKey, const Key& upperKey,
351  const Value& lowerValue, const Value& upperValue ) const // override
352  {
353  const LowerUpperQuaternions quaternions = GetQuaternionsFromCache( lowerValue, upperValue );
354  const float interpPercent = static_cast<float>( (key - lowerKey) / (upperKey - lowerKey) );
355  GlsQuaternionD interpVal;
356  interpVal.SetFromSlerp( interpPercent, quaternions.first, quaternions.second );
357  return interpVal.GetEulerAngles() * float(RAD_TO_DEG);
358  }
359 
360  #if GLS_DEBUG // For testing
361  static Size GetCacheSize() { return s_cacheSize; }
363  const std::pair<Vector, GlsQuaternionD>* GetCache() const { return _cache; }
364  #endif
365 
366  private:
368  // Types
369  typedef std::pair<GlsQuaternionD, GlsQuaternionD> LowerUpperQuaternions;
370 
372  // Looks for the quaternions in the cache or computes them afresh. Updates the cache if needed.
373  std::pair<GlsQuaternionD, GlsQuaternionD> GetQuaternionsFromCache( const Value& lowerValue, const Value& upperValue ) const
374  {
375  GlsQuaternionD lowerQuat;
376  GlsQuaternionD upperQuat;
377 
378  // Initializing to the size represents the quat not being found yet
379  Size lowerNdx = s_cacheSize;
380  Size upperNdx = s_cacheSize;
381 
382  // Search the cache for previously used quaternions
383  for( Size n = 0; n < s_cacheSize && (lowerNdx == s_cacheSize || upperNdx == s_cacheSize); ++n )
384  {
385  if( lowerNdx == s_cacheSize && lowerValue.CloseTo( _cache[n].first ) )
386  {
387  lowerQuat = _cache[n].second;
388  lowerNdx = n;
389  }
390  else if( upperNdx == s_cacheSize && upperValue.CloseTo( _cache[n].first ) )
391  {
392  upperQuat = _cache[n].second;
393  upperNdx = n;
394  }
395  }
396 
397  // Did we find them?
398  if( lowerNdx == s_cacheSize )
399  {
400  const Vector anglesInRadians = lowerValue * float(DEG_TO_RAD);
401  lowerQuat.SetFromEulerAngles( anglesInRadians.x, anglesInRadians.y, anglesInRadians.z );
402  // Save return val so we don't cache upper on top of a newly cached lower
403  lowerNdx = SaveInCache( lowerValue, lowerQuat, lowerNdx, upperNdx );
404  }
405 
406  if( upperNdx == s_cacheSize )
407  {
408  const Vector anglesInRadians = upperValue * float(DEG_TO_RAD);
409  upperQuat.SetFromEulerAngles( anglesInRadians.x, anglesInRadians.y, anglesInRadians.z );
410  SaveInCache( upperValue, upperQuat, lowerNdx, upperNdx ); // Ignore return val
411  }
412 
413  return std::make_pair( lowerQuat, upperQuat );
414  }
415 
417  Size SaveInCache( const Value& value, const GlsQuaternionD& quat, const Size lowerNdx, const Size upperNdx ) const
418  {
419  for( Size n = 0; n < s_cacheSize; ++n )
420  {
421  if( n == lowerNdx || n == upperNdx )
422  {
423  continue;
424  }
425  _cache[n] = std::make_pair( value, quat );
426  return n;
427  }
428  DistiAssert( !"GlsAnimation: GlsSphericalLinearInterpolator<Vector> cache logic is broken." );
429  return s_cacheSize;
430  }
431 
433  // Data members
434  static const Size s_cacheSize = 2;
435  mutable std::pair< Vector, GlsQuaternionD > _cache[ s_cacheSize ];
436  };
437 
438 
442  template<class Value>
444  {
445  // Define dependent names for GCC's two-phase lookup
448 
450  Value operator()(
451  const Key& key,
452  const Key& lowerKey, const Key& upperKey,
453  const Value& lowerValue, const Value& upperValue) const // override
454  {
455  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
456  const Value interpVal = (upperValue - lowerValue) * percent * percent + lowerValue;
457  return interpVal;
458  }
459  };
460 
464  template<class Value>
466  {
467  // Define dependent names for GCC's two-phase lookup
470 
472  Value operator()(
473  const Key& key,
474  const Key& lowerKey, const Key& upperKey,
475  const Value& lowerValue, const Value& upperValue) const // override
476  {
477  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
478  const Value interpVal = (-(upperValue - lowerValue)) * percent * ( percent - 2 ) + lowerValue;
479  return interpVal;
480  }
481  };
482 
486  template<class Value>
488  {
489  // Define dependent names for GCC's two-phase lookup
492 
494  Value operator()(
495  const Key& key,
496  const Key& lowerKey, const Key& upperKey,
497  const Value& lowerValue, const Value& upperValue) const // override
498  {
499  Float percent = static_cast<Float>((key - lowerKey) / ((upperKey - lowerKey) /2)); // t/(d/2)
500  Value interpVal;
501  if (percent < 1)
502  {
503  interpVal = ((upperValue - lowerValue)/2) * percent * percent + lowerValue;
504  }
505  else
506  {
507  --percent;
508  interpVal = (-(upperValue - lowerValue) / 2) * (percent * (percent - 2) - 1) + lowerValue;
509  }
510  return interpVal;
511  }
512  };
513 
517  template<class Value>
519  {
520  // Define dependent names for GCC's two-phase lookup
523 
525  Value operator()(
526  const Key& key,
527  const Key& lowerKey, const Key& upperKey,
528  const Value& lowerValue, const Value& upperValue) const // override
529  {
530  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
531  const Value interpVal = (upperValue - lowerValue) * percent * percent * percent + lowerValue;
532  return interpVal;
533  }
534  };
535 
539  template<class Value>
541  {
542  // Define dependent names for GCC's two-phase lookup
545 
547  Value operator()(
548  const Key& key,
549  const Key& lowerKey, const Key& upperKey,
550  const Value& lowerValue, const Value& upperValue) const // override
551  {
552  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey)) - 1;
553  const Value interpVal = (upperValue - lowerValue) * (percent * percent * percent + 1) + lowerValue;
554  return interpVal;
555  }
556  };
557 
561  template<class Value>
563  {
564  // Define dependent names for GCC's two-phase lookup
567 
569  Value operator()(
570  const Key& key,
571  const Key& lowerKey, const Key& upperKey,
572  const Value& lowerValue, const Value& upperValue) const // override
573  {
574  Float percent = static_cast<Float>((key - lowerKey) / ((upperKey - lowerKey) /2));
575  Value interpVal;
576  if (percent < 1)
577  {
578  interpVal = ((upperValue - lowerValue) / 2) * percent * percent * percent + lowerValue;
579  }
580  else
581  {
582  percent -= 2;
583  interpVal = ((upperValue - lowerValue) / 2) * (percent * percent * percent + 2) + lowerValue;
584  }
585  return interpVal;
586  }
587  };
588 
592  template<class Value>
594  {
595  // Define dependent names for GCC's two-phase lookup
598 
600  Value operator()(
601  const Key& key,
602  const Key& lowerKey, const Key& upperKey,
603  const Value& lowerValue, const Value& upperValue) const // override
604  {
605  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
606  const Value interpVal = (upperValue - lowerValue) * percent * percent * percent * percent + lowerValue;
607  return interpVal;
608  }
609  };
610 
614  template<class Value>
616  {
617  // Define dependent names for GCC's two-phase lookup
620 
622  Value operator()(
623  const Key& key,
624  const Key& lowerKey, const Key& upperKey,
625  const Value& lowerValue, const Value& upperValue) const // override
626  {
627  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey)) - 1;
628  const Value interpVal = -(upperValue - lowerValue) * (percent * percent * percent * percent - 1) + lowerValue;
629  return interpVal;
630  }
631  };
632 
636  template<class Value>
638  {
639  // Define dependent names for GCC's two-phase lookup
642 
644  Value operator()(
645  const Key& key,
646  const Key& lowerKey, const Key& upperKey,
647  const Value& lowerValue, const Value& upperValue) const // override
648  {
649  Float percent = static_cast<Float>((key - lowerKey) / ((upperKey - lowerKey) /2));
650  Value interpVal;
651  if (percent < 1)
652  {
653  interpVal = ((upperValue - lowerValue) / 2) * percent * percent * percent * percent + lowerValue;
654  }
655  else
656  {
657  percent -= 2;
658  interpVal = -((upperValue - lowerValue) / 2) * (percent * percent * percent * percent - 2) + lowerValue;
659  }
660  return interpVal;
661  }
662  };
663 
667  template<class Value>
669  {
670  // Define dependent names for GCC's two-phase lookup
673 
675  Value operator()(
676  const Key& key,
677  const Key& lowerKey, const Key& upperKey,
678  const Value& lowerValue, const Value& upperValue) const // override
679  {
680  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
681  const Value interpVal = (upperValue - lowerValue) * percent * percent * percent * percent * percent + lowerValue;
682  return interpVal;
683  }
684  };
685 
689  template<class Value>
691  {
692  // Define dependent names for GCC's two-phase lookup
695 
697  Value operator()(
698  const Key& key,
699  const Key& lowerKey, const Key& upperKey,
700  const Value& lowerValue, const Value& upperValue) const // override
701  {
702  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey)) - 1;
703  const Value interpVal = (upperValue - lowerValue) * (percent * percent * percent * percent * percent + 1) + lowerValue;
704  return interpVal;
705  }
706  };
707 
711  template<class Value>
713  {
714  // Define dependent names for GCC's two-phase lookup
717 
719  Value operator()(
720  const Key& key,
721  const Key& lowerKey, const Key& upperKey,
722  const Value& lowerValue, const Value& upperValue) const // override
723  {
724  Float percent = static_cast<Float>((key - lowerKey) / ((upperKey - lowerKey) /2));
725  Value interpVal;
726  if (percent < 1)
727  {
728  interpVal = ((upperValue - lowerValue) / 2) * percent * percent * percent * percent * percent + lowerValue;
729  }
730  else
731  {
732  percent -= 2;
733  interpVal = ((upperValue - lowerValue) / 2) * (percent * percent * percent * percent * percent + 2) + lowerValue;
734  }
735  return interpVal;
736  }
737  };
738 
742  template<class Value>
744  {
745  // Define dependent names for GCC's two-phase lookup
748 
750  Value operator()(
751  const Key& key,
752  const Key& lowerKey, const Key& upperKey,
753  const Value& lowerValue, const Value& upperValue) const // override
754  {
755  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
756  const Value interpVal = -(upperValue - lowerValue) * std::cos(percent * (Float(Detail::g_pi) / 2)) + (upperValue - lowerValue) + lowerValue;
757  return interpVal;
758  }
759  };
760 
764  template<class Value>
766  {
767  // Define dependent names for GCC's two-phase lookup
770 
772  Value operator()(
773  const Key& key,
774  const Key& lowerKey, const Key& upperKey,
775  const Value& lowerValue, const Value& upperValue) const // override
776  {
777  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
778  const Value interpVal = (upperValue - lowerValue) * std::sin(percent * (Float(Detail::g_pi) / 2)) + lowerValue;
779  return interpVal;
780  }
781  };
782 
786  template<class Value>
788  {
789  // Define dependent names for GCC's two-phase lookup
792 
794  Value operator()(
795  const Key& key,
796  const Key& lowerKey, const Key& upperKey,
797  const Value& lowerValue, const Value& upperValue) const // override
798  {
799  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
800  const Value interpVal = -((upperValue - lowerValue) / 2) * (std::cos(Float(Detail::g_pi)*percent) - 1) + lowerValue;
801  return interpVal;
802  }
803  };
804 
808  template<class Value>
810  {
811  // Define dependent names for GCC's two-phase lookup
814 
816  Value operator()(
817  const Key& key,
818  const Key& lowerKey, const Key& upperKey,
819  const Value& lowerValue, const Value& upperValue) const // override
820  {
821  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
822  const Value interpVal = (upperValue - lowerValue) * ( std::pow( Float(2.0), 10 * ( percent - 1 ) ) ) + lowerValue;
823  return interpVal;
824  }
825  };
826 
830  template<class Value>
832  {
833  // Define dependent names for GCC's two-phase lookup
836 
838  Value operator()(
839  const Key& key,
840  const Key& lowerKey, const Key& upperKey,
841  const Value& lowerValue, const Value& upperValue) const // override
842  {
843  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
844  const Value interpVal = (upperValue - lowerValue) * ( -std::pow( Float(2.0), -10 * percent ) + 1 ) + lowerValue;
845  return interpVal;
846  }
847  };
848 
852  template<class Value>
854  {
855  // Define dependent names for GCC's two-phase lookup
858 
860  Value operator()(
861  const Key& key,
862  const Key& lowerKey, const Key& upperKey,
863  const Value& lowerValue, const Value& upperValue) const // override
864  {
865  Float percent = static_cast<Float>((key - lowerKey) / ((upperKey - lowerKey) /2));
866  Value interpVal;
867  if (percent < 1)
868  {
869  interpVal = ((upperValue - lowerValue) / 2) * std::pow( Float(2.0), 10*(percent - 1) ) + lowerValue;
870  }
871  else
872  {
873  --percent;
874  interpVal = ((upperValue - lowerValue) / 2) * (-std::pow(Float(2.0), -10 * percent) + 2) + lowerValue;
875  }
876  return interpVal;
877  }
878  };
879 
883  template<class Value>
885  {
886  // Define dependent names for GCC's two-phase lookup
889 
891  Value operator()(
892  const Key& key,
893  const Key& lowerKey, const Key& upperKey,
894  const Value& lowerValue, const Value& upperValue) const // override
895  {
896  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
897  const Value interpVal = -(upperValue - lowerValue) * (std::sqrt(1 - percent*percent) - 1) + lowerValue;
898  return interpVal;
899  }
900  };
901 
905  template<class Value>
907  {
908  // Define dependent names for GCC's two-phase lookup
911 
913  Value operator()(
914  const Key& key,
915  const Key& lowerKey, const Key& upperKey,
916  const Value& lowerValue, const Value& upperValue) const // override
917  {
918  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey)) - 1;
919  const Value interpVal = (upperValue - lowerValue) * std::sqrt(1 - percent*percent) + lowerValue;
920  return interpVal;
921  }
922  };
923 
927  template<class Value>
929  {
930  // Define dependent names for GCC's two-phase lookup
933 
935  Value operator()(
936  const Key& key,
937  const Key& lowerKey, const Key& upperKey,
938  const Value& lowerValue, const Value& upperValue) const // override
939  {
940  Float percent = static_cast<Float>((key - lowerKey) / ((upperKey - lowerKey) /2));
941  Value interpVal;
942  if (percent < 1)
943  {
944  interpVal = -((upperValue - lowerValue) / 2) * (std::sqrt(1 - percent*percent) - 1) + lowerValue;
945  }
946  else
947  {
948  percent -= 2;
949  interpVal = ((upperValue - lowerValue) / 2) * (std::sqrt(1 - percent*percent) + 1) + lowerValue;
950  }
951  return interpVal;
952  }
953  };
954 
958  template<class Value>
960  {
961  // Define dependent names for GCC's two-phase lookup
964 
966  Value operator()(
967  const Key& key,
968  const Key& lowerKey, const Key& upperKey,
969  const Value& lowerValue, const Value& upperValue) const // override
970  {
971  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey)) - 1;
972  const Value interpVal = (-((upperValue - lowerValue) * std::pow(Float(2.0),10*percent) * std::sin( (percent-.075f)*(Float(2.0) * Float(Detail::g_pi))/0.3f)) + lowerValue );
973  return interpVal;
974  }
975  };
976 
980  template<class Value>
982  {
983  // Define dependent names for GCC's two-phase lookup
986 
988  Value operator()(
989  const Key& key,
990  const Key& lowerKey, const Key& upperKey,
991  const Value& lowerValue, const Value& upperValue) const // override
992  {
993  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
994  const Value interpVal = ((upperValue - lowerValue) * std::pow(Float(2.0),-10*(percent)) * std::sin( (percent-.075f)*(Float(2.0) * Float(Detail::g_pi))/0.3f) + upperValue );
995  return interpVal;
996  }
997  };
998 
1002  template<class Value>
1004  {
1005  // Define dependent names for GCC's two-phase lookup
1008 
1010  Value operator()(
1011  const Key& key,
1012  const Key& lowerKey, const Key& upperKey,
1013  const Value& lowerValue, const Value& upperValue) const // override
1014  {
1015  const Float percent = static_cast<Float>((key - lowerKey) / ((upperKey - lowerKey) /2)) - 1;
1016  Value interpVal;
1017  if (percent < 0)
1018  {
1019  interpVal = ((upperValue - lowerValue) * std::pow(Float(2.0), 10*percent) * std::sin( (percent-.1125f)*(Float(2.0) * Float(Detail::g_pi))/.45f )) * -0.5f + lowerValue;
1020  }
1021  else
1022  {
1023  interpVal = (upperValue - lowerValue) * std::pow(Float(2.0),-10*(percent)) * std::sin( (percent-.1125f)*(Float(2.0) * Float(Detail::g_pi))/.45f )*.5f + upperValue;
1024  }
1025  return interpVal;
1026  }
1027  };
1028 
1032  template<class Value>
1034  {
1035  // Define dependent names for GCC's two-phase lookup
1038 
1040  Value operator()(
1041  const Key& key,
1042  const Key& lowerKey, const Key& upperKey,
1043  const Value& lowerValue, const Value& upperValue) const // override
1044  {
1045  const Float percent = static_cast<Float>(((upperKey - lowerKey) - (key - lowerKey)) / (upperKey - lowerKey));
1046  Value interpVal;
1047  if( percent < (1/2.75) )
1048  {
1049  interpVal = (upperValue - lowerValue)*( 7.5625f*percent*percent) + lowerValue;
1050  }
1051  else if( percent < (2/2.75) )
1052  {
1053  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-1.500f/2.75f)*(percent-1.500f/2.75f) ) + .75f) + lowerValue) ;
1054  }
1055  else if( (percent < (2.5/2.75)) )
1056  {
1057  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-2.250f/2.75f)*(percent-2.250f/2.75f) ) + .9375f) + lowerValue);
1058  }
1059  else
1060  {
1061  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-2.625f/2.75f)*(percent-2.625f/2.75f) ) + .984375f) + lowerValue);
1062  }
1063  return (upperValue - lowerValue) - interpVal + lowerValue;
1064  }
1065  };
1066 
1070  template<class Value>
1072  {
1073  // Define dependent names for GCC's two-phase lookup
1076 
1078  Value operator()(
1079  const Key& key,
1080  const Key& lowerKey, const Key& upperKey,
1081  const Value& lowerValue, const Value& upperValue) const // override
1082  {
1083  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
1084  Value interpVal;
1085  if( percent < (1/2.75) )
1086  {
1087  interpVal = (upperValue - lowerValue)*( 7.5625f*percent*percent) + lowerValue;
1088  }
1089  else if( percent < (2/2.75) )
1090  {
1091  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-1.500f/2.75f)*(percent-1.500f/2.75f) ) + .75f) + lowerValue) ;
1092  }
1093  else if( (percent < (2.5/2.75)) )
1094  {
1095  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-2.250f/2.75f)*(percent-2.250f/2.75f) ) + .9375f) + lowerValue);
1096  }
1097  else
1098  {
1099  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-2.625f/2.75f)*(percent-2.625f/2.75f) ) + .984375f) + lowerValue);
1100  }
1101  return interpVal;
1102  }
1103  };
1104 
1108  template<class Value>
1110  {
1111  // Define dependent names for GCC's two-phase lookup
1114 
1116  Value operator()(
1117  const Key& key,
1118  const Key& lowerKey, const Key& upperKey,
1119  const Value& lowerValue, const Value& upperValue) const // override
1120  {
1121  if(((key - lowerKey) < (upperKey - lowerKey) * 0.5))
1122  {
1123  const Float percent = static_cast<Float>(((upperKey - lowerKey) - (2 * (key - lowerKey))) / (upperKey - lowerKey));
1124  Value interpVal;
1125  if( percent < (1/2.75) )
1126  {
1127  interpVal = (upperValue - lowerValue)*( 7.5625f*percent*percent) + lowerValue;
1128  }
1129  else if( percent < (2/2.75) )
1130  {
1131  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-1.500f/2.75f)*(percent-1.500f/2.75f) ) + .75f) + lowerValue) ;
1132  }
1133  else if( (percent < (2.5/2.75)) )
1134  {
1135  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-2.250f/2.75f)*(percent-2.250f/2.75f) ) + .9375f) + lowerValue);
1136  }
1137  else
1138  {
1139  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-2.625f/2.75f)*(percent-2.625f/2.75f) ) + .984375f) + lowerValue);
1140  }
1141  return ((upperValue - lowerValue) - interpVal + lowerValue) * 0.5f + lowerValue;
1142  }
1143  else
1144  {
1145  const Float percent = static_cast<Float>((2 * (key - lowerKey) -(upperKey - lowerKey))/ (upperKey - lowerKey));
1146  Value interpVal;
1147  if( percent < (1/2.75) )
1148  {
1149  interpVal = (upperValue - lowerValue)*( 7.5625f*percent*percent) + lowerValue;
1150  }
1151  else if( percent < (2/2.75) )
1152  {
1153  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-1.500f/2.75f)*(percent-1.500f/2.75f) ) + .75f) + lowerValue) ;
1154  }
1155  else if( (percent < (2.5/2.75)) )
1156  {
1157  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-2.250f/2.75f)*(percent-2.250f/2.75f) ) + .9375f) + lowerValue);
1158  }
1159  else
1160  {
1161  interpVal = ( (upperValue - lowerValue)*( (7.5625f*(percent-2.625f/2.75f)*(percent-2.625f/2.75f) ) + .984375f) + lowerValue);
1162  }
1163  return (interpVal) * 0.5f + (upperValue - lowerValue) * 0.5f + lowerValue;
1164  }
1165  }
1166  };
1167 
1171  template<class Value>
1173  {
1174  // Define dependent names for GCC's two-phase lookup
1177 
1179  Value operator()(
1180  const Key& key,
1181  const Key& lowerKey, const Key& upperKey,
1182  const Value& lowerValue, const Value& upperValue) const // override
1183  {
1184  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey));
1185  const Value interpVal = (upperValue - lowerValue) * percent * percent*((1.70158f+1)*percent - 1.70158f) + lowerValue;
1186  return interpVal;
1187  }
1188  };
1189 
1193  template<class Value>
1195  {
1196  // Define dependent names for GCC's two-phase lookup
1199 
1201  Value operator()(
1202  const Key& key,
1203  const Key& lowerKey, const Key& upperKey,
1204  const Value& lowerValue, const Value& upperValue) const // override
1205  {
1206  const Float percent = static_cast<Float>((key - lowerKey) / (upperKey - lowerKey)) - 1;
1207  const Value interpVal = (upperValue - lowerValue) *(percent*percent*((1.70158f+1)*percent + 1.70158f) + 1) + lowerValue;
1208  return interpVal;
1209  }
1210  };
1211 
1215  template<class Value>
1217  {
1218  // Define dependent names for GCC's two-phase lookup
1221 
1223  Value operator()(
1224  const Key& key,
1225  const Key& lowerKey, const Key& upperKey,
1226  const Value& lowerValue, const Value& upperValue) const // override
1227  {
1228  Float percent = static_cast<Float>((key - lowerKey) / ((upperKey - lowerKey) /2));
1229  Value interpVal;
1230  if (percent < 1)
1231  {
1232  interpVal = (upperValue - lowerValue) / 2 * (percent*percent*(3.5949095f*percent - 2.5949095f)) + lowerValue;
1233  }
1234  else
1235  {
1236  percent -= 2;
1237  interpVal = (upperValue - lowerValue) / 2 * (percent * percent *(3.5949095f*percent + 2.5949095f) + 2) + lowerValue;
1238  }
1239  return interpVal;
1240  }
1241  };
1242 
1243  namespace Detail
1244  {
1248  template<class Value> struct DefaultInterpolator { typedef GlsLinearInterpolator<Value> Type; };
1249  template<> struct DefaultInterpolator<GlsQuaternionD> { typedef GlsSphericalLinearInterpolator<GlsQuaternionD> Type; };
1250  template<> struct DefaultInterpolator<std::string> { typedef GlsGatedInterpolator<std::string> Type; };
1251  template<> struct DefaultInterpolator<glsColor> { typedef GlsColorInterpolationAdapter Type; };
1252 
1254  const GlsKeyframeCurveBase::Key g_nan = std::numeric_limits<GlsKeyframeCurveBase::Key>::quiet_NaN();
1255 
1258  inline bool IsNaN( const double d )
1259  {
1260  #ifdef __FAST_MATH__
1261  // GCC's -ffast-math flag doesn't support d != d checking for NaN, so we have to compare bit patterns
1262  return 0 == std::memcmp( reinterpret_cast<const void*>( &d ), reinterpret_cast<const void*>( &g_nan ), sizeof( double ) );
1263  #else
1264  return d != d;
1265  #endif
1266  }
1267  } // namespace Detail
1268 
1271  template<class T>
1273  {
1274  public:
1275  typedef stdortr1::shared_ptr< GlsKeyframeCurve> Ptr;
1276  typedef stdortr1::shared_ptr<const GlsKeyframeCurve> PtrConst;
1277  typedef T Value;
1279 
1284  explicit GlsKeyframeCurve( const GlsKeyframeInterpolator<Value>* const interpolator = new DefaultInterpolator() )
1285  : _interpolator( interpolator ? interpolator : new DefaultInterpolator() )
1286  , _lowerInterpNdx( 0 )
1287  {}
1288 
1293  : _interpolator( interpolator ? interpolator : typename GlsKeyframeInterpolator<Value>::PtrConst(new DefaultInterpolator()) )
1294  , _lowerInterpNdx( 0 )
1295  {}
1296 
1298  Size GetKeyframeCount() const // override
1299  {
1300  return _keyframes.size();
1301  }
1302 
1304  KeyPair GetMinMaxKeys() const // override
1305  {
1306  // Handle precondition
1307  if( 0 == GetKeyframeCount() )
1308  {
1309  return std::make_pair( Detail::g_nan, Detail::g_nan );
1310  }
1311 
1312  return std::make_pair( _keyframes.front().key, _keyframes.back().key );
1313  }
1314 
1322  void AddKeyframe( const Key& key, const Value& value, const Key& tolerance = Detail::g_glsAnimationFloatTolerance )
1323  {
1324  DistiAssert( !Detail::IsNaN( key ) );
1325 
1326  const Size count = GetKeyframeCount();
1327  DistiAssert( count != (std::numeric_limits<Size>::max)() ); // Are we out of room? (Extra parens avoid the NOMINMAX problems on Windows.)
1328 
1329  // Find the insertion point
1330  Size n = 0;
1331  while( n < count && _keyframes[ n ].key < key )
1332  {
1333  ++n;
1334  }
1335 
1336  // Put the value in the keyframe list
1337  if( n < count && Equal( _keyframes[ n ].key, key, static_cast<float>( tolerance ) ) )
1338  {
1339  // Replace the existing keyframe
1340  _keyframes[ n ].value = value;
1341  }
1342  else
1343  {
1344  // Add a new keyframe
1345  _keyframes.insert( _keyframes.begin() + n, KeyValue( key, value ) );
1346  }
1347  }
1348 
1358  Value Interpolate( const Key& key ) const
1359  {
1360  // Handle edge cases
1361  const Size count = GetKeyframeCount();
1362  if( 0 == count || Detail::IsNaN( key ) )
1363  {
1364  return Value();
1365  }
1366  else if( 1 == count // Only one value, no interpolation possible
1367  || Detail::FloatLessThanOrEqualTo( key, _keyframes[0].key ) ) // Clamp to lowest value
1368  {
1369  _lowerInterpNdx = 0;
1370  return _keyframes[ 0 ].value;
1371  }
1372  else if( Detail::FloatGreaterThanOrEqualTo( key, _keyframes[ count - 1 ].key ) ) // Clamp to highest value
1373  {
1374  _lowerInterpNdx = count - 2; // Save one before the last keyframe as the lower index
1375  return _keyframes[ count - 1 ].value;
1376  }
1377 
1378  // Find the right pair of interpolation keyframes
1379  _lowerInterpNdx = ComputeInterpLowerNdx( key, count );
1380 
1381  // Interpolate between the two keyframes
1382  const KeyValue lower = _keyframes[ _lowerInterpNdx ];
1383  const KeyValue upper = _keyframes[ _lowerInterpNdx + 1 ];
1384  const Value value = (*_interpolator)( key, lower.key, upper.key, lower.value, upper.value );
1385  return value;
1386  }
1387 
1388  #ifdef GLS_DEBUG // For testing
1389  Size GetLowerInterpNdx() const { return _lowerInterpNdx; }
1391  #endif
1392 
1393  private:
1394  // Find the lower index of the right pair of interpolation keyframes
1395  Size ComputeInterpLowerNdx( const Key& key, const Size& count ) const
1396  {
1397  // Can we use our previous interp value? If not, perform a linear search up or down
1398  // from the last used key. This is likely to be faster than a binary search on the
1399  // same key set (lower half or upper half) when the keys are changing monotonically up
1400  // or down in relatively small increments, which will usually be the case, because it
1401  // will almost always find the next key range within one or two comparisons.
1402  if( key >= _keyframes[ _lowerInterpNdx ].key
1403  && key <= _keyframes[ _lowerInterpNdx + 1 ].key )
1404  {
1405  return _lowerInterpNdx;
1406  }
1407  else if( key < _keyframes[ _lowerInterpNdx ].key )
1408  {
1409  DistiAssert( _lowerInterpNdx != 0 ); // Should be caught by previous conditions
1410 
1411  // Search down in the list from the last interpolation point (see comment at top of function)
1412  Size interpLowerNdx = _lowerInterpNdx - 1;
1413  while( interpLowerNdx != 0 && key < _keyframes[ interpLowerNdx ].key )
1414  {
1415  --interpLowerNdx;
1416  }
1417  return interpLowerNdx;
1418  }
1419  else
1420  {
1421  DistiAssert( _lowerInterpNdx != (count - 2) ); // Should be caught by previous conditions
1422 
1423  // Search up in the list from the last interpolation point (see comment at top of function)
1424  Size interpLowerNdx = _lowerInterpNdx + 1;
1425  while( interpLowerNdx < count - 2 && _keyframes[ interpLowerNdx + 1 ].key < key )
1426  {
1427  ++interpLowerNdx;
1428  }
1429  return interpLowerNdx;
1430  }
1431  }
1432 
1433  // Key-value pair struct (improves readibility over std::pair)
1434  struct KeyValue
1435  {
1436  Key key;
1437  Value value;
1438 
1439  KeyValue() {}
1440  KeyValue( const Key& key_, const Value& value_ )
1441  : key( key_ ), value( value_ )
1442  {}
1443  };
1444 
1445  // Data members
1446  std::vector< KeyValue > _keyframes; // Need random access, so a map isn't a good fit.
1447  typename GlsKeyframeInterpolator<Value>::PtrConst _interpolator;
1448  mutable Size _lowerInterpNdx; // cache value
1449  };
1450 }
1451 
1452 #endif
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:468
Definition: gls_keyframe.h:615
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:715
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:1219
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:1112
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:1223
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:1175
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:1007
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:1220
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:469
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:719
GlsKeyframeCurveBase::Size Size
Alias for easier reading.
Definition: gls_keyframe.h:334
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:596
Detail::FloatSelector< Value >::Type Float
Alias for easier reading.
Definition: gls_keyframe.h:170
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:641
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:694
stdortr1::shared_ptr< const GlsKeyframeCurve > PtrConst
Alias for easier reading.
Definition: gls_keyframe.h:1276
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:835
Definition: gls_keyframe.h:540
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:1037
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:988
GlsGatedInterpolator< std::string > Type
Definition: gls_keyframe.h:1250
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:1179
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:769
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:794
GlsKeyframeInterpolator< GlsQuaternionD >::Value Value
Alias for easier reading.
Definition: gls_keyframe.h:307
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:600
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:984
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:447
Definition: gls_keyframe.h:853
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:910
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:697
Definition: gls_keyframe.h:809
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:490
Class template for keyframe curves of different types (double, Vector, etc.)
Definition: gls_keyframe.h:1272
Definition: gls_keyframe.h:884
Definition: gls_keyframe.h:1003
A helper class for choosing the required floating-point type.
Definition: gls_keyframe.h:109
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:644
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:543
Definition: gls_keyframe.h:765
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:565
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:333
Definition: gls_keyframe.h:300
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:966
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:675
Definition: gls_keyframe.h:593
Definition: gls_keyframe.h:270
virtual ~GlsKeyframeInterpolator()
Destructor.
Definition: gls_keyframe.h:173
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:671
Definition: gls_keyframe.h:1172
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:547
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:812
Definition: gls_keyframe.h:1216
GlsColorInterpolationAdapter()
Constructor which creates a default interpolator.
Definition: gls_keyframe.h:216
stdortr1::shared_ptr< GlsKeyframeCurve > Ptr
Alias for easier reading.
Definition: gls_keyframe.h:1275
An abstract base class for all keyframe interpolators.
Definition: gls_keyframe.h:164
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:1197
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:746
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:273
T Value
The templated type.
Definition: gls_keyframe.h:1277
Definition: gls_keyframe.h:1248
Definition: gls_keyframe.h:443
Value operator()(const Key &key, const Key &, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:276
GlsKeyframeCurveBase::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:168
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:913
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:640
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:1116
Definition: gls_keyframe.h:1033
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:816
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:311
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:619
void AddKeyframe(const Key &key, const Value &value, const Key &tolerance=Detail::g_glsAnimationFloatTolerance)
Definition: gls_keyframe.h:1322
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:888
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:491
T Value
Alias for easier reading.
Definition: gls_keyframe.h:169
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:569
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:1040
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:1074
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:791
std::size_t Size
The size type for sizes and indices.
Definition: gls_keyframe.h:77
virtual Size GetKeyframeCount() const =0
Returns the number of keyframes.
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:985
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:522
Definition: gls_keyframe.h:465
Definition: gls_keyframe.h:928
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:525
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:891
Definition: gls_keyframe.h:637
virtual KeyPair GetMinMaxKeys() const =0
GlsColorInterpolationAdapter(GlsKeyframeInterpolator< double >::PtrConst interpolator)
Definition: gls_keyframe.h:229
Definition: gls_keyframe.h:712
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:963
Definition: gls_keyframe.h:743
Base class for the keyframe curve class template.
Definition: gls_keyframe.h:73
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:962
virtual Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const =0
stdortr1::shared_ptr< GlsKeyframeInterpolator > Ptr
Alias for easier reading.
Definition: gls_keyframe.h:166
Detail::DefaultInterpolator< Value >::Type DefaultInterpolator
The default interpolator for the given Value type.
Definition: gls_keyframe.h:1278
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:521
Definition: gls_keyframe.h:668
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:747
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:1201
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:931
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:195
Definition: gls_keyframe.h:959
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:622
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:750
GlsSphericalLinearInterpolator< GlsQuaternionD > Type
Definition: gls_keyframe.h:1249
GlsKeyframeInterpolator< Vector >::Value Value
Alias for easier reading.
Definition: gls_keyframe.h:332
Definition: gls_keyframe.h:787
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:856
stdortr1::shared_ptr< const GlsKeyframeInterpolator > PtrConst
Alias for easier reading.
Definition: gls_keyframe.h:167
Definition: gls_keyframe.h:1109
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:597
Definition: gls_keyframe.h:831
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:772
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:1006
Definition: gls_keyframe.h:1071
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:887
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:672
Definition: gls_keyframe.h:906
Definition: gls_keyframe.h:1194
GlsSphericalLinearInterpolator()
Constructor.
Definition: gls_keyframe.h:337
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:857
Definition: gls_keyframe.h:487
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:1113
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:716
Definition: gls_keyframe.h:213
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:618
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:860
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:1036
float Type
Definition: gls_keyframe.h:110
GlsKeyframeCurve(typename GlsKeyframeInterpolator< Value >::PtrConst interpolator)
Definition: gls_keyframe.h:1292
std::pair< Key, Key > KeyPair
Alias for easier reading.
Definition: gls_keyframe.h:78
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:813
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:935
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Definition: gls_keyframe.h:348
GlsLinearInterpolator< Value > Type
Definition: gls_keyframe.h:1248
Definition: gls_keyframe.h:690
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:1078
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:450
Value Interpolate(const Key &key) const
Definition: gls_keyframe.h:1358
GlsKeyframeCurveBase::Key Type
Definition: gls_keyframe.h:109
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:693
virtual ~GlsKeyframeCurveBase()
Destructor.
Definition: gls_keyframe.h:81
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:196
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:1075
Size GetKeyframeCount() const
Override from GlsKeyframeCurveBase.
Definition: gls_keyframe.h:1298
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:544
Definition: gls_keyframe.h:518
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:1198
GlsColorInterpolationAdapter(GlsKeyframeInterpolator< double > *const interpolator)
Definition: gls_keyframe.h:222
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:834
Definition: gls_keyframe.h:562
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:446
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:1176
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:566
KeyPair GetMinMaxKeys() const
Override from GlsKeyframeCurveBase.
Definition: gls_keyframe.h:1304
Definition: gls_animation.cpp:64
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:909
Implementation of GlsSphericalLinearInterpolator for quaternions.
Definition: gls_keyframe.h:304
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:199
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:494
Definition: gls_keyframe.h:981
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:472
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:768
glsColor operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const glsColor &lowerValue, const glsColor &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:234
Definition: gls_keyframe.h:192
double Key
The key type (usually time, but not always)
Definition: gls_keyframe.h:76
GlsColorInterpolationAdapter Type
Definition: gls_keyframe.h:1251
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:790
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:838
GlsKeyframeInterpolator< Value >::Float Float
Alias for easier reading.
Definition: gls_keyframe.h:932
GlsKeyframeInterpolator< Value >::Key Key
Alias for easier reading.
Definition: gls_keyframe.h:308
GlsKeyframeCurve(const GlsKeyframeInterpolator< Value > *const interpolator=new DefaultInterpolator())
Definition: gls_keyframe.h:1284
Value operator()(const Key &key, const Key &lowerKey, const Key &upperKey, const Value &lowerValue, const Value &upperValue) const
Overrides GlsKeyframeInterpolator.
Definition: gls_keyframe.h:1010