Skip to content

Commit

Permalink
Interpreted extra Dead Space axes as scales, which seems to be right??
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Jan 8, 2025
1 parent 1db90ac commit e5c6b5a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions FinModelUtility/Formats/Visceral/Visceral/src/010/Rcb.bt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ typedef struct {
local ulong endOffset = FTell();

FSeek(boneIdTableOffset);
BoneId boneIds[boneCount];
BoneId boneIds[boneCount];

FSeek(boneMatricesOffset);
BoneMatrix boneMatrix[boneCount];
Expand All @@ -90,7 +90,7 @@ typedef struct {


FSeek(fileHeader.skeletonsOffset);
Skeleton skeleton[fileHeader.skeletonCount];
Skeleton skeleton[fileHeader.skeletonCount] <optimize=false>;



Expand Down
34 changes: 27 additions & 7 deletions FinModelUtility/Formats/Visceral/Visceral/src/api/BnkReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using schema.binary;


namespace visceral.api;

public class BnkReader {
Expand All @@ -24,6 +25,9 @@ public enum AxisType : byte {
POS_X,
POS_Y,
POS_Z,
SCALE_X,
SCALE_Y,
SCALE_Z,
}

public enum KeyframeType : byte {
Expand Down Expand Up @@ -107,9 +111,10 @@ private void ReadIntoAnimation_(IBinaryReader bnkBr,

var unkHash = bnkBr.ReadUInt32();
var maybeVersion = bnkBr.ReadUInt32();
var unk3 = bnkBr.ReadUInt32();
var unk4 = bnkBr.ReadUInt32();
var unk5 = bnkBr.ReadUInt32();
var isLooping = bnkBr.ReadUInt32() != 0;
var unk4 = bnkBr.ReadUInt16();
var extraAxisCount = bnkBr.ReadUInt16();
var unk6 = bnkBr.ReadUInt32();

var someHashFromRcb = bnkBr.ReadUInt32();
var standaloneCommandPrefix = bnkBr.ReadUInt32();
Expand Down Expand Up @@ -144,10 +149,9 @@ private void ReadIntoAnimation_(IBinaryReader bnkBr,
var boneTracks = finAnimation.AddBoneTracks(bones[b]);
var rotations = boneTracks.UseSeparateQuaternionKeyframes();
var translations = boneTracks.UseSeparateTranslationKeyframes();
var scales = boneTracks.UseSeparateScaleKeyframes();

for (var a = 0; a < 7; ++a) {
var axisType = (AxisType) a;

void ReadAxis(AxisType axisType) {
void SetKeyframe(int frame, float value) {
totalFrames = Math.Max(totalFrames, frame);

Expand All @@ -167,7 +171,13 @@ void SetKeyframe(int frame, float value) {
.SetKeyframe(frame, value);
break;
}
default: throw new Exception();
case AxisType.SCALE_X:
case AxisType.SCALE_Y:
case AxisType.SCALE_Z: {
scales.Axes[axisType - AxisType.SCALE_X]
.SetKeyframe(frame, value);
break;
}
}
}

Expand Down Expand Up @@ -216,6 +226,16 @@ void SetKeyframe(int frame, float value) {
throw new NotImplementedException();
}
}

if (b > 0) {
for (var a = 7; a < 7 + extraAxisCount; ++a) {
ReadAxis((AxisType) a);
}
}

for (var a = 0; a < 7; ++a) {
ReadAxis((AxisType) a);
}
}
}
}
Expand Down

0 comments on commit e5c6b5a

Please sign in to comment.