15 #ifndef OSGANIMATION_EASE_MOTION
16 #define OSGANIMATION_EASE_MOTION 1
18 #include <osg/Referenced>
19 #include <osg/ref_ptr>
32 result = 7.5625 * t * t;
34 else if (t < (2/2.75))
37 result = 7.5625* t * t + .75;
39 else if (t < (2.5/2.75))
42 result = 7.5625 * t * t + .9375;
47 result = 7.5625* t * t + .984375;
73 result = result * 0.5 + 0.5;
81 inline static void getValueAt(
float t,
float& result) { result = t;}
87 inline static void getValueAt(
float t,
float& result) { result = - (t * (t -2.0));}
92 inline static void getValueAt(
float t,
float& result) { result = t*t;}
101 result = 0.5 * t * t;
105 result = - 0.5 * (t * ( t - 2) - 1);
113 inline static void getValueAt(
float t,
float& result) { t = t-1.0; result = t*t*t + 1;}
118 inline static void getValueAt(
float t,
float& result) { result = t*t*t;}
127 result = 0.5f * t * t * t;
130 result = 0.5 * (t * t * t + 2.0f);
138 inline static void getValueAt(
float t,
float& result) { result = t*t*t*t*t;}
143 inline static void getValueAt(
float t,
float& result) { t = t - 1; result = - (t*t*t*t -1); }
152 result = 0.5*t*t*t*t;
156 result = -0.5 * (t*t*t*t -2);
166 result = pow(2.0f, -10.0f * t) * sinf((t - 0.3f / 4.0f) * (2.0f *
osg::PI) / 0.3f) + 1.0f;
175 result = 1.0f - result;
187 result = -0.5 * (1.0f * pow(2.0f, 10.0f * t) * sinf((t - 0.45f / 4.0f) * (2.0f *
osg::PI) / 0.45f));
192 result = pow(2.0f, -10.0f * t) * sinf((t - 0.45f / 4.0f) * (2.0f *
osg::PI) / 0.45f) * 0.5f + 1.0f;
202 result = sinf(t * (
osg::PI / 2.0f));
210 result = -cosf(t * (
osg::PI / 2.0f)) + 1.0f;
218 result = -0.5f * (cosf((
osg::PI * t)) - 1.0f);
228 result = t * t * ((1.70158 + 1.0f) * t + 1.70158) + 1.0f;
236 result = t * t * ((1.70158 + 1.0f) * t - 1.70158);
244 float s = 1.70158 * 1.525f;
248 result = 0.5f * (t * t * ((s + 1.0f) * t - s));
253 result = 0.5f * ((p) * t * ((s + 1.0f) * t + s) + 2.0f);
264 result = sqrt(1.0f - t * t);
272 result = -(sqrt(1.0f - (t * t)) - 1.0f);
283 result = -0.5f * (sqrt(1.0f - t * t) - 1.0f);
288 result = 0.5f * (sqrt(1 - t * t) + 1.0f);
304 result = -powf(2.0f, -10.0f * t) + 1.0f;
319 result = powf(2.0f, 10.0f * (t - 1.0f));
328 if(t == 0.0f || t == 1.0f)
337 result = 0.5f * powf(2.0f, 10.0f * (t - 1.0f));
341 result = 0.5f * (-powf(2.0f, -10.0f * (t - 1.0f)) + 2.0f);
419 template <
typename T>
435 if (!_sampler.getKeyframeContainer())
440 float size = _sampler.getEndTime() - _sampler.getStartTime();
441 t = t * size + _sampler.getStartTime();
442 _sampler.getValueAt(t, result);
457 if (_motions.empty())
460 osg::notify(
osg::WARN) <<
"CompositeMotion::getValueInNormalizedRange no Motion in the CompositeMotion, add motion to have result" << std::endl;
463 for (MotionList::const_iterator it = _motions.begin(); it != _motions.end(); ++it)
465 const Motion* motion =
static_cast<const Motion*
>(it->get());
467 if (t < durationInRange)
469 float tInRange = t/durationInRange * motion->
getDuration();
473 t = t - durationInRange;
475 osg::notify(
osg::WARN) <<
"CompositeMotion::getValueInNormalizedRange did find the value in range, something wrong" << std::endl;
MathMotionTemplate< InCircFunction > InCircMotion
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
MathMotionTemplate< InOutCubicFunction > InOutCubicMotion
MathMotionTemplate< InCubicFunction > InCubicMotion
static void getValueAt(float t, float &result)
MathMotionTemplate< OutBounceFunction > OutBounceMotion
virtual void getValueInNormalizedRange(float t, value_type &result) const
static void getValueAt(float t, float &result)
value_type getValue() const
CompositeMotion(float startValue=0, float duration=1, float changeValue=1, TimeBehaviour tb=CLAMP)
static void getValueAt(float t, float &result)
value_type getValueAt(float time) const
MathMotionTemplate< OutElasticFunction > OutElasticMotion
MathMotionTemplate< InOutQuadFunction > InOutQuadMotion
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
void getValue(value_type &result) const
void getValueAt(float time, value_type &result) const
virtual void getValueInNormalizedRange(float t, value_type &result) const
MathMotionTemplate< InQuartFunction > InQuartMotion
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
MotionList & getMotionList()
std::vector< osg::ref_ptr< Motion > > MotionList
virtual void getValueInNormalizedRange(float t, value_type &result) const
const T & getSampler() const
MathMotionTemplate< InQuadFunction > InQuadMotion
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
MathMotionTemplate< InOutCircFunction > InOutCircMotion
MathMotionTemplate< LinearFunction > LinearMotion
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
MathMotionTemplate< InOutQuartFunction > InOutQuartMotion
MathMotionTemplate< InBackFunction > InBackMotion
MathMotionTemplate< InElasticFunction > InElasticMotion
virtual void getValueInNormalizedRange(float t, value_type &result) const =0
MathMotionTemplate< InSineFunction > InSineMotion
MathMotionTemplate< OutSineFunction > OutSineMotion
float evaluateTime(float time) const
MathMotionTemplate< OutCircFunction > OutCircMotion
static void getValueAt(float t, float &result)
Motion(float startValue=0, float duration=1, float changeValue=1, TimeBehaviour tb=CLAMP)
const MotionList & getMotionList() const
static void getValueAt(float t, float &result)
MathMotionTemplate< OutQuadFunction > OutQuadMotion
MathMotionTemplate(float startValue=0, float duration=1, float changeValue=1, TimeBehaviour tb=CLAMP)
MathMotionTemplate< InOutSineFunction > InOutSineMotion
static void getValueAt(float t, float &result)
SamplerMotionTemplate(float startValue=0, float duration=1, float changeValue=1, TimeBehaviour tb=CLAMP)
static void getValueAt(float t, float &result)
OSG_EXPORT std::ostream & notify(const NotifySeverity severity)
static void getValueAt(float t, float &result)
static void getValueAt(float t, float &result)
MathMotionTemplate< InExpoFunction > InExpoMotion
MathMotionTemplate< InOutElasticFunction > InOutElasticMotion
MathMotionTemplate< OutExpoFunction > OutExpoMotion
MathMotionTemplate< InOutBackFunction > InOutBackMotion
static void getValueAt(float t, float &result)
MathMotionTemplate< OutCubicFunction > OutCubicMotion
MathMotionTemplate< OutBackFunction > OutBackMotion
MathMotionTemplate< InOutBounceFunction > InOutBounceMotion
static void getValueAt(float t, float &result)
MathMotionTemplate< InBounceFunction > InBounceMotion
MathMotionTemplate< OutQuartFunction > OutQuartMotion
float getDuration() const
static void getValueAt(float t, float &result)
MathMotionTemplate< InOutExpoFunction > InOutExpoMotion