forked from abcdls0905/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi_ui3d_animation.h
137 lines (120 loc) · 2.6 KB
/
i_ui3d_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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#pragma once
#include "i_ui3d_mesh.h"
class IUI3DActionBase
{
public:
virtual void OnFrameStart() = 0;
virtual void OnFrame(float per) = 0;
virtual void OnFrameEnd() = 0;
};
class RotateAction : public IUI3DActionBase
{
FmVec3 m_target;
FmVec3 m_value;
FmVec3 m_start;
IUIVisNode* m_visobj;
bool m_relative;
public:
RotateAction(IUIVisNode* pVisNode, const FmVec3& target, bool relative = true )
{
m_relative = relative;
m_visobj = pVisNode;
m_value = target;
}
private:
void OnFrameStart()
{
m_start = m_visobj->GetAngle();
if(m_relative)
m_target = m_value + m_start;
else
m_target = m_value;
}
void OnFrame(float per)
{
FmVec3 target = m_start + (m_target - m_start) * per;
m_visobj->SetAngle(target.x, target.y, target.z);
}
void OnFrameEnd()
{
m_visobj->SetAngle(m_target.x, m_target.y, m_target.z);
}
};
class ScaleAction : public IUI3DActionBase
{
FmVec3 m_target;
FmVec3 m_value;
FmVec3 m_start;
bool m_relative;
IUIVisNode* m_pVisNode;
public:
ScaleAction(IUIVisNode* pVisNode, const FmVec3& target, bool relative = true )
{
m_pVisNode = pVisNode;
m_relative = relative;
m_value = target;
}
private:
void OnFrameStart()
{
m_start = m_pVisNode->GetScale();
if(m_relative)
m_target = m_value + m_start;
else
m_target = m_value;
}
void OnFrame(float per)
{
FmVec3 target = m_start + (m_target - m_start) * per;
m_pVisNode->SetScale(target.x, target.y, target.z);
}
void OnFrameEnd()
{
m_pVisNode->SetScale(m_target.x, m_target.y, m_target.z);
}
};
class PositionAction : public IUI3DActionBase
{
FmVec3 m_target;
FmVec3 m_value;
FmVec3 m_start;
PERSISTID m_pid;
bool m_relative;
IUIVisNode* m_pVisNode;
public:
PositionAction(IUIVisNode* pVisNode, const FmVec3& target, bool relative = true)
{
m_pVisNode = pVisNode;
m_relative = relative;
m_pVisNode = pVisNode;
m_value = target;
}
private:
void OnFrameStart()
{
m_start = this->m_pVisNode->GetPosition();
if(m_relative)
m_target = m_value + m_start;
else
m_target = m_value;
}
void OnFrame(float per)
{
FmVec3 target = m_start + (m_target - m_start) * per;
m_pVisNode->SetPosition(target.x, target.y, target.z);
}
void OnFrameEnd()
{
m_pVisNode->SetPosition(m_target.x, m_target.y, m_target.z);
}
};
class IUI3DAnimation
{
public:
virtual ~IUI3DAnimation(){}
virtual void Create(int maxframe = 30, float speed = 1) = 0;
virtual void CreateFrameGroup(const char* name) = 0;
virtual void AddAction(IUI3DActionBase* pAction, int frame_num, int frame_skip = 0, const char* framegroup = 0) = 0;
virtual void Play() = 0;
virtual void Update(float time) = 0;
};