1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <iostream>
#include <sys/time.h>
#include "ofMain.h"
class TAInterpoledValue {
enum it_type { t_int, t_float };
int v_type;
float *v_f;
int *v_i;
unsigned long long start_time;
float startValue;
float endValue;
int duration;
int animationType;
public:
enum animation_types {linear, quad_in, quad_out};
TAInterpoledValue(float *value);
TAInterpoledValue(int *value);
void setToValue(float v);
void setToEndValue();
float getValue();
float time_linear(float time);
float time_quadraticIn(float time);
float time_quadraticOut(float time);
void setup(int duration, float final, int atype);
void setup(int duration, float start, float final, int atype);
bool update();
};
class TAInterpolator
{
vector <TAInterpoledValue> inter_values;
public:
template <typename T2>
void interpolate(T2 *value, int duration, float final, int atype = 0) {
TAInterpoledValue v(value);
v.setup(duration, final, atype);
inter_values.push_back(v);
}
template <typename T2>
void interpolate(T2 *value, int duration, float start, float final, int atype = 0) {
TAInterpoledValue v(value);
v.setup(duration, start, final, atype);
inter_values.push_back(v);
}
void update() {
for (int i = 0; i < inter_values.size(); i++) {
if (inter_values[i].update()) {
inter_values.erase(inter_values.begin() + i);
}
}
}
}; |
Partager