Files
BlitzNext/Runtime/blitz3d/animator.hpp
T

88 lines
1.4 KiB
C++
Raw Normal View History

2014-01-31 08:23:00 +13:00
#ifndef ANIMATOR_H
#define ANIMATOR_H
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 17:04:17 +01:00
Animator(const 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 17:04:17 +01:00
int animSeq() const
{
return _seq;
}
int animLen() const
{
return _seq_len;
}
float animTime() const
{
return _time;
}
bool animating() const
{
return !!_mode;
}
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
int numSeqs() const
{
return _seqs.size();
}
const vector<Object*>& getObjects() const
{
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
vector<Animation> keys;
//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
};
vector<Seq> _seqs;
2019-01-18 17:04:17 +01:00
vector<Anim> _anims;
2014-01-31 08:23:00 +13:00
vector<Object*> _objs;
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();
};
#endif