-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAnimation.h
79 lines (63 loc) · 1.44 KB
/
Animation.h
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
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef _ANIMATION_H_
#define _ANIMATION_H_
#include "Joint.h"
#include "common.h"
#include <vector>
#include <memory>
#include <unordered_map>
/**
* [Caution]
* - Channels stores rotation as degree
*
**/
struct Channel
{
enum class Channel_Type
{
X_TRANSLATION,
Y_TRANSLATION,
Z_TRANSLATION,
X_ROTATION,
Y_ROTATION,
Z_ROTATION
}type;
float value;
};
struct FrameData
{
bool movable;
glm::vec3 translation = glm::vec3(0);
glm::quat quaternion = glm::quat();
};
struct Frame
{
uint32_t frame_id;
std::unordered_map<std::shared_ptr<Joint>, std::vector<Channel>> joint_channel_map;
std::unordered_map<std::shared_ptr<Joint>, FrameData> joint_framedata_map;
};
// getCurrentFrameData() specific frame -> step() to next frame
// getCurrentFrameTime(); --> for synchronization
//
class Animation
{
public:
Animation();
~Animation();
void Pause();
void Step();
void setFrames(std::vector<Frame>& frames);
void setCurrentFrame(size_t frame_count);
inline const std::vector<Frame>& getFrames() { return m_frames; };
inline const Frame& getCurrentFrame() { return m_frames[m_current_frame]; };
inline const size_t getCurrentFrameTime() { return m_current_frame; };
inline const size_t getKeyFrameSize() { return m_frames.size(); };
float m_frame_time;
uint32_t m_frame_count;
private:
// Sub-function of setFrames()
void PrecomputeFrameData();
std::vector<Frame> m_frames;
size_t m_current_frame;
bool m_pause;
};
#endif