2019-06-11 06:59:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-07-08 19:44:32 +00:00
|
|
|
#include "Quaternion.h"
|
2019-06-11 06:59:28 +00:00
|
|
|
|
2020-12-01 16:42:18 +00:00
|
|
|
#ifdef MoveMemory
|
|
|
|
#undef MoveMemory // windows shit
|
|
|
|
#endif
|
|
|
|
|
2019-06-11 06:59:28 +00:00
|
|
|
// TODO: put them somewhere else?
|
|
|
|
struct KeyFrame {
|
|
|
|
CQuaternion rotation;
|
|
|
|
float deltaTime; // relative to previous key frame
|
|
|
|
};
|
|
|
|
|
|
|
|
struct KeyFrameTrans : KeyFrame {
|
|
|
|
CVector translation;
|
|
|
|
};
|
|
|
|
|
2020-12-18 22:46:51 +00:00
|
|
|
struct KeyFrameCompressed {
|
|
|
|
int16 rot[4]; // 4096
|
|
|
|
int16 deltaTime; // 60
|
|
|
|
|
|
|
|
void GetRotation(CQuaternion *quat){
|
|
|
|
float scale = 1.0f/4096.0f;
|
|
|
|
quat->x = rot[0]*scale;
|
|
|
|
quat->y = rot[1]*scale;
|
|
|
|
quat->z = rot[2]*scale;
|
|
|
|
quat->w = rot[3]*scale;
|
|
|
|
}
|
|
|
|
void SetRotation(const CQuaternion &quat){
|
|
|
|
rot[0] = quat.x * 4096.0f;
|
|
|
|
rot[1] = quat.y * 4096.0f;
|
|
|
|
rot[2] = quat.z * 4096.0f;
|
|
|
|
rot[3] = quat.w * 4096.0f;
|
|
|
|
}
|
|
|
|
float GetDeltaTime(void) { return deltaTime/60.0f; }
|
|
|
|
void SetTime(float t) { deltaTime = t*60.0f + 0.5f; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct KeyFrameTransCompressed : KeyFrameCompressed {
|
|
|
|
int16 trans[3]; // 1024
|
|
|
|
|
|
|
|
void GetTranslation(CVector *vec) {
|
|
|
|
float scale = 1.0f/1024.0f;
|
|
|
|
vec->x = trans[0]*scale;
|
|
|
|
vec->y = trans[1]*scale;
|
|
|
|
vec->z = trans[2]*scale;
|
|
|
|
}
|
|
|
|
void SetTranslation(const CVector &vec){
|
|
|
|
trans[0] = vec.x*1024.0f;
|
|
|
|
trans[1] = vec.y*1024.0f;
|
|
|
|
trans[2] = vec.z*1024.0f;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-06-11 06:59:28 +00:00
|
|
|
|
|
|
|
// The sequence of key frames of one animated node
|
|
|
|
class CAnimBlendSequence
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
KF_ROT = 1,
|
|
|
|
KF_TRANS = 2
|
|
|
|
};
|
|
|
|
int32 type;
|
|
|
|
char name[24];
|
|
|
|
int32 numFrames;
|
|
|
|
int16 boneTag;
|
|
|
|
void *keyFrames;
|
|
|
|
void *keyFramesCompressed;
|
|
|
|
|
|
|
|
CAnimBlendSequence(void);
|
|
|
|
virtual ~CAnimBlendSequence(void);
|
|
|
|
void SetName(char *name);
|
2020-05-08 13:59:57 +00:00
|
|
|
void SetNumFrames(int numFrames, bool translation, bool compressed);
|
2019-06-11 06:59:28 +00:00
|
|
|
void RemoveQuaternionFlips(void);
|
|
|
|
KeyFrame *GetKeyFrame(int n) {
|
|
|
|
return type & KF_TRANS ?
|
|
|
|
&((KeyFrameTrans*)keyFrames)[n] :
|
|
|
|
&((KeyFrame*)keyFrames)[n];
|
|
|
|
}
|
2020-12-18 22:46:51 +00:00
|
|
|
KeyFrameCompressed *GetKeyFrameCompressed(int n) {
|
2020-05-08 13:59:57 +00:00
|
|
|
return type & KF_TRANS ?
|
2020-12-18 22:46:51 +00:00
|
|
|
&((KeyFrameTransCompressed*)keyFramesCompressed)[n] :
|
|
|
|
&((KeyFrameCompressed*)keyFramesCompressed)[n];
|
2020-05-08 13:59:57 +00:00
|
|
|
}
|
2019-06-11 06:59:28 +00:00
|
|
|
bool HasTranslation(void) { return !!(type & KF_TRANS); }
|
2020-12-18 22:46:51 +00:00
|
|
|
void Uncompress(void);
|
|
|
|
void CompressKeyframes(void);
|
|
|
|
void RemoveUncompressedData(void);
|
2020-12-01 16:42:18 +00:00
|
|
|
bool MoveMemory(void);
|
2019-06-11 06:59:28 +00:00
|
|
|
|
|
|
|
void SetBoneTag(int tag) { boneTag = tag; }
|
|
|
|
};
|
2020-12-18 16:27:18 +00:00
|
|
|
VALIDATE_SIZE(CAnimBlendSequence, 0x30);
|