CHR0 (File Format)

From Custom Mario Kart
(Redirected from CHR0)
Jump to navigation Jump to search
Under Construction
This article is not finished. Help improve it by adding accurate information or correcting grammar and spelling.

Overview

This page describes the Mario Kart Wii CHR0 file format, as found within BRRES files. They are model movement animation files.

File Format

File Header

Offset Type Description
0x00 String The magic "CHR0" to identify the sub file. See »BRRES Sub Files« for other magics.
0x04 UInt32 Length of the sub file.
0x08 UInt32 Sub file version number. The number of sections (N) is dependent of this version number. See »BRRES Sub Files« for details.
0x0C Int32 Offset to outer BRRES File.
0x10 Int32[N] N section offsets. N is implied in the version number (offset 0x08).
0x10+N*4 Int32 String offset to the name of this sub file. This name equal to the name of the entry name of the BRRES Index Group pointing to this data.
0x14+N*4 End of this header

CHR0 Header

The CHR0 header follows directly after the file header. For CHR0 version 5, it starts at offset 0x1c and has the following layout:

offset size description
0x00 4 Unknown.
0x04 2 Frame count.
0x06 2 Animation data count.
0x08 4 Looping 0x00=disabled 0x01=enabled.
0x0c 4 Unknown.
0x10 End of header/Start of a filler

Animation Data (Section 0)

The start of section 0 is defined in the file header. It contains the animation data for the file. It starts with a BRRES Index Group. Each one of the entries in the index group points to the animation information for one texture.

Model Animation Data

The structure of the model animation data which the index group points to has the following layout:

offset size description
0x00 4 String offset to the name of the bone to animate.
0x04 4 Animation type code. Determines how much animation data is required (P).
0x08 P*4 Animation data.
0x08+P*4 End of structure

The animation type code is a 32 bit structure with the following layout (msb first):

Bit 1f 1e 1d 1c 1b 1a 19 18
Meaning Translation Format Rotation Format Scale Format Has Translation
Bit 17 16 15 14 13 12 11 10
Meaning Has Rotation Has Scale Z Fixed Y Fixed X Fixed Rotation Z Fixed Rotation Y Fixed Rotation X Fixed
Bit f e d c b a 9 8
Meaning Scale Z Fixed Scale Y Fixed Scale X Fixed Disable Classic Scale Apply Child Scale Compensate Apply Scale Compensate Use Model Translation Use Model Rotation
Bit 7 6 5 4 3 2 1 0
Meaning Use Model Scale Translation Isotropic Rotation Isotropic Scale Uniform Scale Isotropic Rotation & Translation Isotropic Use Identity Always set

If present, the animation data is stored in the following order:

  1. Scale
  2. Rotation
  3. Translation

If the value is 'fixed', then the animation data contains a single to set the value to. If the type is 'isotropic', only one piece of data is stored for each type, rather than for each component. If it is not 'fixed', the animation data field contains a pointer to an animation frame data structure data. The structure depends on the value in the format field.

Format Name
0b001 Interpolated 4.
0b010 Interpolated 6.
0b011 Interpolated 12.
0b100 Linear 1.
0b110 Linear 4.
Interpolated 4
offset size description
0x00 2 Frame count (Q).
0x02 2 Unknown.
0x04 4 Frame scale (float).
0x08 4 Step (float).
0x0c 4 Base (float).
0x10 Q*4 Frame information.
0x10+Q*4 End of structure

The frame information data each has the following layout:

offset size description
0x00 1 Frame index.
0x01 1.5 Step.
0x02+1/2 1.5 Tangent (/32.0 to get value).
0x04 End of structure
Interpolated 6
offset size description
0x00 2 Frame count (Q).
0x02 2 Unknown.
0x04 4 Frame scale (float).
0x08 4 Step (float).
0x0c 4 Base (float).
0x10 Q*6 Frame information.
0x10+Q*6 End of structure

The frame information data each has the following layout:

offset size description
0x00 2 Frame index (/32.0 to get value).
0x02 2 Step.
0x04 2 Tangent (/256.0 to get value).
0x06 End of structure
Interpolated 12
offset size description
0x00 2 Frame count (Q).
0x02 2 Unknown.
0x04 4 Frame scale (float).
0x8 Q*12 Frame information.
0x8+Q*12 End of structure

The frame information data each has the following layout:

offset size description
0x00 4 Frame index (float).
0x04 4 Value (float).
0x08 4 Tangent (float).
0x0c End of structure
Linear 1

Q is the frame count which is set in the file header.

offset size description
0x00 4 Step (float).
0x04 4 Base (float).
0x8 Q*4 Frame information.
0x8+Q*4 End of structure

The frame information data is a series of singles.

Linear 4

Linear 4 simply consists of a number of singles representing the value at each of the frames. The frame count is the frame count from the file header.

All information about the implementation of these structures is presently unknown.

Tools

The following tools can handle CHR0 files:

Links

All about BRRES files

BRRES fileIndex GroupSub Files

CHR0CLR0MDL0PAT0SCN0SHP0SRT0TEX0