diff options
Diffstat (limited to '')
-rw-r--r-- | src/animation/AnimManager.cpp | 148 |
1 files changed, 86 insertions, 62 deletions
diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index a85149e6..9fc54654 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -287,6 +287,7 @@ AnimAssocDesc aStripAnimDescs[] = { { ANIM_STRIP_F, ASSOC_REPEAT | ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_STRIP_G, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, }; +#ifdef PC_PLAYER_CONTROLS AnimAssocDesc aStdAnimDescsSide[] = { { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION | ASSOC_WALK }, { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION | ASSOC_WALK }, @@ -294,7 +295,7 @@ AnimAssocDesc aStdAnimDescsSide[] = { { ANIM_IDLE_STANCE, ASSOC_REPEAT }, { ANIM_WALK_START, ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION }, }; - +#endif char const* aStdAnimations[] = { "walk_civi", "run_civi", @@ -834,6 +835,7 @@ char const* aSkateAnimations[] = { "skate_sprint", "skate_idle", }; +#ifdef PC_PLAYER_CONTROLS char const* aPlayerStrafeBackAnimations[] = { "walk_back", "run_back", @@ -897,7 +899,7 @@ char const* aChainsawStrafeRightAnimations[] = { "idle_csaw", "walkst_csaw_right", }; - +#endif #define awc(a) ARRAY_SIZE(a), a const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS] = { @@ -953,6 +955,7 @@ const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_ { "jogwoman", "ped", MI_COP, awc(aJoggerWomanAnimations), aStdAnimDescs }, { "panicchunky", "ped", MI_COP, awc(aPanicChunkyAnimations), aStdAnimDescs }, { "skate", "skate", MI_COP, awc(aSkateAnimations), aStdAnimDescs }, +#ifdef PC_PLAYER_CONTROLS { "playerback", "ped", MI_COP, awc(aPlayerStrafeBackAnimations), aStdAnimDescs }, { "playerleft", "ped", MI_COP, awc(aPlayerStrafeLeftAnimations), aStdAnimDescsSide }, { "playerright", "ped", MI_COP, awc(aPlayerStrafeRightAnimations), aStdAnimDescsSide }, @@ -962,6 +965,7 @@ const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_ { "csawback", "ped", MI_COP, awc(aChainsawStrafeBackAnimations), aStdAnimDescs }, { "csawleft", "ped", MI_COP, awc(aChainsawStrafeLeftAnimations), aStdAnimDescsSide }, { "csawright", "ped", MI_COP, awc(aChainsawStrafeRightAnimations), aStdAnimDescsSide }, +#endif }; #undef awc @@ -992,7 +996,7 @@ CAnimManager::Shutdown(void) void CAnimManager::UncompressAnimation(CAnimBlendHierarchy *hier) { - if(hier->compressed2){ + if(hier->keepCompressed){ if(hier->totalLength == 0.0f) hier->CalcTotalTimeCompressed(); }else{ @@ -1255,13 +1259,10 @@ CAnimManager::CreateAnimAssocGroups(void) group->firstAnimId = def->animDescs[0].animId; group->CreateAssociations(def->blockName, clump, def->animNames, def->numAnims); for(j = 0; j < group->numAssociations; j++) - // GetAnimation(i) in III (but it's in LoadAnimFiles), GetAnimation(group->animDesc[j].animId) in VC group->GetAnimation(def->animDescs[j].animId)->flags |= def->animDescs[j].flags; -#ifdef PED_SKIN if(IsClumpSkinned(clump)) RpClumpForAllAtomics(clump, AtomicRemoveAnimFromSkinCB, nil); -#endif RpClumpDestroy(clump); } } @@ -1278,7 +1279,7 @@ CAnimManager::LoadAnimFile(const char *filename) //--MIAMI: done void -CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]) +CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*uncompressedAnims)[32]) { #define ROUNDSIZE(x) if((x) & 3) (x) += 4 - ((x)&3) struct IfpHeader { @@ -1323,16 +1324,22 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32] RwStreamRead(stream, buf, name.size); hier->SetName(buf); - // Unimplemented uncompressed anim thing - if (somename) { - for (int i = 0; somename[i][0]; i++) { - if (!CGeneral::faststricmp(somename[i], hier->name)) +#ifdef ANIM_COMPRESSION + bool compressHier = compress; +#else + bool compressHier = false; +#endif + if (uncompressedAnims) { + for (int i = 0; uncompressedAnims[i][0]; i++) { + if (!CGeneral::faststricmp(uncompressedAnims[i], hier->name)){ debug("Loading %s uncompressed\n", hier->name); + compressHier = false; + } } } - hier->compressed = false; - hier->compressed2 = false; + hier->compressed = compressHier; + hier->keepCompressed = false; // DG info has number of nodes/sequences RwStreamRead(stream, (char*)&dgan, sizeof(IfpHeader)); @@ -1352,69 +1359,86 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32] ROUNDSIZE(anim.size); RwStreamRead(stream, buf, anim.size); int numFrames = *(int*)(buf+28); -#ifdef PED_SKIN + seq->SetName(buf); if(anim.size == 44) seq->SetBoneTag(*(int*)(buf+40)); -#endif - seq->SetName(buf); if(numFrames == 0) continue; + bool hasScale = false; + bool hasTranslation = false; RwStreamRead(stream, &info, sizeof(info)); - if(strncmp(info.ident, "KR00", 4) == 0){ - seq->SetNumFrames(numFrames, false, false); - KeyFrame *kf = seq->GetKeyFrame(0); - if (strstr(seq->name, "L Toe")) - debug("anim %s has toe keyframes\n", hier->name); // , seq->name); - - for(l = 0; l < numFrames; l++, kf++){ - RwStreamRead(stream, 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 - } + if(strncmp(info.ident, "KRTS", 4) == 0){ + hasScale = true; + seq->SetNumFrames(numFrames, true, compressHier); }else if(strncmp(info.ident, "KRT0", 4) == 0){ - seq->SetNumFrames(numFrames, true, false); - KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0); - if (strstr(seq->name, "L Toe")) - debug("anim %s has toe keyframes\n", hier->name); // , seq->name); + hasTranslation = true; + seq->SetNumFrames(numFrames, true, compressHier); + }else if(strncmp(info.ident, "KR00", 4) == 0){ + seq->SetNumFrames(numFrames, false, compressHier); + } + if(strstr(seq->name, "L Toe")) + debug("anim %s has toe keyframes\n", hier->name); // BUG: seq->name + + for(l = 0; l < numFrames; l++){ + if(hasScale){ + RwStreamRead(stream, buf, 0x2C); + CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]); + rot.Invert(); + CVector trans(fbuf[4], fbuf[5], fbuf[6]); - for(l = 0; l < numFrames; l++, kf++){ + if(compressHier){ + KeyFrameTransCompressed *kf = (KeyFrameTransCompressed*)seq->GetKeyFrameCompressed(l); + kf->SetRotation(rot); + kf->SetTranslation(trans); + // scaling ignored + kf->SetTime(fbuf[10]); // absolute time here + }else{ + KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l); + kf->rotation = rot; + kf->translation = trans; + // scaling ignored + kf->deltaTime = fbuf[10]; // absolute time here + } + }else if(hasTranslation){ RwStreamRead(stream, 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, false); - KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0); - if (strstr(seq->name, "L Toe")) - debug("anim %s has toe keyframes\n", hier->name); // , seq->name); + CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]); + rot.Invert(); + CVector trans(fbuf[4], fbuf[5], fbuf[6]); - for(l = 0; l < numFrames; l++, kf++){ - RwStreamRead(stream, 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]; - // scaling ignored - kf->deltaTime = fbuf[10]; // absolute time here + if(compressHier){ + KeyFrameTransCompressed *kf = (KeyFrameTransCompressed*)seq->GetKeyFrameCompressed(l); + kf->SetRotation(rot); + kf->SetTranslation(trans); + kf->SetTime(fbuf[7]); // absolute time here + }else{ + KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l); + kf->rotation = rot; + kf->translation = trans; + kf->deltaTime = fbuf[7]; // absolute time here + } + }else{ + RwStreamRead(stream, buf, 0x14); + CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]); + rot.Invert(); + + if(compressHier){ + KeyFrameCompressed *kf = (KeyFrameCompressed*)seq->GetKeyFrameCompressed(l); + kf->SetRotation(rot); + kf->SetTime(fbuf[4]); // absolute time here + }else{ + KeyFrame *kf = (KeyFrame*)seq->GetKeyFrame(l); + kf->rotation = rot; + kf->deltaTime = fbuf[4]; // absolute time here + } } } } - hier->RemoveQuaternionFlips(); - hier->CalcTotalTime(); + if(!compressHier){ + hier->RemoveQuaternionFlips(); + hier->CalcTotalTime(); + } } if(animIndex > ms_numAnimations) ms_numAnimations = animIndex; |