22 #ifndef TETRAEDGE_TE_TE_CURVE_ANIM2_H 23 #define TETRAEDGE_TE_TE_CURVE_ANIM2_H 25 #include "tetraedge/te/te_animation.h" 26 #include "tetraedge/te/te_interpolation.h" 30 template<
class T>
static T linearInterpolation(T &obj1, T &obj2,
double amount) {
31 amount = CLIP<double>(amount, 0.0, 1.0);
32 return (obj1 * (1.0 - amount)) + (obj2 * amount);
35 template<
class T,
class S>
38 typedef void(T::*TMethod)(
const S &);
40 TeCurveAnim2() : _callbackObj(
nullptr), _callbackMethod(
nullptr), _duration(0), _lastUpdateTime(0) {}
41 virtual ~TeCurveAnim2() {}
49 void update(
double millis) {
50 _lastUpdateTime = millis;
52 double amount = _interp.interpole(millis, _duration);
54 const S interpVal = linearInterpolation<S>(_startVal, _endVal, amount);
56 (_callbackObj->*_callbackMethod)(interpVal);
57 if (_lastUpdateTime >= _duration) {
58 if (_repeatCount == -1) {
70 TMethod _callbackMethod;
75 double _lastUpdateTime;
80 #endif // TETRAEDGE_TE_TE_CURVE_ANIM2_H Definition: detection.h:27
Definition: te_curve_anim2.h:36
Definition: te_animation.h:31
Definition: te_interpolation.h:31