/
ltanimtracker.h
229 lines (165 loc) · 4.13 KB
/
ltanimtracker.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#ifndef __LTANIMTRACKER_H__
#define __LTANIMTRACKER_H__
#ifndef __LTBASEDEFS_H__
#include "ltbasedefs.h"
#endif
class LTAnimTracker;
class AnimTimeRef;
class AnimKeyFrame;
class Model;
class ModelAnim;
class AnimInfo;
class ModelInstance;
typedef void (*StringKeyCallback)(LTAnimTracker *pTracker,
AnimKeyFrame *pFrame);
/*!
All the info on where we are in the animation.
*/
class FrameLocator
{
public:
void Clear()
{
m_iAnim = 0;
m_iFrame = 0;
m_Time = 0;
}
uint16 m_iAnim;
uint16 m_iFrame;
uint32 m_Time; //! Milliseconds
};
/*!
References a specific time in an animation.
*/
class AnimTimeRef
{
public:
AnimTimeRef() {
m_iWeightSet = INVALID_MODEL_WEIGHTSET;
Clear();
}
void Init(Model *pModel,
uint32 iAnim1=0, uint32 iFrame1=0,
uint32 iAnim2=0, uint32 iFrame2=0,
float percent=0.0f)
{
m_pModel = pModel;
m_Prev.m_iAnim = (uint16)iAnim1;
m_Prev.m_iFrame = (uint16)iFrame1;
m_Prev.m_Time = 0;
m_Cur.m_iAnim = (uint16)iAnim2;
m_Cur.m_iFrame = (uint16)iFrame2;
m_Cur.m_Time = 0;
m_Percent = percent;
}
void Clear() {
Init(LTNULL, 0, 0, 0, 0, 0.0f);
}
bool IsValid();
ModelAnim *GetAnim1();
ModelAnim *GetAnim2();
public:
/*!
Set it between the specified keyframes on the specified animation.
*/
bool SetKeyframePosition(uint32 iAnim, uint32 iFrame1,
uint32 iFrame2, float fPercent);
Model *m_pModel;
/*!
This tells exactly where we want the vertices set up.
*/
FrameLocator m_Prev;
FrameLocator m_Cur;
/*!
Percentage between the two frames. Must be between 0 and 1.
*/
float m_Percent;
/*! If multiple \b LTAnimTracker objects are being used together,
this tells how to blend each one. This is ignored for the first weight
set. */
uint32 m_iWeightSet;
};
/*!
Animation tracker for model instances.
\note
Game code should \em never touch the internals of this structure or
call any of its functions. It should use the \b ILTModel functions to
access these.
*/
class LTAnimTracker {
public:
LTAnimTracker()
{
/*!
Movement encoding hint.
*/
m_hHintNode = INVALID_MODEL_NODE;
m_hLastHintAnim = INVALID_MODEL_ANIM;
m_dwLastHintTime = 0;
m_tfLastHint.m_Pos.Init();
m_tfLastHint.m_Rot.Init();
m_bDirty = true;
}
/*!
Tells if the frame locators are on valid frames.
*/
bool IsValid();
ModelAnim* GetCurAnim();
ModelAnim* GetPrevAnim();
AnimInfo* GetCurAnimInfo();
AnimInfo* GetPrevAnimInfo();
AnimKeyFrame* GetCurFrame();
AnimKeyFrame* GetPrevFrame();
bool AllowInvalid();
/*!
Get/set its linked list info.
*/
LTAnimTracker * GetNext() {return (LTAnimTracker*)m_Link.m_pNext;}
void SetNext(LTAnimTracker *pNext) {m_Link.m_pNext = (LTLink*)pNext;}
ModelInstance* GetModelInstance() {return (ModelInstance*)m_Link.m_pData;}
void SetModelInstance(ModelInstance *pInst) {m_Link.m_pData = pInst;}
Model* GetModel() {return m_TimeRef.m_pModel;}
void SetModel(Model *pModel) {m_TimeRef.m_pModel = pModel;}
public:
LTLink m_Link;
/*!
Set this if you want to be notified of string keys.
*/
StringKeyCallback m_StringKeyCallback;
/*!
Stuff used to track where it is in the keyframes.
*/
uint32 m_CurKey;
/*!
Combination of \b AT_ flags above.
*/
uint16 m_Flags;
/*!
How far we have ve interpolated between \b prev and \b cur
(when switching animations). Set to \b NOT_INTERPOLATING
if not interpolating.
*/
uint16 m_InterpolationMS;
/*!
Factor with which to change the animation rate, default = 1.0.
*/
float m_RateModifier ;
AnimTimeRef m_TimeRef;
/*!
Reference / identifier for engine-managed tracker
*/
ANIMTRACKERID m_ID;
/*!
Movement encoding hint.
*/
HMODELNODE m_hHintNode;
HMODELANIM m_hLastHintAnim;
uint32 m_dwLastHintTime;
LTransform m_tfLastHint;
/*!
Tracker dirty?
*/
//NEW
bool m_bDirty;
};
#endif //! __LTANIMTRACKER_H__