2019-06-11 08:59:28 +02:00
|
|
|
#include "common.h"
|
2020-04-17 15:31:11 +02:00
|
|
|
|
2019-06-11 08:59:28 +02:00
|
|
|
#include "AnimBlendSequence.h"
|
|
|
|
|
2020-05-08 15:59:57 +02:00
|
|
|
//--MIAMI: file done
|
|
|
|
|
2019-06-11 08:59:28 +02:00
|
|
|
CAnimBlendSequence::CAnimBlendSequence(void)
|
|
|
|
{
|
|
|
|
type = 0;
|
|
|
|
numFrames = 0;
|
|
|
|
keyFrames = nil;
|
|
|
|
keyFramesCompressed = nil;
|
|
|
|
#ifdef PED_SKIN
|
|
|
|
boneTag = -1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
CAnimBlendSequence::~CAnimBlendSequence(void)
|
|
|
|
{
|
|
|
|
if(keyFrames)
|
|
|
|
RwFree(keyFrames);
|
2020-05-08 15:59:57 +02:00
|
|
|
if(keyFramesCompressed)
|
|
|
|
RwFree(keyFramesCompressed);
|
2019-06-11 08:59:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CAnimBlendSequence::SetName(char *name)
|
|
|
|
{
|
|
|
|
strncpy(this->name, name, 24);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-05-08 15:59:57 +02:00
|
|
|
CAnimBlendSequence::SetNumFrames(int numFrames, bool translation, bool compressed)
|
2019-06-11 08:59:28 +02:00
|
|
|
{
|
|
|
|
if(translation){
|
|
|
|
type |= KF_ROT | KF_TRANS;
|
2020-05-08 15:59:57 +02:00
|
|
|
if(compressed)
|
|
|
|
keyFramesCompressed = RwMalloc(sizeof(KeyFrameTrans) * numFrames);
|
|
|
|
else
|
|
|
|
keyFrames = RwMalloc(sizeof(KeyFrameTrans) * numFrames);
|
2019-06-11 08:59:28 +02:00
|
|
|
}else{
|
|
|
|
type |= KF_ROT;
|
2020-05-08 15:59:57 +02:00
|
|
|
if(compressed)
|
|
|
|
keyFramesCompressed = RwMalloc(sizeof(KeyFrame) * numFrames);
|
|
|
|
else
|
|
|
|
keyFrames = RwMalloc(sizeof(KeyFrame) * numFrames);
|
2019-06-11 08:59:28 +02:00
|
|
|
}
|
|
|
|
this->numFrames = numFrames;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CAnimBlendSequence::RemoveQuaternionFlips(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
CQuaternion last;
|
|
|
|
KeyFrame *frame;
|
|
|
|
|
|
|
|
if(numFrames < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
frame = GetKeyFrame(0);
|
|
|
|
last = frame->rotation;
|
|
|
|
for(i = 1; i < numFrames; i++){
|
|
|
|
frame = GetKeyFrame(i);
|
|
|
|
if(DotProduct(last, frame->rotation) < 0.0f)
|
|
|
|
frame->rotation = -frame->rotation;
|
|
|
|
last = frame->rotation;
|
|
|
|
}
|
|
|
|
}
|