43 typedef std::function<float (float)>
EaseFn;
51 return start * ( 1 - time ) + end * time;
69 if( std::isfinite( val.
getAxis().x ) && std::isfinite( val.
getAxis().y ) && std::isfinite( val.
getAxis().z ) )
117 virtual void reset(
bool unsetStarted )
141 class TweenRef :
public std::shared_ptr<Tween<T> > {
144 : std::shared_ptr<
Tween<T> >( sp )
147 : std::shared_ptr<
Tween<T> >( tween )
150 : std::shared_ptr<
Tween<T> >()
155 class Tween :
public TweenBase {
157 typedef std::function<T (const T&, const T&, float)>
LerpFn;
166 Tween( T *
target, T startValue, T endValue,
float startTime,
float duration,
229 std::shared_ptr<Tween<T> > result(
new Tween<T>( *
this ) );
230 result->mCopyStartValue =
false;
236 std::shared_ptr<Tween<T> > result(
new Tween<T>( *
this ) );
237 std::swap( result->mStartValue, result->mEndValue );
238 result->mCopyStartValue =
false;
252 virtual void update(
float relativeTime )
269 :
Tween<T>( &
mValue, startValue, endValue, startTime, duration, easeFunction, lerpFunction ),
mFn( fn ),
mValue( startValue )
273 virtual void update(
float relativeTime )
280 std::function<void (T)>
mFn;
339 operator const T&()
const {
return mValue; }
352 rhs.mParentTimeline.reset();
358 rhs.mParentTimeline.reset();
std::function< T(const T &, const T &, float)> LerpFn
Definition: Tween.h:157
bool mCopyStartValue
Definition: Tween.h:137
Quaternion< T > slerp(T t, const Quaternion< T > &end) const
Definition: Quaternion.h:465
StartFn mStartFunction
Definition: Tween.h:131
FnTweenRef(FnTween< T > *fnTween)
Definition: Tween.h:290
void setLerpFn(const LerpFn &lerpFn)
Definition: Tween.h:182
Options & finishFn(const TweenBase::FinishFn &finishFn)
Definition: Tween.h:193
virtual void update(float relativeTime)
Definition: Tween.h:273
Options & lerpFn(const typename Tween< T >::LerpFn &lerpFn)
Definition: Tween.h:206
EaseFn mEaseFunction
Definition: Tween.h:135
void setFinishFn(FinishFn finishFn)
Definition: Tween.h:98
GLuint start
Definition: GLee.h:963
Options(TweenRef< T > tweenRef, TimelineRef timeline)
Definition: Tween.h:211
float mDuration
Definition: Tween.h:136
virtual TimelineItemRef clone() const
Creates a clone of the item.
Definition: Tween.h:227
TimelineRef mTimeline
Definition: Tween.h:113
Options & appendTo(void *endTarget, float offset=0)
Definition: Tween.h:205
T mEndValue
Definition: Tween.h:260
T getStartValue() const
Returns the starting value for the tween. If the tween will copy its target's value upon starting (is...
Definition: Tween.h:175
void setReverseFinishFn(FinishFn reverseFinishFn)
Definition: Tween.h:101
const T & value() const
Definition: Tween.h:366
EaseFn getEaseFn() const
Definition: Tween.h:87
FinishFn mReverseFinishFunction
Definition: Tween.h:133
std::function< void()> StartFn
Definition: Tween.h:78
T z
Definition: Vector.h:321
Vec3< T > getAxis() const
Definition: Quaternion.h:68
virtual void start(bool reverse)
Definition: Tween.h:242
T x
Definition: Vector.h:321
static Quaternion< float > identity()
Definition: Quaternion.h:733
virtual void reset(bool unsetStarted=false)
Marks the item as not completed, and if unsetStarted, marks the item as not started.
Definition: TimelineItem.h:77
FnTweenRef(const std::shared_ptr< FnTween< T > > &sp)
Definition: Tween.h:287
T * ptr()
Definition: Tween.h:370
std::shared_ptr< class Timeline > TimelineRef
Definition: Timeline.h:40
Options & reverseStartFn(const TweenBase::StartFn &reverseStartFn)
Definition: Tween.h:191
UpdateFn mUpdateFunction
Definition: Tween.h:132
Anim(Anim &&rhs)
Definition: Tween.h:348
Options & pingPong(bool doPingPong=true)
Definition: Tween.h:200
T & value()
Definition: Tween.h:367
Anim< T > & operator=(T value)
Definition: Tween.h:364
GLenum target
Definition: GLee.h:13607
T y
Definition: Vector.h:321
void setStartFn(StartFn startFunction)
Definition: Tween.h:89
TweenRef(Tween< T > *tween)
Definition: Tween.h:146
Options & autoRemove(bool remove=true)
Definition: Tween.h:198
TweenRef(const std::shared_ptr< Tween< T > > &sp)
Definition: Tween.h:143
Tween(T *target, T endValue, float startTime, float duration, EaseFn easeFunction=easeNone, LerpFn lerpFunction=&tweenLerp< T >)
Definition: Tween.h:160
Options & loop(bool doLoop=true)
Definition: Tween.h:199
std::function< void(T)> mFn
Definition: Tween.h:280
FnTween(std::function< void(T)> fn, T startValue, T endValue, float startTime, float duration, EaseFn easeFunction=easeNone, typename Tween< T >::LerpFn lerpFunction=&tweenLerp< T >)
Definition: Tween.h:268
virtual void reset(bool unsetStarted)
Marks the item as not completed, and if unsetStarted, marks the item as not started.
Definition: Tween.h:117
void setEaseFn(EaseFn easeFunction)
change how the tween moves through time
Definition: Tween.h:86
~AnimBase()
Definition: Tween.cpp:66
void appendTo(TweenBase &tweenBase, void *target, float offset)
Definition: Tween.cpp:118
void stop()
removes self from Timeline
Definition: Tween.cpp:102
void setReplace(const AnimBase &rhs)
Definition: Tween.cpp:81
GLuint GLfloat * val
Definition: GLee.h:14636
FinishFn mFinishFunction
Definition: Tween.h:133
std::function< void()> FinishFn
Definition: Tween.h:79
Anim(const Anim< T > &rhs)
Definition: Tween.h:332
T mValue
Definition: Tween.h:376
void setReverseStartFn(StartFn reverseStartFunction)
Definition: Tween.h:92
bool isCopyStartValue()
Returns whether the tween will copy its target's value upon starting.
Definition: Tween.h:180
void timelineEnd(TweenBase &tweenBase, float offset)
Definition: Tween.cpp:123
Base interface for anything that can go on a Timeline.
Definition: TimelineItem.h:34
Anim< T > & operator=(Anim &&rhs)
Definition: Tween.h:355
TweenBase(void *target, bool copyStartValue, float startTime, float duration, EaseFn easeFunction=easeNone)
Definition: Tween.cpp:32
Options & startTime(float time)
Definition: Tween.h:197
T tweenLerp(const T &start, const T &end, float time)
Definition: Tween.h:49
Options & startFn(const TweenBase::StartFn &startFn)
Definition: Tween.h:190
GLintptr offset
Definition: GLee.h:2095
Options & easeFn(const EaseFn &easeFunc)
Definition: Tween.h:195
Options & delay(float delayAmt)
Definition: Tween.h:196
T & operator()()
Definition: Tween.h:337
Quaternion< T > normalized() const
Definition: Quaternion.h:137
Options & reverseFinishFn(const TweenBase::FinishFn &reverseFinishFn)
Definition: Tween.h:194
const T & operator()() const
Definition: Tween.h:336
StartFn mReverseStartFunction
Definition: Tween.h:131
Anim< T > & operator=(const Anim &rhs)
Definition: Tween.h:340
float easeNone(float t)
Easing equation for a simple linear tweening with no easing.
Definition: Easing.h:49
Anim()
Definition: Tween.h:326
bool isComplete() const
returns false if any tweens are active on 'this', otherwise true
Definition: Tween.cpp:89
Options & updateFn(const TweenBase::UpdateFn &updateFn)
Definition: Tween.h:192
Options & appendTo(Anim< Y > *endTarget, float offset=0)
Definition: Tween.h:204
GLsizei const GLfloat * value
Definition: GLee.h:2487
Options & infinite(bool doInfinite=true)
Definition: Tween.h:201
void setParentTimeline(TimelineRef parentTimeline)
Definition: Tween.cpp:109
GLuint GLuint end
Definition: GLee.h:963
AnimBase(void *voidPtr)
Definition: Tween.h:310
TimelineRef getParent() const
returns the parent timeline for the Anim<> or NULL if there is none
Definition: Tween.h:307
void * mTarget
Definition: TimelineItem.h:115
TweenRef< T > getThisRef()
Returns a TweenRef to this.
Definition: Tween.h:185
T getEndValue() const
Definition: Tween.h:176
T mValue
Definition: Tween.h:281
void set(const AnimBase &rhs)
Definition: Tween.cpp:72
Timeline & timeline()
Returns a reference to the active App's Timeline.
Definition: App.h:685
const T * ptr() const
Definition: Tween.h:369
virtual ~TweenBase()
Definition: Tween.h:83
Options(TimelineRef timeline)
Definition: Tween.h:106
std::function< void()> UpdateFn
Definition: Tween.h:80
std::shared_ptr< class TimelineItem > TimelineItemRef
Definition: TimelineItem.h:31
virtual TimelineItemRef cloneReverse() const
Creates a cloned item which runs in reverse relative to a timeline of duration timelineDuration.
Definition: Tween.h:234
TweenRef()
Definition: Tween.h:149
virtual void complete(bool reverse)
Definition: Tween.h:122
TweenRef< T > mTweenRef
Definition: Tween.h:215
StartFn getReverseStartFn() const
Definition: Tween.h:93
FinishFn getReverseFinishFn() const
Definition: Tween.h:102
std::function< float(float)> EaseFn
Definition: Tween.h:42
virtual void update(float relativeTime)
Definition: Tween.h:252
void setUpdateFn(UpdateFn updateFunction)
Definition: Tween.h:95
Tween(T *target, T startValue, T endValue, float startTime, float duration, EaseFn easeFunction=easeNone, LerpFn lerpFunction=&tweenLerp< T >)
Definition: Tween.h:166
void * mVoidPtr
Definition: Tween.h:319
Definition: Timeline.h:42
FnTweenRef()
Definition: Tween.h:293
Options & timelineEnd(float offset=0)
Definition: Tween.h:202
virtual ~Tween()
Definition: Tween.h:172
T mStartValue
Definition: Tween.h:260
TimelineRef mParentTimeline
Definition: Tween.h:320
UpdateFn getUpdateFn() const
Definition: Tween.h:96
virtual void reverse()
Definition: Tween.h:222
FinishFn getFinishFn() const
Definition: Tween.h:99
StartFn getStartFn() const
Definition: Tween.h:90
Anim(T value)
Definition: Tween.h:329
T * getTarget() const
Definition: Tween.h:177
LerpFn mLerpFunction
Definition: Tween.h:262