diff --git a/FinModelUtility/Formats/Visceral/Visceral/src/010/Bnk.bt b/FinModelUtility/Formats/Visceral/Visceral/src/010/Bnk.bt index b17524c5b..811929197 100644 --- a/FinModelUtility/Formats/Visceral/Visceral/src/010/Bnk.bt +++ b/FinModelUtility/Formats/Visceral/Visceral/src/010/Bnk.bt @@ -13,13 +13,35 @@ LittleEndian(); -local int C_POINTER = 0x888888; -local int C_ANIMATION_HEADER = 0x00ffff; +local int C_POINTER = 0x000000; //0x888888; +local int C_ANIMATION_HEADER = 0x000000; //0x00ffff; local int C_ANIMATION_DATA = 0xffff00; -local int C_EVENT_DATA = 0x0000ff; +local int C_EVENT_DATA = 0x000000; // 0x0000ff; +local int C_5F = 0xffffff; + +local int C_TYPE_1_BONE = 0x00ff00; +local int C_TYPE_2_BONE = 0x0000ff; +local int C_TYPE_8_BONE = 0x00ffff; +local int C_TYPE_16_BONE = 0xff00ff; local uint i, ii; +void Align(int64 amount, int64 section) { + local int64 pos = FTell(); + local int64 posRelativeToLine = pos % 0x10; + + if (amount == 0x10) { + if (posRelativeToLine > 0) { + FSkip(0x10 - posRelativeToLine); + } + } else { + if (posRelativeToLine < amount) { + FSkip(amount - posRelativeToLine); + } else if (posRelativeToLine > amount) { + FSkip(0x10 - posRelativeToLine + amount); + } + } +} typedef struct { uint pointersOffset ; @@ -130,11 +152,9 @@ AnimationHeader animationHeaders[fileHeader.animationHeaderCount] ; - + + if (animationType == 0) { + struct AnimationData0 animationData0 ; + } + if (animationType == 1) { + struct AnimationData1 animationData1; + } typedef struct { ushort maybePadding; @@ -179,10 +206,102 @@ typedef struct { Params params; } - FSeek(tmp); } AnimationData; +struct AnimationData0 { + uint unk0_0; + uint unk0_4; + uint unk0_8; + uint unk0_C; + + uint unk1_0; + uint unk1_4; + ushort boneCount; + ushort boneSectionLength; + ushort unk1_C; + ushort unk1_E; + + ushort unk2_0; + ushort unk2_2; + ushort animationLength; + ushort animationLengthTimes2Or0; + ushort unk2_8; + ushort type2BoneCount; + ushort type1BoneCount; + ushort padding1; + + ushort padding2; + ushort type8BoneCount; + ushort type16BoneCount; + ushort unk3_6; + ushort unk3_8; + ushort numOf5fsAfterHeader; + uint padding3; + + uint maybeRanges[4 * 4]; + + byte boneTypes[boneCount]; + byte paddingAfterBones[boneSectionLength - boneCount]; + + // Section 1 + // TODO: Figure out how this is actually meant to work. + if (numOf5fsAfterHeader == 0) { + byte unkWithout5f[0x30]; + } else { + local uint num5fs = 0; + while (num5fs < numOf5fsAfterHeader) { + byte value ; + if (value == 0x5f) { + num5fs++; + } + } + } + local int64 align = 0x10 - (FTell() % 0x10); + + // Section 2 + byte section2Bytes[6 * type1BoneCount] ; + Align(align, 2); + + // Section 3 + byte section3Bytes[6 * type2BoneCount] ; + Align(align, 3); + + // Section 4 + byte section4Bytes[unk3_6 * animationLengthTimes2Or0]; + Align(align, 4); + + // Section 5 + byte section5Bytes[unk3_8 * animationLength]; + Align(align, 5); + + // Section 6 + local int simpleBoneCount = 0; + local int i; + for(i = 0; i < boneCount; i++) { + if (boneTypes[i] == 1 || boneTypes[i] == 2) { + simpleBoneCount++; + } + } + byte section6Bytes[12 * simpleBoneCount]; + Align(align, 6); + + // Section 7 + byte section7Bytes[12 * type8BoneCount] ; + Align(align, 7); + + // Section 8 + byte section8Bytes[12 * type16BoneCount] ; + Align(align, 8); + + // Section 9 + byte section9Bytes[animationLengthTimes2Or0 + 4*unk2_8]; + Align(align, 9); +}; + +struct AnimationData1 { +}; + FSeek(fileHeader.animationDataOffsetTableOffset);