======== Animation Data ========
Banjo-Kazooie uses animation files comprised of a list of [[https://hack64.net/wiki/doku.php?id=banjo_kazooie:model_data#animation_setup:~:text=ii%20ii%5D-,Internal%20Bone%20ID,-0x000E|Internal Bone IDs]], their transformation type (scale, rotate or translate), and across which frames of an animation these transformations occur. Animation indices can be found in the [[https://hack64.net/wiki/doku.php?id=banjo_kazooie:rom_map | Rom Map]].
===== Header =====
The file header is 0x8 bytes in length and details the start and end frames of the animation as well as the amount of elements impacting the various bones of a model.
^ Address ^ Value / Syntax ^ Description ^
| 0x0000 | [xx xx] | Start Frame of animation |
| 0x0004 | [yy yy] | End Frame of animation |
| 0x0008 | [zz zz] | Element Count |
| 0x000C | [00 00] | Padding / Unknown |
**Example (60f0.bin, Banjo's Backflip at address 0x0):**
''00 0F 00 A5 00 48 00 00''
Loads an animation beginning at frame 15 (0x0F) and ending at frame 165 (0xA5) with 72 (0x48) elements across those frames.
===== Element Header =====
The element header establishes that an internal bone ID is affected, which transform type* is occurring, and how many times that bone transforms between the start and end frames. Element headers are 0x4 bytes. Each Internal Bone ID may have more than one element corresponding to a separate transformation type of that bone. An element header only exists before the transform section for its respective bone ID and a new one is generated when all transforms for data count [cc cc] have been written.
^ Offset from End of Header ^ Value / Syntax ^ Description ^
| 0x0000 | [aa ab] | aa = Internal Bone ID, b = Transform Type* |
| 0x0004 | [cc cc] | Data Count |
**Example (60f0.bin, Banjo's Backflip at address 0x08):**
''00 10 00 09''
This element targets Internal Bone ID 1 (0x1), rotates the bone around the X axis (0x0), and does this at 9 (0x9) different points between frames 15 and 165.
^ *Transform Type ^ Value ^
| X Rotation | 0 |
| Y Rotation | 1 |
| Z Rotation | 2 |
| X Scale | 3 |
| Y Scale | 4 |
| Z Scale | 5 |
| X Translation | 6 |
| Y Translation | 7 |
| Z Translation | 8 |
===== Transform Structure =====
The transform structure details the frames in which a transformation of the bone occurs and by how much the bone moves between frames with respect to the scale of the model (transform factor). Transform structure is repeated for instances [cc cc] before introducing the next element header where [cc cc] = [[https://hack64.net/wiki/doku.php?id=banjo_kazooie:animations#element_header:~:text=0x0004-,%5Bcc%20cc%5D,-Data%20Count|Data Count]]. The first two bytes of data contain two bits representing unknown values and fourteen bits which determine the frame of a transformation.
*Bitwise Parameters:
[xx xx] => ''[DE FF FF FF FF FF FF FF]''
| D | Unknown 1 |
| E | Unknown 2 |
| FF FF FF FF FF FF FF | Frame of Transformation |
So data for each transform structure can best be represented like this:
^ Offset from End of Element Header ^ Value / Syntax ^ Description ^
| 0x0000 | [xx xx] | *Bitwise Parameters for Unk1, Unk2, and Frame of Transformation |
| 0x0002 | [gg gg] | Transform Factor |
**Example (60f0.bin, Banjo's Backflip at address 0x0C):**
''C0 0F 15 E6''
At frame 15 (0xF), two bitwise parameters are set as true (if [d] = 1 and [e] = 1, then the remaining two bits must return false to equal 0xC) and then the bone transforms by a factor of 87.59375 (0x15E6).