RFL_Res.dat (File Format)

From Custom Mario Kart
Jump to navigation Jump to search

RFL_Res.dat is the only sub file from /contents/RFLRes01.arc, and present in many Wii games that use Miis. It contains all Mii head components, such as face, hair, beard and nose models, as well as the textures used for the eyes and eyebrows between others. The name suggests it was generated by the Revolution SDK's Face Library.

File Format

The file is big endian, and structured in eighteen sections, each one corresponding to a group. It starts headerless, with a tree structure directly.

Offset Type Description
0x00 UInt16 Number of sections N. Always 0x12 = 18.
0x02 UInt16 Unknown. The value is 0x39D = 925.
0x04 Int32[N] Section offsets, relative to the start of the file.
0x04 + (4 * N) End of main tree, start of first section

Section

Each section follows a similar structure than the main tree's. There is no way to identify what each section corresponds to, except by looking at their files. Since this file is the same in all games it is used, it's assumed that they follow a common order.

Offset Type Description
0x00 UInt16 Number of files N.
0x02 UInt16 Length of the biggest file, unknown use.
0x04 Int32[N] File offsets, relative to the end of the offset list.
0x04 + (4 * N) Int32 Section size.
0x08 + (4 * N) End of section, start of first file

File

There are two main types of files: models and textures. While textures are in BTI format, models use a standard format that does not contain material, vertex color and shader data, although it follows the Wii Graphics Code for drawing polygon indices. Each model section has a different identifier, and how much data they can handle depends of the type of model.

File structure order
Index Identifier/Description
1 berd. Beard models, no UV data.
2 Texture data. Eye textures.
3 Texture data. Eyebrow textures.
4 face. Face models, with UV data and position values for the beard, hair and nose.
5 Texture data. Make up textures.
6 frhd. Forehead models, no UV data.
7 glas. Glasses model, with UV data. It only contains one model, which is used for all glasses.
8 Texture data. Glasses textures.
9 hair. Hair models, no UV data. Each one corresponds to a forehead model.
10 mask. Area with UV data where eyes, eyebrows, mouth, mole, nose lines and facial hair are drawn. Each one corresponds to a face model.
11 Texture data. Mole texture.
12 Texture data. Mouth and lip textures.
13 Texture data. Facial hair textures.
14 nose. Nose models, no UV data.
15 nsln. Nose lines, with UV data. Each one corresponds to a nose model.
16 Texture data. Nose textures. Each one corresponds to a nose line model.
17 cap_. Additional hair complements, like caps and hairbands, with UV data. Each one corresponds to a hair model.
18 Texture data. Cap textures. Each one corresponds to a cap model.

Model format

Offset Type Description
0x00 String Magic.
if magic is face
0x04 Float[3] Nose XYZ position.
0x10 Float[3] Beard XYZ position.
0x1C Float[3] Hair XYZ position.
M = current position (model data offset)
M UInt16 Number of vertices V.
M + 0x02 SByte[3][2][V] Vertex data. The first SByte is the integer, and the second one is the decimal multiplied by 255.
M + 0x02 + (3 * 2 * V) UInt16 Number of vertex normals N.
M + 0x04 + (3 * 2 * V) SByte[3][2][N] Normal data. The first SByte is the integer, and the second one is the decimal multiplied by 255. Then, the result is multiplied by 64.
if model has UV data
M + 0x04 + (3 * 2 * V) + (3 * 2 * N) UInt16 Number of texture coordinates T.
M + 0x06 + (3 * 2 * V) + (3 * 2 * N) Int16[2][T] Texture coordinate data. Horizontal coordinates are calculated by multiplying the value by 8192,
while vertical coordinates are calculated by doing the same and substracting the result from 8192.
P = current position
P Byte Number of draw commands D.
Polygon draw data for each draw command D, starting at P + 0x01
0x00 Byte Number of indices I.
0x01 Byte Draw command type, as defined in the Wii Graphics Code.
0x02 Byte[3][I] or Byte[2][I] Index data, in the order vertex index, normal index, texture coordinate index (if exists).

Texture format

Main article: BTI (File Format)

Tools

The following tools can handle RFL_Res.dat: