Skip to content

Commit

Permalink
Finally figured out how to read type 0 animations, what a nightmare.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Jan 13, 2025
1 parent 9d1ed0c commit 5ead21a
Showing 1 changed file with 127 additions and 8 deletions.
135 changes: 127 additions & 8 deletions FinModelUtility/Formats/Visceral/Visceral/src/010/Bnk.bt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <bgcolor=C_POINTER>;
Expand Down Expand Up @@ -130,11 +152,9 @@ AnimationHeader animationHeaders[fileHeader.animationHeaderCount] <optimize=fals
typedef struct {
uint ptr;


local uint tmp = FTell();
FSeek(ptr);


uint someId; // Looks like a hash, might be for some kind of name?
uint maybeVersion;
uint unk1;
Expand All @@ -148,11 +168,18 @@ typedef struct {
uint unk4;
uint unk5;

uint unk6;
ushort animationType;
ushort unk6;
uint unk7;
uint someCount;
uint someOffset <bgcolor=C_POINTER>;


if (animationType == 0) {
struct AnimationData0 animationData0 <bgcolor=0xff0000>;
}
if (animationType == 1) {
struct AnimationData1 animationData1;
}

typedef struct {
ushort maybePadding;
Expand All @@ -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 <bgcolor=C_5F>;
if (value == 0x5f) {
num5fs++;
}
}
}
local int64 align = 0x10 - (FTell() % 0x10);

// Section 2
byte section2Bytes[6 * type1BoneCount] <bgcolor=C_TYPE_1_BONE>;
Align(align, 2);

// Section 3
byte section3Bytes[6 * type2BoneCount] <bgcolor=C_TYPE_2_BONE>;
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] <bgcolor=C_TYPE_8_BONE>;
Align(align, 7);

// Section 8
byte section8Bytes[12 * type16BoneCount] <bgcolor=C_TYPE_16_BONE>;
Align(align, 8);

// Section 9
byte section9Bytes[animationLengthTimes2Or0 + 4*unk2_8];
Align(align, 9);
};

struct AnimationData1 {
};



FSeek(fileHeader.animationDataOffsetTableOffset);
Expand Down

0 comments on commit 5ead21a

Please sign in to comment.