From CloudModding TWW Wiki

BRK is a format that stores texture register animations, which allows animating color changes. It consists of the standard animation header, followed by BRK-specific data in the TRK1 chunk, with color data stored in banks at the end.

JSYSTEM Header

The file starts with a standard JSYSTEM header, using a magic of J3D1brk1. BRK files have one chunk, the TRK1 chunk.

Header

Offset Type Name Description
0x00
Chunk Header Standard JSYSTEM chunk header
0x08
Loop Mode Loop Mode
0x09
byte Unknown (Likely unused)
0x0A
short Duration The number of frames in the animation
0x0C
short Register Color Table Count The number of animation entries in the register colors table
0x0E
short Konstant Color Table Count The number of animation entries in the konstant colors table
0x10
short Register Red Count The number of entries in the register red values table
0x12
short Register Blue Count The number of entries in the register blue values table
0x14
short Register Green Count The number of entries in the register green values table
0x16
short Register Alpha Count The number of entries in the register alpha values table
0x18
short Konstant Red Count The number of entries in the konstant red values table
0x1A
short Konstant Blue Count The number of entries in the konstant blue values table
0x1C
short Konstant Green Count The number of entries in the konstant green values table
0x1E
short Konstant Alpha Count The number of entries in the konstant alpha values table
0x20
int Register Animation Data Table Offset Offset to the start of the register animation data table
0x24
int Konstant Animation Data Table Offset Offset to the start of the konstant animation data table
0x28
int Register Remap Table Offset
0x2C
int Konstant Remap Table Offset
0x30
int Register Name Table Offset
0x34
int Register Name Table Offset
0x38
int Register Red Table Offset
0x3C
int Register Green Table Offset
0x40
int Register Blue Table Offset
0x44
int Register Alpha Table Offset
0x48
int Konstant Red Table Offset
0x4C
int Konstant Green Table Offset
0x50
int Konstant Blue Table Offset
0x54
int Konstant Alpha Table Offset

LoopMode

LoopMode is an enum as follows:

Value Name Meaning
0x00 Once The animation plays once and stops on the final frame.
0x01 Once and Reset The animation plays once and stops on the first frame.
0x02 Loop The animation loops indefinitely.
0x03 Mirrored Once The animation plays once, then plays in reverse, then stops on the first frame.
0x04 Mirrored Loop The animation plays once, then plays in reverse, then the process repeats.

Animation Data

There are 4 animation tracks stored in each animation table, one for each color channel.

Offset Type Channel
0x00
TrackData Red
0x06
TrackData Green
0x0C
TrackData Blue
0x12
TrackData Alpha

TrackData

Each TrackData is 0x06 bytes long, with the following layout:

Offset Type Name Description
0x00
short Count Number of keyframes in the track
0x02
short Index The index of the first piece of keyframe data
0x04
TangentMode Tangent Mode The mode of storing animation curve tangents

TangentMode

TangentMode is an enum as follows:

Value Name Meaning
0x00 Symmetric One tangent value is stored, used for both the incoming and outgoing tangents
0x01 Piece-wise Two tangent values are stored, the incoming and outgoing tangents, respectively

Animation Curve Data

The tables for individual channels store the component data for that channel. The values are stored as consecutive signed shorts.

Using the Index, Count, and Tangent Mode values for the curves, the decoding is as follows:

  1. If the Count field is 1, then there is no curve, and instead, a single value is stored in the table at Index.
  2. Otherwise, then if Tangent Mode is Symmetric: Read 3 values per keyframe, with Count keyframes, starting from the table at Index. The three values, are, in order: Time (the frame index), Value, and Tangent (both incoming and outgoing).
  3. Otherwise, then Tangent Mode should be Piece-wise. Read 4 values per keyframe, with Count keyframes, starting from the table at Index. The four values, are, in order: Time (the frame index), Value, Incoming Tangent, and Outgoing Tangent.

Calculating the value for an animation track

To calculate a single value for a single animation track, a Hermite spline interpolation should be used. Specifically, choose the two keyframes on either side of the current time, and interpolate using the left's outgoing tangent and value, and the right's incoming tangent and value to build the four control points on a 1D Cubic Hermite spline.