From CloudModding TWW Wiki

BTK stores texture matrix animation data.

JSYSTEM header

The file starts with a standard JSYSTEM header, using a magic of J3D1btk1. BTK files have one chunk, the TTK1 chunk.

TTK1

Header

Offset Type Name Description
0x00
Chunk Header Standard JSYSTEM chunk header
0x08
Loop Mode Loop Mode
0x09
int Rotation Frac Multiplier for fixed-point decimal
0x0A
short Duration The number of frames in the animation
0x0C
short Keyframe Count The total number of keyframes, times 3
0x0E
short Scale Table Count The number of entries in the scale table
0x10
short Rotation Table Count The number of entries in the rotation table
0x12
short Translation Table Count The number of entries in the rotation table
0x14
int Animation Data Table Offset Offset to the start of the animation data table
0x18
int Remap Table Offset Not used at runtime
0x1C
int Name Table Offset Contains the material names to bind against
0x20
int Texture Coordinate Index Table Offset
0x24
int Center Coordinate Table Offset
0x28
int Scale Table Offset
0x2C
int Rotation Table Offset
0x30
int Translation Table Offset
0x34
byte[0x28] Post Matrix Data A similar set of tables, for Post Matrices. Has never been observed to exist in the wild.
0x5C
MatrixMode Matrix Mode Determines whether texture coordinates should be calculated with the Basic or Maya algorithm. This field is not read in Sunshine's copy of JSYSTEM, hardcoding the Basic mode, and their tooling seems to have output uninitialized data instead of a valid enum value. It is explicitly checked to equal exactly 0x01 in Wind Waker onwards, likely for this reason.

MatrixMode is an enum as follows:

Value Name Meaning
0x00 Basic Mode
0x01 Maya Mode

The table data is packed in Struct-of-Arrays fashion, meaning that to read the Nth animation, one should read the Nth item in the material name, texture coordinate index, material center, and animation data tables.

Material Name and Texture Coordinate Index

The material name and texture coordinate index tell you how to bind the animation to a model. Animations are always bound by material name and texture coordinate index. The material name table is a JUTNameTab table. The table entries are laid out as follows:

Offset Type Name Description
0x00
GXTexCoordID (byte) Texture Coordinate Index

Center Coordinate Table

The center coordinate is used by the Basic Matrix Mode algorithm. The table entries are laid out as follows:

Offset Type Name Description
0x00
float S
0x04
float T
0x08
float Q

Animation Data

The animation data itself is stored in an identical form to BCK, so see the BCK page for details. Note that as this is acting on texture coordinates rather than world positions, the coordinates S, T, Q are used instead of X, Y, Z.

Calculating the SRT Texture Matrix

The SRT texture matrix can be calculated by either the Basic or Maya matrix modes.

Basic Mode

The Center S, Center T, Scale S, Scale T, Rotation Q, Translation S and Translation T inputs are used. The final matrix is a 3x2 matrix, which is as follows:

00 = Scale S * cos(Rotation Q)
01 = Scale S * -sin(Rotation Q)
02 = Translation S + Center S + (Scale S * (sin(Rotation Q) * Center T - cos(Rotation Q) * Center S))
10 = Scale T * sin(Rotation Q)
11 = Scale T * cos(Rotation R)
12 = Translation T + Center T + (Scale T * (-sin(Rotation Q) * Center S + cos(Rotation Q) * Center T))

Maya Mode

The Scale S, Scale T, Rotation Q, Translation S and Translation T inputs are used. The final matrix is a 3x2 matrix, which is as follows:

00 = Scale S * cos(Rotation Q)
01 = Scale T * -sin(Rotation Q)
02 = Scale S * ((0.5 * -cos(Rotation Q)) - (0.5 * sin(Rotation Q) - 0.5) - Translation S)
10 = Scale S * sin(rotation)
11 = Scale T * cos(rotation)
12 = Scale T * ((0.5 * -cos(Rotation Q)) + (0.5 * sin(Rotation Q) - 0.5) + Translation T) + 1