diff options
author | aap <aap@papnet.eu> | 2020-12-18 23:47:38 +0100 |
---|---|---|
committer | aap <aap@papnet.eu> | 2020-12-18 23:47:38 +0100 |
commit | df5bafc80c544382b3def3925e50cf2ad3382a03 (patch) | |
tree | 75f3e11e1265aadc0eae2eab10cdf582e1c176fa /src/animation/AnimManager.cpp | |
parent | little cleanup of templates (diff) | |
download | re3-df5bafc80c544382b3def3925e50cf2ad3382a03.tar re3-df5bafc80c544382b3def3925e50cf2ad3382a03.tar.gz re3-df5bafc80c544382b3def3925e50cf2ad3382a03.tar.bz2 re3-df5bafc80c544382b3def3925e50cf2ad3382a03.tar.lz re3-df5bafc80c544382b3def3925e50cf2ad3382a03.tar.xz re3-df5bafc80c544382b3def3925e50cf2ad3382a03.tar.zst re3-df5bafc80c544382b3def3925e50cf2ad3382a03.zip |
Diffstat (limited to 'src/animation/AnimManager.cpp')
-rw-r--r-- | src/animation/AnimManager.cpp | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index 877dcd76..e701018e 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -841,54 +841,57 @@ CAnimManager::LoadAnimFile(int fd, bool compress) ROUNDSIZE(anim.size); CFileMgr::Read(fd, buf, anim.size); int numFrames = *(int*)(buf+28); + seq->SetName(buf); #ifdef PED_SKIN if(anim.size == 44) seq->SetBoneTag(*(int*)(buf+40)); #endif - seq->SetName(buf); if(numFrames == 0) continue; + bool hasScale = false; + bool hasTranslation = false; CFileMgr::Read(fd, (char*)&info, sizeof(info)); - if(strncmp(info.ident, "KR00", 4) == 0){ - seq->SetNumFrames(numFrames, false); - KeyFrame *kf = seq->GetKeyFrame(0); - 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){ + if(strncmp(info.ident, "KRTS", 4) == 0){ + hasScale = true; seq->SetNumFrames(numFrames, true); - KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0); - for(l = 0; l < numFrames; l++, kf++){ - 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){ + }else if(strncmp(info.ident, "KRT0", 4) == 0){ + hasTranslation = true; seq->SetNumFrames(numFrames, true); - KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0); - for(l = 0; l < numFrames; l++, kf++){ + }else if(strncmp(info.ident, "KR00", 4) == 0){ + seq->SetNumFrames(numFrames, false); + } + + for(l = 0; l < numFrames; l++){ + if(hasScale){ CFileMgr::Read(fd, buf, 0x2C); - 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]; + 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; // scaling ignored 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 } } |