2019-01-18 21:26:42 +01:00
|
|
|
#pragma once
|
|
|
|
|
#include <vector>
|
2019-01-18 15:55:06 +01:00
|
|
|
#include "animation.hpp"
|
2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
class Object;
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
class Animator {
|
|
|
|
|
public:
|
|
|
|
|
enum { ANIM_MODE_LOOP = 1, ANIM_MODE_PINGPONG = 2, ANIM_MODE_ONESHOT = 3 };
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
Animator(Animator* animator);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
Animator(Object* tree, int frames);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 21:26:42 +01:00
|
|
|
Animator(const std::vector<Object*>& objs, int frames);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
void addSeq(int frames);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
void addSeqs(Animator* t);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
void extractSeq(int first, int last, int seq);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
void setAnimTime(float time, int seq);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
void animate(int mode, float speed, int seq, float trans);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
void update(float elapsed);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 21:26:42 +01:00
|
|
|
inline int animSeq() const
|
2019-01-18 17:04:17 +01:00
|
|
|
{
|
|
|
|
|
return _seq;
|
|
|
|
|
}
|
2019-01-18 21:26:42 +01:00
|
|
|
inline int animLen() const
|
2019-01-18 17:04:17 +01:00
|
|
|
{
|
|
|
|
|
return _seq_len;
|
|
|
|
|
}
|
2019-01-18 21:26:42 +01:00
|
|
|
inline float animTime() const
|
2019-01-18 17:04:17 +01:00
|
|
|
{
|
|
|
|
|
return _time;
|
|
|
|
|
}
|
2019-01-18 21:26:42 +01:00
|
|
|
inline bool animating() const
|
2019-01-18 17:04:17 +01:00
|
|
|
{
|
|
|
|
|
return !!_mode;
|
|
|
|
|
}
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 21:26:42 +01:00
|
|
|
inline int numSeqs() const
|
2019-01-18 17:04:17 +01:00
|
|
|
{
|
|
|
|
|
return _seqs.size();
|
|
|
|
|
}
|
2019-01-18 21:26:42 +01:00
|
|
|
inline const std::vector<Object*>& getObjects() const
|
2019-01-18 17:04:17 +01:00
|
|
|
{
|
|
|
|
|
return _objs;
|
|
|
|
|
}
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
private:
|
|
|
|
|
struct Seq {
|
2014-01-31 08:23:00 +13:00
|
|
|
int frames;
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
struct Anim {
|
2014-01-31 08:23:00 +13:00
|
|
|
//anim keys
|
2019-01-18 21:26:42 +01:00
|
|
|
std::vector<Animation> keys;
|
2014-01-31 08:23:00 +13:00
|
|
|
//for transitions...
|
2019-01-18 17:04:17 +01:00
|
|
|
bool pos, scl, rot;
|
|
|
|
|
Vector src_pos, dest_pos;
|
|
|
|
|
Vector src_scl, dest_scl;
|
|
|
|
|
Quat src_rot, dest_rot;
|
|
|
|
|
Anim() : pos(false), scl(false), rot(false) {}
|
2014-01-31 08:23:00 +13:00
|
|
|
};
|
|
|
|
|
|
2019-01-18 21:26:42 +01:00
|
|
|
std::vector<Seq> _seqs;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 21:26:42 +01:00
|
|
|
std::vector<Anim> _anims;
|
|
|
|
|
std::vector<Object*> _objs;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
int _seq, _mode, _seq_len;
|
|
|
|
|
float _time, _speed, _trans_time, _trans_speed;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
void reset();
|
2019-01-18 17:04:17 +01:00
|
|
|
void addObjs(Object* obj);
|
2014-01-31 08:23:00 +13:00
|
|
|
void updateAnim();
|
|
|
|
|
void beginTrans();
|
|
|
|
|
void updateTrans();
|
|
|
|
|
};
|