FSCN (File Format)
The FSCN (caFe SCeNe animation) subfile stores scene animations controlling fog, light and camera settings. It appears as a subfile of a BFRES file in the 10th index group. Unless otherwise noted, all offsets in the file are relative to themselves.
Format
An FSCN file begins with an FSCN header. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. The purpose of these sections is described in the table below.
FSCN shares many similarities with the FSKA, FSHU, FTXP, FVIS and FSHA subfiles, which mostly only differ in the structure describing what is changed by animations over time, but reusing the same animation curve and key structures, and even headers being very similar to one another.
Header (FSCN)
Every FSCN begins with an 0x24 byte FSCN header. Beyond the general subfile fields it stores the entry number and location of Camera, Fog and Light Animation index groups.
Offset | Size | Type | Description |
---|---|---|---|
0x00 | 4 | Char[4] | "FSCN" file identifier, ASCII string. |
0x04 | 4 | Int32 | File name offset (without file extension). |
0x08 | 4 | Int32 | File path offset, the path of the file this data was originally created from. Stripped in Mario Kart 8 files, always pointing to an empty string at the end of the BFRES string table. |
0x0C | 2 | UInt16 | User Data entry count. |
0x0E | 2 | UInt16 | Camera Animation count, the number of elements in the Camera Animation index group. |
0x10 | 2 | UInt16 | Light Animation count, the number of elements in the Light Animation index group. |
0x12 | 2 | UInt16 | Fog Animation count, the number of elements in the Fog Animation index group |
0x14 | 4 | Int32 | Camera Animation index group offset. |
0x18 | 4 | Int32 | Light Animation index group offset. |
0x1C | 4 | Int32 | Fog Animation index group offset. |
0x20 | 4 | Int32 | User Data index group offset. |
0x24 | End of FSCN header |
Camera Animation (FCAM)
A Camera Animation can modify visual parameters which control the cameera parameters like the field of view, aspect ratio, position, rotation or clipping planes. The header is of 0x24 bytes size.
Offset | Size | Type | Description |
---|---|---|---|
0x00 | 4 | Char[4] | "FCAM" section identifier, ASCII string. |
0x04 | 2 | UInt16 | Flags. Set of bits packed as xxxxxPxR xxxxxLxB, controlling how to play the animation and what data is stored. The following flags are possible:
|
0x06 | 2 | — | Padding. |
0x08 | 4 | Int32 | Frame count. |
0x0C | 1 | Byte | Curve count, the number of elements in the Curve array. |
0x0D | 1 | — | Padding. |
0x0E | 2 | UInt16 | User Data entry count (for this section). |
0x10 | 4 | UInt32 | Baked length. |
0x14 | 4 | Int32 | Name offset of this animation. |
0x18 | 4 | Int32 | Curve array offset. |
0x1C | 4 | Int32 | Base Value offset. |
0x20 | 4 | Int32 | User Data index group offset (for this section). |
0x24 | End of Camera Animation (FCAM) |
Base Value (Camera Animation Result)
The Camera Animation header points to a Camera Animation Result structure of 0x2C bytes size. It apparently stores the initial state of the camera.
Offset | Size | Type | Description |
---|---|---|---|
0x00 | 4 | Single | Near clipping plane distance. Polygons closer to the camera than this distance are not drawn. |
0x04 | 4 | Single | Far clipping plane distance. Polygons further away to the camera than this distance are not drawn. |
0x08 | 4 | Single | Aspect ratio of the projected world. |
0x0C | 4 | Single | Height offset of the camera or Field of View angle. |
0x10 | 12 | Single[3] | Position of the camera. |
0x1C | 12 | Single[3] | Rotation (aim direction) of the camera. |
0x28 | 4 | Single | Twist of the camera. |
0x2C | End of Base Value (Camera Animation Result) |
Light Animation (FLIT)
A Light Animation can modify light parameters like light type, intensity or attenuation. The header is of 0x30 bytes size.
Offset | Size | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x00 | 4 | Char[4] | "FLIT" section identifier, ASCII string. | ||||||||||||||||
0x04 | 2 | UInt16 | Flags. Set of bits packed as PPPPPPPC xxxxxLxB, controlling how to play the animation and what data is stored. The following flags are possible:
| ||||||||||||||||
0x06 | 2 | UInt16 | User Data entry count (for this section). | ||||||||||||||||
0x08 | 4 | Int32 | Frame count. | ||||||||||||||||
0x0C | 1 | Byte | Curve count, the number of elements in the Curve array. | ||||||||||||||||
0x0D | 1 | SByte | Light type, determining what kind of light source is simulated. | ||||||||||||||||
0x0E | 1 | SByte | Distance Attenuation function index. | ||||||||||||||||
0x0F | 1 | SByte | Angle Attenuation function index. | ||||||||||||||||
0x10 | 4 | UInt32 | Baked length. | ||||||||||||||||
0x14 | 4 | Int32 | Name offset of this animation. | ||||||||||||||||
0x18 | 4 | Int32 | Light type name offset. | ||||||||||||||||
0x1C | 4 | Int32 | Distance Attenuation function name offset. | ||||||||||||||||
0x20 | 4 | Int32 | Angle Attenuation function name offset. | ||||||||||||||||
0x24 | 4 | Int32 | Curve array offset. | ||||||||||||||||
0x28 | 4 | Int32 | Base Value offset. | ||||||||||||||||
0x2C | 4 | Int32 | User Data index group offset (for this section). | ||||||||||||||||
0x30 | End of Light Animation (FLIT) |
Base Value (Light Animation Result)
The Light Animation header points to a Light Animation Result structure of 0x44 bytes size. It apparently stores the initial state of the light.
Offset | Size | Type | Description |
---|---|---|---|
0x00 | 4 | Int32 | Enable the light or disable it. |
0x04 | 12 | Single[3] | Position of the light. |
0x10 | 12 | Single[3] | Rotation (aim direction) of the light. |
0x1C | 8 | Single[2] | Distance Attenuation. |
0x24 | 8 | Single[2] | Angle Attenuation. |
0x2C | 24 | Single[3][2] | Colors, stored as RGB floating point vectors. |
0x44 | End of Base Value (Light Animation Result) |
Fog Animation (FFOG)
A Fog Animation can modify fog parameters like distance or color. The header is of 0x30 bytes size.
Offset | Size | Type | Description |
---|---|---|---|
0x00 | 4 | Char[4] | "FFOG" section identifier, ASCII string. |
0x04 | 2 | UInt16 | Flags. Set of bits packed as xxxxxxxx xxxxxLxB, controlling how to play the animation and what data is stored. The following flags are possible:
|
0x06 | 2 | — | Padding. |
0x08 | 4 | Int32 | Frame count. |
0x0C | 1 | Byte | Curve count, the number of elements in the Curve array. |
0x0D | 1 | Byte | Distance Attenuation function index. |
0x0E | 2 | UInt16 | User Data entry count (for this section). |
0x10 | 4 | UInt32 | Baked length. |
0x14 | 4 | Int32 | Name offset of this animation. |
0x18 | 4 | Int32 | Distance Attenuation function name offset. |
0x24 | 4 | Int32 | Curve array offset. |
0x28 | 4 | Int32 | Base Value offset. |
0x2C | 4 | Int32 | User Data index group offset (for this section). |
0x30 | End of Fog Animation (FFOG) |
Base Value (Fog Animation Result)
The Fog Animation header points to a Fog Animation Result structure of 0x14 bytes size. It apparently stores the initial state of the fog.
Offset | Size | Type | Description |
---|---|---|---|
0x00 | 8 | Single[2] | Distance Attenuation. |
0x08 | 12 | Single[3] | Color of the fog. |
0x14 | End of Base Value (Fog Animation Result) |
Curve
Curves store how animations are performed over time and store the required keys and values for this. They appear in multiple animation subfiles, and their header is of 0x24 bytes size (for BFRES versions earlier than 3.4.0.0, they are of 0x20 bytes size).
Offset | Size | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x00 | 2 | UInt16 | Flags. Sets of bits packed as xxxxxxxx xCCCKKFF.
| ||||||||||||||||||||||||||||||||||||||||||||||||
0x02 | 2 | UInt16 | Key count. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x04 | 4 | UInt32 | Target Offset, an offset in bytes into the corresponding Animation Data structure to animate the field at that relative address. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x08 | 4 | Single | Start frame, the first frame at which a key is placed. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x0C | 4 | Single | End frame, the last frame at which a key is placed. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x10 | 4 | Int32 / Single | Data scale, multiplier to the raw key values to get the final result. Together with Data offset, it is chosen carefully to consider an optimal granularity between the stored values. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x14 | 4 | Single | Data offset, added to the raw values (after multiplying them with Data scale) to get the final key value. | ||||||||||||||||||||||||||||||||||||||||||||||||
if BFRES version >= 3.4.0.0 | |||||||||||||||||||||||||||||||||||||||||||||||||||
0x18 | 4 | Single | Data delta, stores the difference between the first and last key value. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x1C | 4 | Int32 | Frame array offset. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x20 | 4 | Int32 | Key array offset. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x24 | End of Curve | ||||||||||||||||||||||||||||||||||||||||||||||||||
else | |||||||||||||||||||||||||||||||||||||||||||||||||||
0x18 | 4 | Int32 | Frame array offset. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x1C | 4 | Int32 | Key array offset. | ||||||||||||||||||||||||||||||||||||||||||||||||
0x20 | End of Curve |
Frames
The Curve header points to a Frame array which stores values controlling at which frame a Key from the Key array is placed. Thus, the array has as many elements as specified in Key count. The data type of the frames is given in the Curve's Flags.
The end of the array is aligned to 4 bytes.
Keys
The Curve header points to a Key array which stores the key values and additional values to interpolate the curve from one point to the next. Thus, the array has as many elements as specified in Key count, multiplied by the number of elements stored per key (depending upon the CCC Curve Type bits in the Curve Flags as described above). The data type of each element is given by the KK Key Type bits in the Curve Flags.
The end of the array is aligned to 4 bytes.
Step Curves
The elements apparently represent the key values directly.
Linear Curves
For linearly interpolated curves, 2 elements are stored per key:
- Value at which the key is set. To get the final value, scale and then offset it.
- Delta to value at next frame to which the curve linearly runs. To get the final value, scale it. If there is no next frame, this is always 0.
A key can be discarded by the next key if that one is stored at the same frame. In that case, only the value of the next key is stored, and the delta of the previous key is adjusted to run to the value of the now discarded key.
This example curve's keys are stored as SByte elements. The curve scale was computed as 2, the offset as 200 and the curve delta (if available in the BFRES version) as 300. Due to the lower key in frame 20 being discarded in favor of the higher key, only 3 keys are stored in 6 elements as follows.
Point | Array Index | Raw Value | *2 (Scale) | +200 (Offset) | Notes |
---|---|---|---|---|---|
0,0 | 0 | -100 | -200 | 0 | Initial key with value 0. |
(20,254) | 1 | 127 | 254 | - | Delta to end value of initial key at next frame. |
20,254 | - | - | - | - | This key is discarded in favor of the next. |
20,400 | 2 | 100 | 200 | 400 | Overrides previous key. |
(30,300) | 3 | -50 | -100 | - | End value of overriding key at next frame. |
30,300 | 4 | 50 | 100 | 300 | Value of fourth (but third stored) key. |
(end) | 5 | 0 | 0 | - | Since no frame follows, always 0. |
Hermite Curves
For hermite curves, 4 elements are stored for each key. It is unclear how to exactly interprete them to form the curve out of it.
Target
The Curve targets which control what exactly is animated over time are not yet known.