anim fixes
This commit is contained in:
parent
a080fbfbd4
commit
df5bafc80c
@ -52,7 +52,6 @@ CAnimBlendHierarchy::RemoveQuaternionFlips(void)
|
|||||||
void
|
void
|
||||||
CAnimBlendHierarchy::RemoveAnimSequences(void)
|
CAnimBlendHierarchy::RemoveAnimSequences(void)
|
||||||
{
|
{
|
||||||
if(sequences)
|
|
||||||
delete[] sequences;
|
delete[] sequences;
|
||||||
numSequences = 0;
|
numSequences = 0;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public:
|
|||||||
char name[24];
|
char name[24];
|
||||||
CAnimBlendSequence *sequences;
|
CAnimBlendSequence *sequences;
|
||||||
int16 numSequences;
|
int16 numSequences;
|
||||||
int16 compressed; // not really used
|
int16 compressed;
|
||||||
float totalLength;
|
float totalLength;
|
||||||
CLink<CAnimBlendHierarchy*> *linkPtr;
|
CLink<CAnimBlendHierarchy*> *linkPtr;
|
||||||
|
|
||||||
|
@ -16,9 +16,10 @@ CAnimBlendSequence::CAnimBlendSequence(void)
|
|||||||
|
|
||||||
CAnimBlendSequence::~CAnimBlendSequence(void)
|
CAnimBlendSequence::~CAnimBlendSequence(void)
|
||||||
{
|
{
|
||||||
assert(keyFramesCompressed == nil);
|
|
||||||
if(keyFrames)
|
if(keyFrames)
|
||||||
RwFree(keyFrames);
|
RwFree(keyFrames);
|
||||||
|
if(keyFramesCompressed)
|
||||||
|
RwFree(keyFramesCompressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -841,54 +841,57 @@ CAnimManager::LoadAnimFile(int fd, bool compress)
|
|||||||
ROUNDSIZE(anim.size);
|
ROUNDSIZE(anim.size);
|
||||||
CFileMgr::Read(fd, buf, anim.size);
|
CFileMgr::Read(fd, buf, anim.size);
|
||||||
int numFrames = *(int*)(buf+28);
|
int numFrames = *(int*)(buf+28);
|
||||||
|
seq->SetName(buf);
|
||||||
#ifdef PED_SKIN
|
#ifdef PED_SKIN
|
||||||
if(anim.size == 44)
|
if(anim.size == 44)
|
||||||
seq->SetBoneTag(*(int*)(buf+40));
|
seq->SetBoneTag(*(int*)(buf+40));
|
||||||
#endif
|
#endif
|
||||||
seq->SetName(buf);
|
|
||||||
if(numFrames == 0)
|
if(numFrames == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
bool hasScale = false;
|
||||||
|
bool hasTranslation = false;
|
||||||
CFileMgr::Read(fd, (char*)&info, sizeof(info));
|
CFileMgr::Read(fd, (char*)&info, sizeof(info));
|
||||||
if(strncmp(info.ident, "KR00", 4) == 0){
|
if(strncmp(info.ident, "KRTS", 4) == 0){
|
||||||
seq->SetNumFrames(numFrames, false);
|
hasScale = true;
|
||||||
KeyFrame *kf = seq->GetKeyFrame(0);
|
seq->SetNumFrames(numFrames, true);
|
||||||
for(l = 0; l < numFrames; l++, kf++){
|
|
||||||
CFileMgr::Read(fd, buf, 0x14);
|
|
||||||
kf->rotation.x = -fbuf[0];
|
|
||||||
kf->rotation.y = -fbuf[1];
|
|
||||||
kf->rotation.z = -fbuf[2];
|
|
||||||
kf->rotation.w = fbuf[3];
|
|
||||||
kf->deltaTime = fbuf[4]; // absolute time here
|
|
||||||
}
|
|
||||||
}else if(strncmp(info.ident, "KRT0", 4) == 0){
|
}else if(strncmp(info.ident, "KRT0", 4) == 0){
|
||||||
|
hasTranslation = true;
|
||||||
seq->SetNumFrames(numFrames, true);
|
seq->SetNumFrames(numFrames, true);
|
||||||
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
|
}else if(strncmp(info.ident, "KR00", 4) == 0){
|
||||||
for(l = 0; l < numFrames; l++, kf++){
|
seq->SetNumFrames(numFrames, false);
|
||||||
CFileMgr::Read(fd, buf, 0x20);
|
|
||||||
kf->rotation.x = -fbuf[0];
|
|
||||||
kf->rotation.y = -fbuf[1];
|
|
||||||
kf->rotation.z = -fbuf[2];
|
|
||||||
kf->rotation.w = fbuf[3];
|
|
||||||
kf->translation.x = fbuf[4];
|
|
||||||
kf->translation.y = fbuf[5];
|
|
||||||
kf->translation.z = fbuf[6];
|
|
||||||
kf->deltaTime = fbuf[7]; // absolute time here
|
|
||||||
}
|
}
|
||||||
}else if(strncmp(info.ident, "KRTS", 4) == 0){
|
|
||||||
seq->SetNumFrames(numFrames, true);
|
for(l = 0; l < numFrames; l++){
|
||||||
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
|
if(hasScale){
|
||||||
for(l = 0; l < numFrames; l++, kf++){
|
|
||||||
CFileMgr::Read(fd, buf, 0x2C);
|
CFileMgr::Read(fd, buf, 0x2C);
|
||||||
kf->rotation.x = -fbuf[0];
|
CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
|
||||||
kf->rotation.y = -fbuf[1];
|
rot.Invert();
|
||||||
kf->rotation.z = -fbuf[2];
|
CVector trans(fbuf[4], fbuf[5], fbuf[6]);
|
||||||
kf->rotation.w = fbuf[3];
|
|
||||||
kf->translation.x = fbuf[4];
|
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
|
||||||
kf->translation.y = fbuf[5];
|
kf->rotation = rot;
|
||||||
kf->translation.z = fbuf[6];
|
kf->translation = trans;
|
||||||
// scaling ignored
|
// scaling ignored
|
||||||
kf->deltaTime = fbuf[10]; // absolute time here
|
kf->deltaTime = fbuf[10]; // absolute time here
|
||||||
|
}else if(hasTranslation){
|
||||||
|
CFileMgr::Read(fd, buf, 0x20);
|
||||||
|
CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
|
||||||
|
rot.Invert();
|
||||||
|
CVector trans(fbuf[4], fbuf[5], fbuf[6]);
|
||||||
|
|
||||||
|
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
|
||||||
|
kf->rotation = rot;
|
||||||
|
kf->translation = trans;
|
||||||
|
kf->deltaTime = fbuf[7]; // absolute time here
|
||||||
|
}else{
|
||||||
|
CFileMgr::Read(fd, buf, 0x14);
|
||||||
|
CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
|
||||||
|
rot.Invert();
|
||||||
|
|
||||||
|
KeyFrame *kf = (KeyFrame*)seq->GetKeyFrame(l);
|
||||||
|
kf->rotation = rot;
|
||||||
|
kf->deltaTime = fbuf[4]; // absolute time here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "AnimBlendClumpData.h"
|
#include "AnimBlendClumpData.h"
|
||||||
#include "AnimBlendHierarchy.h"
|
#include "AnimBlendHierarchy.h"
|
||||||
#include "AnimBlendAssociation.h"
|
#include "AnimBlendAssociation.h"
|
||||||
|
#include "AnimManager.h"
|
||||||
#include "RpAnimBlend.h"
|
#include "RpAnimBlend.h"
|
||||||
#ifdef PED_SKIN
|
#ifdef PED_SKIN
|
||||||
#include "PedModelInfo.h"
|
#include "PedModelInfo.h"
|
||||||
@ -441,7 +442,7 @@ RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta)
|
|||||||
next = link->next;
|
next = link->next;
|
||||||
CAnimBlendAssociation *assoc = CAnimBlendAssociation::FromLink(link);
|
CAnimBlendAssociation *assoc = CAnimBlendAssociation::FromLink(link);
|
||||||
if(assoc->UpdateBlend(timeDelta)){
|
if(assoc->UpdateBlend(timeDelta)){
|
||||||
// CAnimManager::UncompressAnimation(v6->hierarchy)
|
CAnimManager::UncompressAnimation(assoc->hierarchy);
|
||||||
updateData.nodes[i++] = assoc->GetNode(0);
|
updateData.nodes[i++] = assoc->GetNode(0);
|
||||||
if(assoc->flags & ASSOC_MOVEMENT){
|
if(assoc->flags & ASSOC_MOVEMENT){
|
||||||
totalLength += assoc->hierarchy->totalLength/assoc->speed * assoc->blendAmount;
|
totalLength += assoc->hierarchy->totalLength/assoc->speed * assoc->blendAmount;
|
||||||
|
@ -12,6 +12,11 @@ public:
|
|||||||
float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; }
|
float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; }
|
||||||
void Normalise(void);
|
void Normalise(void);
|
||||||
void Multiply(const CQuaternion &q1, const CQuaternion &q2);
|
void Multiply(const CQuaternion &q1, const CQuaternion &q2);
|
||||||
|
void Invert(void){ // Conjugate would have been a better name
|
||||||
|
x = -x;
|
||||||
|
y = -y;
|
||||||
|
z = -z;
|
||||||
|
}
|
||||||
|
|
||||||
const CQuaternion &operator+=(CQuaternion const &right) {
|
const CQuaternion &operator+=(CQuaternion const &right) {
|
||||||
x += right.x;
|
x += right.x;
|
||||||
|
Loading…
Reference in New Issue
Block a user