BCSTM-Player |
This commit is contained in:
172
external/tween-engine/include/TweenEngine/BaseTween.h
vendored
Normal file
172
external/tween-engine/include/TweenEngine/BaseTween.h
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
//
|
||||
// BaseTween.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* BaseTween is the base class of Tween and Timeline. It defines the
|
||||
* iteration engine used to play animations for any number of times, and in
|
||||
* any direction, at any speed.
|
||||
* <p/>
|
||||
*
|
||||
* It is responsible for calling the different callbacks at the right moments,
|
||||
* and for making sure that every callbacks are triggered, even if the update
|
||||
* engine gets a big delta time at once.
|
||||
*
|
||||
* @see Tween
|
||||
* @see Timeline
|
||||
* @author Aurelien Ribon | http://www.aurelienribon.com/
|
||||
*/
|
||||
|
||||
#ifndef __BaseTween__
|
||||
#define __BaseTween__
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <TweenEngine/TweenCallback.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class TweenManager;
|
||||
|
||||
typedef std::function<void(BaseTween* source)> TweenCallbackFunction;
|
||||
|
||||
class BaseTween
|
||||
{
|
||||
private:
|
||||
// General
|
||||
int step;
|
||||
int repeatCnt;
|
||||
bool isIterationStep;
|
||||
bool isYoyoFlag;
|
||||
|
||||
// Timings
|
||||
float repeatDelay;
|
||||
float currentTime;
|
||||
float deltaTime;
|
||||
bool isStartedFlag; // true when the object is started
|
||||
bool isInitializedFlag; // true after the delay
|
||||
bool isFinishedFlag; // true when all repetitions are done
|
||||
bool isKilledFlag; // true if kill() was called
|
||||
bool isPausedFlag; // true if pause() was called
|
||||
|
||||
// Misc
|
||||
TweenCallback *callback;
|
||||
int callbackTriggers;
|
||||
void *userData;
|
||||
std::map<int, TweenCallbackFunction> callbacks;
|
||||
|
||||
// Update
|
||||
void initialize();
|
||||
void testRelaunch();
|
||||
void updateStep();
|
||||
void testCompletion();
|
||||
|
||||
protected:
|
||||
// Timings
|
||||
float delayStart;
|
||||
float duration;
|
||||
|
||||
virtual void reset();
|
||||
virtual void forceStartValues() = 0;
|
||||
virtual void forceEndValues() = 0;
|
||||
virtual void initializeOverride();
|
||||
virtual void updateOverride(int step, int lastStep, bool isIterationStep, float delta);
|
||||
virtual void forceToStart();
|
||||
virtual void forceToEnd(float time);
|
||||
|
||||
void callCallback(int type);
|
||||
bool isReverse(int step);
|
||||
bool isValid(int step);
|
||||
|
||||
public:
|
||||
virtual ~BaseTween() {}
|
||||
|
||||
virtual int getTweenCount() = 0;
|
||||
virtual int getTimelineCount() = 0;
|
||||
|
||||
// Package access
|
||||
bool isAutoRemoveEnabled;
|
||||
bool isAutoStartEnabled;
|
||||
|
||||
virtual BaseTween &build();
|
||||
BaseTween &start();
|
||||
BaseTween &start(TweenManager &manager);
|
||||
BaseTween &delay(float delay);
|
||||
void kill();
|
||||
virtual void free();
|
||||
void pause();
|
||||
void resume();
|
||||
BaseTween &repeat(int count, float delay);
|
||||
BaseTween &repeatYoyo(int count, float delay);
|
||||
BaseTween &setCallback(TweenCallback *callback);
|
||||
BaseTween &setCallback(int type, const TweenCallbackFunction& callback);
|
||||
BaseTween &setCallbackTriggers(int flags);
|
||||
BaseTween &setUserData(void *data);
|
||||
|
||||
// Getters
|
||||
float getDelay();
|
||||
float getDuration();
|
||||
int getRepeatCount();
|
||||
float getRepeatDelay();
|
||||
float getFullDuration();
|
||||
void *getUserData();
|
||||
int getStep();
|
||||
float getCurrentTime();
|
||||
bool isStarted();
|
||||
bool isInitialized();
|
||||
bool isFinished();
|
||||
bool isYoyo();
|
||||
bool isPaused();
|
||||
|
||||
// Update
|
||||
void update(float delta);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* defined(__BaseTween__) */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
100
external/tween-engine/include/TweenEngine/Pool.h
vendored
Normal file
100
external/tween-engine/include/TweenEngine/Pool.h
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
//
|
||||
// Pool.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* A light pool of objects that can be resused to avoid allocation.
|
||||
* Based on Nathan Sweet pool implementation
|
||||
*/
|
||||
|
||||
#ifndef __Pool__
|
||||
#define __Pool__
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
class PoolCallback
|
||||
{
|
||||
public:
|
||||
virtual void onPool(T *obj) = 0;
|
||||
virtual void onUnPool(T *obj) = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class Pool
|
||||
{
|
||||
private:
|
||||
std::vector<T *> objects;
|
||||
PoolCallback<T> *callback;
|
||||
|
||||
protected:
|
||||
virtual ~Pool() {}
|
||||
virtual T *create()=0;
|
||||
|
||||
public:
|
||||
Pool(int initCapacity, PoolCallback<T> *callback);
|
||||
T *get();
|
||||
void free(T *obj);
|
||||
void clear();
|
||||
int size();
|
||||
void ensureCapacity(int minCapacity);
|
||||
|
||||
};
|
||||
|
||||
// Implementation
|
||||
template <typename T>
|
||||
Pool<T>::Pool(int initCapacity, PoolCallback<T> *cb) : objects(initCapacity), callback(cb)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *Pool<T>::get()
|
||||
{
|
||||
T *obj = nullptr;
|
||||
if (objects.empty())
|
||||
{
|
||||
obj = create();
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = objects.back();
|
||||
objects.pop_back();
|
||||
if (obj == nullptr) obj = create();
|
||||
}
|
||||
if (callback != nullptr) callback->onUnPool(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Pool<T>::free(T *obj)
|
||||
{
|
||||
if (obj == nullptr) return;
|
||||
|
||||
bool contains = (std::find(objects.begin(), objects.end(), obj) != objects.end());
|
||||
|
||||
if (!contains)
|
||||
{
|
||||
if (callback != nullptr) callback->onPool(obj);
|
||||
objects.push_back(obj);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Pool<T>::clear() { objects.clear(); }
|
||||
|
||||
template <typename T>
|
||||
int Pool<T>::size() { return objects.size(); }
|
||||
|
||||
template <typename T>
|
||||
void Pool<T>::ensureCapacity(int minCapacity) { objects.reserve(minCapacity); }
|
||||
|
||||
}
|
||||
|
||||
#endif /* defined(__Pool__) */
|
116
external/tween-engine/include/TweenEngine/Tween.h
vendored
Normal file
116
external/tween-engine/include/TweenEngine/Tween.h
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
//
|
||||
// Tween.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Tween__
|
||||
#define __Tween__
|
||||
|
||||
#include <TweenEngine/Tweenable.h>
|
||||
#include <TweenEngine/BaseTween.h>
|
||||
#include <TweenEngine/Pool.h>
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
#include <TweenEngine/TweenPath.h>
|
||||
#include <TweenEngine/TweenEquations.h>
|
||||
#include <TweenEngine/TweenPaths.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class TweenPool;
|
||||
class TweenPoolCallback;
|
||||
|
||||
class Tween : public BaseTween
|
||||
{
|
||||
friend class TweenPoolCallback;
|
||||
|
||||
private:
|
||||
static int combinedAttrsLimit;
|
||||
static int waypointsLimit;
|
||||
|
||||
// Main
|
||||
Tweenable *targetObj;
|
||||
int type;
|
||||
TweenEquation *equation;
|
||||
TweenPath *pathAlgorithm;
|
||||
|
||||
// General
|
||||
bool isFrom;
|
||||
bool isRelative;
|
||||
int combinedAttrsCnt;
|
||||
int waypointsCnt;
|
||||
|
||||
// Values
|
||||
float* startValues;
|
||||
float* targetValues;
|
||||
float* waypoints;
|
||||
|
||||
// Buffers
|
||||
float *accessorBuffer;
|
||||
int accessorBufferSize;
|
||||
float *pathBuffer;
|
||||
int pathBufferSize;
|
||||
|
||||
//static TweenPoolCallback *poolCallback;
|
||||
static TweenPool &pool;
|
||||
|
||||
void setup(Tweenable *target, int tweenType, float duration);
|
||||
|
||||
protected:
|
||||
virtual void reset();
|
||||
virtual void forceStartValues();
|
||||
virtual void forceEndValues();
|
||||
virtual void initializeOverride();
|
||||
virtual void updateOverride(int step, int lastStep, bool isIterationStep, float delta);
|
||||
|
||||
public:
|
||||
static const int ACCESSOR_READ = 0;
|
||||
static const int ACCESSOR_WRITE = 1;
|
||||
|
||||
static void setCombinedAttributesLimit(int limit);
|
||||
static void setWaypointsLimit(int limit);
|
||||
static const char *getVersion();
|
||||
|
||||
static int getPoolSize();
|
||||
static void ensurePoolCapacity(int minCapacity);
|
||||
|
||||
static Tween &to(Tweenable& target, int tweenType, float duration);
|
||||
static Tween &from(Tweenable& target, int tweenType, float duration);
|
||||
static Tween &set(Tweenable& target, int tweenType);
|
||||
static Tween &call(TweenCallback &callback);
|
||||
static Tween &mark();
|
||||
|
||||
Tween();
|
||||
~Tween();
|
||||
|
||||
virtual int getTweenCount();
|
||||
virtual int getTimelineCount();
|
||||
|
||||
virtual Tween &build();
|
||||
virtual void free();
|
||||
|
||||
Tween &ease(TweenEquation &easeEquation);
|
||||
Tween &target(float targetValue);
|
||||
Tween &target(float targetValue1, float targetValue2);
|
||||
Tween &target(float targetValue1, float targetValue2, float targetValue3);
|
||||
Tween &target(float *targetValues, int len);
|
||||
Tween &targetRelative(float targetValue);
|
||||
Tween &targetRelative(float targetValue1, float targetValue2);
|
||||
Tween &targetRelative(float targetValue1, float targetValue2, float targetValue3);
|
||||
Tween &targetRelative(float *targetValues, int len);
|
||||
Tween &waypoint(float targetValue);
|
||||
Tween &waypoint(float targetValue1, float targetValue2);
|
||||
Tween &waypoint(float targetValue1, float targetValue2, float targetValue3);
|
||||
Tween &waypoint(float *targetValues, int len);
|
||||
Tween &path(TweenPath &path);
|
||||
int getType();
|
||||
TweenEquation *getEasing();
|
||||
float *getTargetValues();
|
||||
int getCombinedAttributesCount();
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Tween__) */
|
103
external/tween-engine/include/TweenEngine/TweenAccessor.h
vendored
Normal file
103
external/tween-engine/include/TweenEngine/TweenAccessor.h
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
//
|
||||
// TweenAccessor.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* The TweenAccessor interface lets you interpolate any attribute from any
|
||||
* object. Just implement it as you want and register it to the engine by
|
||||
* calling {@link Tween#registerAccessor}.
|
||||
* <p/>
|
||||
*
|
||||
* <h2>Example</h2>
|
||||
*
|
||||
* The following code snippet presents an example of implementation for tweening
|
||||
* a Particle class. This Particle class is supposed to only define a position
|
||||
* with an "x" and an "y" fields, and their associated getters and setters.
|
||||
* <p/>
|
||||
*
|
||||
* <pre> {@code
|
||||
* public class ParticleAccessor implements TweenAccessor<Particle> {
|
||||
* public static final int X = 1;
|
||||
* public static final int Y = 2;
|
||||
* public static final int XY = 3;
|
||||
*
|
||||
* public int getValues(Particle target, int tweenType, float[] returnValues) {
|
||||
* switch (tweenType) {
|
||||
* case X: returnValues[0] = target.getX(); return 1;
|
||||
* case Y: returnValues[0] = target.getY(); return 1;
|
||||
* case XY:
|
||||
* returnValues[0] = target.getX();
|
||||
* returnValues[1] = target.getY();
|
||||
* return 2;
|
||||
* default: assert false; return 0;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* public void setValues(Particle target, int tweenType, float[] newValues) {
|
||||
* switch (tweenType) {
|
||||
* case X: target.setX(newValues[0]); break;
|
||||
* case Y: target.setY(newValues[1]); break;
|
||||
* case XY:
|
||||
* target.setX(newValues[0]);
|
||||
* target.setY(newValues[1]);
|
||||
* break;
|
||||
* default: assert false; break;
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* Once done, you only need to register this TweenAccessor once to be able to
|
||||
* use it for every Particle objects in your application:
|
||||
* <p/>
|
||||
*
|
||||
* <pre> {@code
|
||||
* Tween.registerAccessor(Particle.class, new ParticleAccessor());
|
||||
* }</pre>
|
||||
*
|
||||
* And that's all, the Tween Engine can no work with all your particles!
|
||||
*
|
||||
* @author Aurelien Ribon | http://www.aurelienribon.com/
|
||||
*/
|
||||
|
||||
#ifndef __TweenAccessor__
|
||||
#define __TweenAccessor__
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
template<class T>
|
||||
class TweenAccessor
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~TweenAccessor() {}
|
||||
|
||||
/**
|
||||
* Gets one or many values from the target object associated to the
|
||||
* given tween type. It is used by the Tween Engine to determine starting
|
||||
* values.
|
||||
*
|
||||
* @param target The target object of the tween.
|
||||
* @param tweenType An integer representing the tween type.
|
||||
* @param returnValues An array which should be modified by this method.
|
||||
* @return The count of modified slots from the returnValues array.
|
||||
*/
|
||||
virtual int getValues(T& target, int tweenType, float *returnValues) = 0;
|
||||
|
||||
/**
|
||||
* This method is called by the Tween Engine each time a running tween
|
||||
* associated with the current target object has been updated.
|
||||
*
|
||||
* @param target The target object of the tween.
|
||||
* @param tweenType An integer representing the tween type.
|
||||
* @param newValues The new values determined by the Tween Engine.
|
||||
*/
|
||||
virtual void setValues(T& target, int tweenType, float *newValues) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* defined(__TweenAccessor__) */
|
65
external/tween-engine/include/TweenEngine/TweenCallback.h
vendored
Normal file
65
external/tween-engine/include/TweenEngine/TweenCallback.h
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
//
|
||||
// TweenCallback.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* TweenCallbacks are used to trigger actions at some specific times. They are
|
||||
* used in both Tweens and Timelines. The moment when the callback is
|
||||
* triggered depends on its registered triggers:
|
||||
* <p/>
|
||||
*
|
||||
* <b>BEGIN</b>: right after the delay (if any)<br/>
|
||||
* <b>START</b>: at each iteration beginning<br/>
|
||||
* <b>END</b>: at each iteration ending, before the repeat delay<br/>
|
||||
* <b>COMPLETE</b>: at last END event<br/>
|
||||
* <b>BACK_BEGIN</b>: at the beginning of the first backward iteration<br/>
|
||||
* <b>BACK_START</b>: at each backward iteration beginning, after the repeat delay<br/>
|
||||
* <b>BACK_END</b>: at each backward iteration ending<br/>
|
||||
* <b>BACK_COMPLETE</b>: at last BACK_END event
|
||||
* <p/>
|
||||
*
|
||||
* <pre> {@code
|
||||
* forward : BEGIN COMPLETE
|
||||
* forward : START END START END START END
|
||||
* |--------------[XXXXXXXXXX]------[XXXXXXXXXX]------[XXXXXXXXXX]
|
||||
* backward: bEND bSTART bEND bSTART bEND bSTART
|
||||
* backward: bCOMPLETE bBEGIN
|
||||
* }</pre>
|
||||
*
|
||||
* @see Tween
|
||||
* @see Timeline
|
||||
* @author Aurelien Ribon | http://www.aurelienribon.com/
|
||||
*/
|
||||
|
||||
#ifndef __TweenCallback__
|
||||
#define __TweenCallback__
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class BaseTween;
|
||||
|
||||
class TweenCallback
|
||||
{
|
||||
|
||||
public:
|
||||
static const int BEGIN = 0x01;
|
||||
static const int START = 0x02;
|
||||
static const int END = 0x04;
|
||||
static const int COMPLETE = 0x08;
|
||||
static const int BACK_BEGIN = 0x10;
|
||||
static const int BACK_START = 0x20;
|
||||
static const int BACK_END = 0x40;
|
||||
static const int BACK_COMPLETE = 0x80;
|
||||
static const int ANY_FORWARD = 0x0F;
|
||||
static const int ANY_BACKWARD = 0xF0;
|
||||
static const int ANY = 0xFF;
|
||||
|
||||
virtual ~TweenCallback() {}
|
||||
virtual void onEvent(int type, BaseTween *source) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
#endif /* defined(__TweenCallback__) */
|
46
external/tween-engine/include/TweenEngine/TweenEquation.h
vendored
Normal file
46
external/tween-engine/include/TweenEngine/TweenEquation.h
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
//
|
||||
// TweenEquation.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* Base class for every easing equation. You can create your own equations
|
||||
* and directly use them in the Tween engine by inheriting from this class.
|
||||
*
|
||||
* @see Tween
|
||||
* @author Aurelien Ribon | http://www.aurelienribon.com/
|
||||
*/
|
||||
|
||||
#ifndef __TweenEquation__
|
||||
#define __TweenEquation__
|
||||
|
||||
//#include <string.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class TweenEquation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Computes the next value of the interpolation.
|
||||
*
|
||||
* @param t The current time, between 0 and 1.
|
||||
* @return The current value.
|
||||
*/
|
||||
virtual float compute(float t) = 0;
|
||||
|
||||
virtual const char *toString() = 0;
|
||||
|
||||
/**
|
||||
* Returns true if the given string is the name of this equation (the name
|
||||
* is returned in the toString() method, don't forget to override it).
|
||||
* This method is usually used to save/load a tween to/from a text file.
|
||||
*/
|
||||
//bool isValueOf(const char *str) { return !strcmp(str, toString()); };
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__TweenEquation__) */
|
63
external/tween-engine/include/TweenEngine/TweenEquations.h
vendored
Normal file
63
external/tween-engine/include/TweenEngine/TweenEquations.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// TweenEquations.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __TweenEquations__
|
||||
#define __TweenEquations__
|
||||
|
||||
#include <TweenEngine/equations/Quad.h>
|
||||
#include <TweenEngine/equations/Linear.h>
|
||||
#include <TweenEngine/equations/Back.h>
|
||||
#include <TweenEngine/equations/Bounce.h>
|
||||
#include <TweenEngine/equations/Circ.h>
|
||||
#include <TweenEngine/equations/Cubic.h>
|
||||
#include <TweenEngine/equations/Elastic.h>
|
||||
#include <TweenEngine/equations/Expo.h>
|
||||
#include <TweenEngine/equations/Quart.h>
|
||||
#include <TweenEngine/equations/Quint.h>
|
||||
#include <TweenEngine/equations/Sine.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class TweenEquations
|
||||
{
|
||||
public:
|
||||
static TweenEquation &easeInQuad;
|
||||
static TweenEquation &easeOutQuad;
|
||||
static TweenEquation &easeInOutQuad;
|
||||
static TweenEquation &easeInOutLinear;
|
||||
static TweenEquation &easeInBack;
|
||||
static TweenEquation &easeOutBack;
|
||||
static TweenEquation &easeInOutBack;
|
||||
static TweenEquation &easeInBounce;
|
||||
static TweenEquation &easeOutBounce;
|
||||
static TweenEquation &easeInOutBounce;
|
||||
static TweenEquation &easeInCirc;
|
||||
static TweenEquation &easeOutCirc;
|
||||
static TweenEquation &easeInOutCirc;
|
||||
static TweenEquation &easeInCubic;
|
||||
static TweenEquation &easeOutCubic;
|
||||
static TweenEquation &easeInOutCubic;
|
||||
static TweenEquation &easeInElastic;
|
||||
static TweenEquation &easeOutElastic;
|
||||
static TweenEquation &easeInOutElastic;
|
||||
static TweenEquation &easeInExpo;
|
||||
static TweenEquation &easeOutExpo;
|
||||
static TweenEquation &easeInOutExpo;
|
||||
static TweenEquation &easeInQuart;
|
||||
static TweenEquation &easeOutQuart;
|
||||
static TweenEquation &easeInOutQuart;
|
||||
static TweenEquation &easeInQuint;
|
||||
static TweenEquation &easeOutQuint;
|
||||
static TweenEquation &easeInOutQuint;
|
||||
static TweenEquation &easeInSine;
|
||||
static TweenEquation &easeOutSine;
|
||||
static TweenEquation &easeInOutSine;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* defined(__TweenEquations__) */
|
61
external/tween-engine/include/TweenEngine/TweenManager.h
vendored
Normal file
61
external/tween-engine/include/TweenEngine/TweenManager.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// TweenManager.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* A TweenManager updates all your tweens and timelines at once.
|
||||
* Its main interest is that it handles the tween/timeline life-cycles for you,
|
||||
* as well as the pooling constraints (if object pooling is enabled).
|
||||
* <p/>
|
||||
*
|
||||
* Just give it a bunch of tweens or timelines and call update() periodically,
|
||||
* you don't need to care for anything else! Relax and enjoy your animations.
|
||||
*
|
||||
* @see Tween
|
||||
* @see Timeline
|
||||
* @author Aurelien Ribon | http://www.aurelienribon.com/
|
||||
*/
|
||||
|
||||
#ifndef __TweenManager__
|
||||
#define __TweenManager__
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include <TweenEngine/BaseTween.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class TweenManager
|
||||
{
|
||||
private:
|
||||
std::vector<BaseTween *>objects;
|
||||
|
||||
bool isPaused = false;
|
||||
|
||||
public:
|
||||
TweenManager();
|
||||
|
||||
static void setAutoRemove(BaseTween &object, bool value);
|
||||
static void setAutoStart(BaseTween &object, bool value);
|
||||
|
||||
TweenManager &add(BaseTween &object);
|
||||
void killAll();
|
||||
void ensureCapacity(int minCapacity);
|
||||
void pause();
|
||||
void resume();
|
||||
void update(float delta);
|
||||
int size();
|
||||
|
||||
// Debug Helpers
|
||||
int getRunningTweensCount();
|
||||
int getRunningTimelinesCount();
|
||||
std::vector<BaseTween *> &getObjects();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* defined(__TweenManager__) */
|
37
external/tween-engine/include/TweenEngine/TweenPath.h
vendored
Normal file
37
external/tween-engine/include/TweenEngine/TweenPath.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// TweenPath.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* Base class for every paths. You can create your own paths and directly use
|
||||
* them in the Tween engine by inheriting from this class.
|
||||
*
|
||||
* @author Aurelien Ribon | http://www.aurelienribon.com/
|
||||
*/
|
||||
|
||||
#ifndef __TweenPath__
|
||||
#define __TweenPath__
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class TweenPath
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Computes the next value of the interpolation, based on its waypoints and
|
||||
* the current progress.
|
||||
*
|
||||
* @param t The progress of the interpolation, between 0 and 1. May be out
|
||||
* of these bounds if the easing equation involves some kind of rebounds.
|
||||
* @param points The waypoints of the tween, from start to target values.
|
||||
* @param pointsCnt The number of valid points in the array.
|
||||
* @return The next value of the interpolation.
|
||||
*/
|
||||
virtual float compute(float t, float *points, int pointsCnt) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__TweenPath__) */
|
23
external/tween-engine/include/TweenEngine/TweenPaths.h
vendored
Normal file
23
external/tween-engine/include/TweenEngine/TweenPaths.h
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// TweenPaths.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __TweenPaths__
|
||||
#define __TweenPaths__
|
||||
|
||||
#include <TweenEngine/TweenPath.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class TweenPaths
|
||||
{
|
||||
public:
|
||||
static TweenPath &linear;
|
||||
static TweenPath &catmullRom;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__TweenPaths__) */
|
32
external/tween-engine/include/TweenEngine/TweenPool.h
vendored
Normal file
32
external/tween-engine/include/TweenEngine/TweenPool.h
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// TweenPool.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __TweenPool__
|
||||
#define __TweenPool__
|
||||
|
||||
#include <TweenEngine/Pool.h>
|
||||
#include <TweenEngine/Tween.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class TweenPoolCallback : public PoolCallback<Tween>
|
||||
{
|
||||
public:
|
||||
void onPool(Tween *obj);
|
||||
void onUnPool(Tween *obj);
|
||||
};
|
||||
|
||||
class TweenPool : public Pool<Tween>
|
||||
{
|
||||
protected:
|
||||
Tween *create();
|
||||
public:
|
||||
TweenPool();
|
||||
|
||||
};
|
||||
}
|
||||
#endif /* defined(__TweenPool__) */
|
12
external/tween-engine/include/TweenEngine/Tweenable.h
vendored
Normal file
12
external/tween-engine/include/TweenEngine/Tweenable.h
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef __Tweenable__
|
||||
#define __Tweenable__
|
||||
|
||||
namespace TweenEngine {
|
||||
class Tweenable {
|
||||
public:
|
||||
virtual int getValues(int tweenType, float *returnValues) = 0;
|
||||
virtual void setValues(int tweenType, float *newValues) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
37
external/tween-engine/include/TweenEngine/equations/Back.h
vendored
Normal file
37
external/tween-engine/include/TweenEngine/equations/Back.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Back.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Back__
|
||||
#define __Back__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class BackIn : public TweenEquation
|
||||
{
|
||||
~BackIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class BackOut : public TweenEquation
|
||||
{
|
||||
~BackOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class BackInOut : public TweenEquation
|
||||
{
|
||||
~BackInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Back__) */
|
38
external/tween-engine/include/TweenEngine/equations/Bounce.h
vendored
Normal file
38
external/tween-engine/include/TweenEngine/equations/Bounce.h
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
//
|
||||
// Bounce.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Bounce__
|
||||
#define __Bounce__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class BounceIn : public TweenEquation
|
||||
{
|
||||
~BounceIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class BounceOut : public TweenEquation
|
||||
{
|
||||
~BounceOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class BounceInOut : public TweenEquation
|
||||
{
|
||||
~BounceInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* defined(__Bounce__) */
|
37
external/tween-engine/include/TweenEngine/equations/Circ.h
vendored
Normal file
37
external/tween-engine/include/TweenEngine/equations/Circ.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Circ.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Circ__
|
||||
#define __Circ__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class CircIn : public TweenEquation
|
||||
{
|
||||
~CircIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class CircOut : public TweenEquation
|
||||
{
|
||||
~CircOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class CircInOut : public TweenEquation
|
||||
{
|
||||
~CircInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Circ__) */
|
37
external/tween-engine/include/TweenEngine/equations/Cubic.h
vendored
Normal file
37
external/tween-engine/include/TweenEngine/equations/Cubic.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Cubic.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Cubic__
|
||||
#define __Cubic__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class CubicIn : public TweenEquation
|
||||
{
|
||||
~CubicIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class CubicOut : public TweenEquation
|
||||
{
|
||||
~CubicOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class CubicInOut : public TweenEquation
|
||||
{
|
||||
~CubicInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Cubic__) */
|
61
external/tween-engine/include/TweenEngine/equations/Elastic.h
vendored
Normal file
61
external/tween-engine/include/TweenEngine/equations/Elastic.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// Elastic.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Elastic__
|
||||
#define __Elastic__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class ElasticIn : public TweenEquation
|
||||
{
|
||||
private:
|
||||
float amplitude;
|
||||
float period;
|
||||
bool isAmplitudeSet;
|
||||
bool isPeriodSet;
|
||||
public:
|
||||
~ElasticIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
void setAmplitude(float a);
|
||||
void setPeriod(float p);
|
||||
};
|
||||
|
||||
class ElasticOut : public TweenEquation
|
||||
{
|
||||
private:
|
||||
float amplitude;
|
||||
float period;
|
||||
bool isAmplitudeSet;
|
||||
bool isPeriodSet;
|
||||
public:
|
||||
~ElasticOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
void setAmplitude(float a);
|
||||
void setPeriod(float p);
|
||||
};
|
||||
|
||||
class ElasticInOut : public TweenEquation
|
||||
{
|
||||
private:
|
||||
float amplitude;
|
||||
float period;
|
||||
bool isAmplitudeSet;
|
||||
bool isPeriodSet;
|
||||
public:
|
||||
~ElasticInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
void setAmplitude(float a);
|
||||
void setPeriod(float p);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Elastic__) */
|
37
external/tween-engine/include/TweenEngine/equations/Expo.h
vendored
Normal file
37
external/tween-engine/include/TweenEngine/equations/Expo.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Expo.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Expo__
|
||||
#define __Expo__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class ExpoIn : public TweenEquation
|
||||
{
|
||||
~ExpoIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class ExpoOut : public TweenEquation
|
||||
{
|
||||
~ExpoOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class ExpoInOut : public TweenEquation
|
||||
{
|
||||
~ExpoInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Expo__) */
|
24
external/tween-engine/include/TweenEngine/equations/Linear.h
vendored
Normal file
24
external/tween-engine/include/TweenEngine/equations/Linear.h
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
//
|
||||
// Linear.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Linear__
|
||||
#define __Linear__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class LinearInOut : public TweenEquation
|
||||
{
|
||||
~LinearInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* defined(__Linear__) */
|
37
external/tween-engine/include/TweenEngine/equations/Quad.h
vendored
Normal file
37
external/tween-engine/include/TweenEngine/equations/Quad.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Quad.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Quad__
|
||||
#define __Quad__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class QuadIn : public TweenEquation
|
||||
{
|
||||
~QuadIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class QuadOut : public TweenEquation
|
||||
{
|
||||
~QuadOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class QuadInOut : public TweenEquation
|
||||
{
|
||||
~QuadInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Quad__) */
|
37
external/tween-engine/include/TweenEngine/equations/Quart.h
vendored
Normal file
37
external/tween-engine/include/TweenEngine/equations/Quart.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Quart.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Quart__
|
||||
#define __Quart__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class QuartIn : public TweenEquation
|
||||
{
|
||||
~QuartIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class QuartOut : public TweenEquation
|
||||
{
|
||||
~QuartOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class QuartInOut : public TweenEquation
|
||||
{
|
||||
~QuartInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Quart__) */
|
37
external/tween-engine/include/TweenEngine/equations/Quint.h
vendored
Normal file
37
external/tween-engine/include/TweenEngine/equations/Quint.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Quint.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Quint__
|
||||
#define __Quint__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class QuintIn : public TweenEquation
|
||||
{
|
||||
~QuintIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class QuintOut : public TweenEquation
|
||||
{
|
||||
~QuintOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class QuintInOut : public TweenEquation
|
||||
{
|
||||
~QuintInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Quint__) */
|
37
external/tween-engine/include/TweenEngine/equations/Sine.h
vendored
Normal file
37
external/tween-engine/include/TweenEngine/equations/Sine.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Sine.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __Sine__
|
||||
#define __Sine__
|
||||
|
||||
#include <TweenEngine/TweenEquation.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class SineIn : public TweenEquation
|
||||
{
|
||||
~SineIn();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class SineOut : public TweenEquation
|
||||
{
|
||||
~SineOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
|
||||
class SineInOut : public TweenEquation
|
||||
{
|
||||
~SineInOut();
|
||||
float compute(float t);
|
||||
const char *toString();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__Sine__) */
|
22
external/tween-engine/include/TweenEngine/paths/CatmullRom.h
vendored
Normal file
22
external/tween-engine/include/TweenEngine/paths/CatmullRom.h
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// CatmullRom.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __CatmullRom__
|
||||
#define __CatmullRom__
|
||||
|
||||
#include <TweenEngine/TweenPath.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class CatmullRom : public TweenPath
|
||||
{
|
||||
float compute(float t, float *points, int pointsCnt);
|
||||
float catmullRomSpline(float a, float b, float c, float d, float t);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__CatmullRom__) */
|
21
external/tween-engine/include/TweenEngine/paths/LinearPath.h
vendored
Normal file
21
external/tween-engine/include/TweenEngine/paths/LinearPath.h
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// Linear.h
|
||||
//
|
||||
// This code is derived from Universal Tween Engine
|
||||
// Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
|
||||
#ifndef __LinearPath__
|
||||
#define __LinearPath__
|
||||
|
||||
#include <TweenEngine/TweenPath.h>
|
||||
|
||||
namespace TweenEngine
|
||||
{
|
||||
class LinearPath : public TweenPath
|
||||
{
|
||||
float compute(float t, float *points, int pointsCnt);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__LinearPath__) */
|
Reference in New Issue
Block a user