BRK
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.
Contents
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 |
---|---|---|---|
|
Chunk Header | Standard JSYSTEM chunk header | |
|
Loop Mode | Loop Mode | |
|
byte | Unknown | (Likely unused) |
|
short | Duration | The number of frames in the animation |
|
short | Register Color Table Count | The number of animation entries in the register colors table |
|
short | Konstant Color Table Count | The number of animation entries in the konstant colors table |
|
short | Register Red Count | The number of entries in the register red values table |
|
short | Register Blue Count | The number of entries in the register blue values table |
|
short | Register Green Count | The number of entries in the register green values table |
|
short | Register Alpha Count | The number of entries in the register alpha values table |
|
short | Konstant Red Count | The number of entries in the konstant red values table |
|
short | Konstant Blue Count | The number of entries in the konstant blue values table |
|
short | Konstant Green Count | The number of entries in the konstant green values table |
|
short | Konstant Alpha Count | The number of entries in the konstant alpha values table |
|
int | Register Animation Data Table Offset | Offset to the start of the register animation data table |
|
int | Konstant Animation Data Table Offset | Offset to the start of the konstant animation data table |
|
int | Register Remap Table Offset | |
|
int | Konstant Remap Table Offset | |
|
int | Register Name Table Offset | |
|
int | Register Name Table Offset | |
|
int | Register Red Table Offset | |
|
int | Register Green Table Offset | |
|
int | Register Blue Table Offset | |
|
int | Register Alpha Table Offset | |
|
int | Konstant Red Table Offset | |
|
int | Konstant Green Table Offset | |
|
int | Konstant Blue Table Offset | |
|
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 |
---|---|---|
|
TrackData | Red |
|
TrackData | Green |
|
TrackData | Blue |
|
TrackData | Alpha |
TrackData
Each TrackData is 0x06 bytes long, with the following layout:
Offset | Type | Name | Description |
---|---|---|---|
|
short | Count | Number of keyframes in the track |
|
short | Index | The index of the first piece of keyframe data |
|
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:
- If the Count field is 1, then there is no curve, and instead, a single value is stored in the table at Index.
- 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).
- 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.