KMP (File Format)

From Custom Mario Kart
Revision as of 22:01, 17 March 2011 by Chadderz (talk | contribs) (moved Kmp (File Format) to KMP (File Format): Caps for consistency.)
Jump to navigation Jump to search

A KMP File contains information about how the course is played, such as start positions and check points.

Known editors:

Format

A variant on the KMP format has been used in Mario Kart DS. This article describes the Mario Kart Wii KMP format.

Header

The header for the KMP format is a 0x4C byte structure. It is as follows. All offsets are relative to the end of the header.

Offset Type Description
0x00 char[4] 'RKMD' in ASCII; File identifier
0x04 int Length of the file in bytes.
0x08 short Number of sections in the file.
0x0A short Length of the file header (0x004C).
0x0C int Unknown.
0x10 int KTPT section offset.
0x14 int ENPT section offset.
0x18 int ENPH section offset.
0x1C int ITPT section offset.
0x20 int ITPH section offset.
0x24 int CKPT section offset.
0x28 int CKPH section offset.
0x2C int GOBJ section offset.
0x30 int POTI section offset.
0x34 int AREA section offset.
0x38 int CAME section offset.
0x3C int JGPT section offset.
0x40 int CNPT section offset.
0x44 int MSPT section offset.
0x48 int STGI section offset.

Sections

The file consists of a series of sections, each describing a different aspect of the course. Each section has a header and entries.

KTPT

The KTPT section describes kart points; the starting positions of racers. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'KTPT' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x1C byte structure as follows.

Offset Type Description
0x00 vector A 3D position vector of the start position.
0x0C vector A 3D rotation vector of the start position.
0x18 short Player ID. In courses with multiple start positions (such as battle courses), this determines which players start here. Otherwise set to 0xFFFF to set all players start positions to this point.
0x1A short Padding.

ENPT

The ENPT section describes enemy points; the routes of cpu racers. The cpu racers attempt to follow the path described by each group of points (as determined by ENPH). The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'ENPT' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x14 byte structure as follows.

Offset Type Description
0x00 vector A 3D position vector of the enemy position.
0x0C float Unknown.
0x10 short Point properties. Exact meanings unknown.
0x12 short Point properties. Exact meanings unknown.

ENPH

The ENPH section describes enemy points grouping; how the routes of cpu racers link together. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'ENPH' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x10 byte structure as follows.

Offset Type Description
0x00 byte Point start. The index of the first ENPT entry in this group.
0x01 byte Point length. The number of ENPT entries in this group.
0x02 byte[6] Next group. The indicies of the possible next ENPH group entries to follow.
0x8 byte[6] Last group. The indicies of the previous ENPH groups entries may have followed.
0x0E short Padding.

ITPT

The ITPT section describes item points; the routes of items such as red shells. The items attempt to follow the path described by each group of points (as determined by ITPH). The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'ITPT' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x14 byte structure as follows.

Offset Type Description
0x00 vector A 3D position vector of the item position.
0x0C float Unknown.
0x10 short Point properties. Exact meanings unknown.
0x12 short Point properties. Exact meanings unknown.

ITPH

The ITPH section describes item point grouping; how the routes of items link together. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'ITPH' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x10 byte structure as follows.

Offset Type Description
0x00 byte Point start. The index of the first ITPT entry in this group.
0x01 byte Point length. The number of ITPT entries in this group.
0x02 byte[6] Next group. The indicies of the possible next ITPH group entries to follow.
0x8 byte[6] Last group. The indicies of the previous ITPH groups entries may have followed.
0x0E short Padding.

CKPT

The CKPT section describes check points; the routes players must follow to count laps. The racers must follow the path described by each group of points (as determined by CKPH). The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'CKPT' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x14 byte structure as follows.

Offset Type Description
0x00 vector A 2D position vector of the start of the check point line.
0x08 vector A 2D position vector of the end of check point line.
0x10 byte Respawn position. Index into the JGPT section to respawn players at once they have crossed this checkpoint.
0x11 byte Checkpoint setting
0x12 byte Last check point in this group's squence.
0x13 byte Next check point in this group's squence.

Checkpoint setting is separated in 3 groups:

Lapcount trigger: 00 (when passed in right direction it counts the lap)

Normal checkpoint: FF (used for setting respawns and checking in which position you are) It may effects more

Key checkpoint: xx (if you cross 01 you need to follow all in order before lapcount trigger works). Used to prevent ultra shortcuts.

For lap count you need to have at least passed the first and the last checkpoint, if you passed a key checkpoint, you need to pass all key checkpoints!

CKPH

The CKPH section describes check point grouping; how the routes of check points link together. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'CKPH' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x10 byte structure as follows.

Offset Type Description
0x00 byte Point start. The index of the first CKPT entry in this group.
0x01 byte Point length. The number of CKPT entries in this group.
0x02 byte[6] Next group. The indicies of the possible next CKPH group entries to follow.
0x8 byte[6] Last group. The indicies of the previous CKPH groups entries may have followed.
0x0E short Padding.

GOBJ

The GOBJ section describes objects; things on the course such as item boxes, pipes and also control objects such as sound triggers. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'GOBJ' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x3C byte structure as follows.

Offset Type Description
0x00 short Object ID. See Objects.
0x02 short Padding.
0x04 vector A 3D position vector of the object.
0x10 vector A 3D angle vector of the object's rotation.
0x1C vector A 3D scale vector of the object's scale.
0x28 short Route ID. Index into the POTI section that this object should follow.
0x2A short[8] Object settings. See Objects.
0x3A short Object presence flags. See Objects.

POTI

The POTI section describes routes; these are routes for many things including cameras and objects. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'POTI' in ASCII; Section identifier
0x04 short Number of routes.
0x06 short Total number of points in all routes.

Each entry is a 0x4 byte structure as follows, which is followed by 0x10 byte structures.

Offset Type Description
0x00 short Number of points in the route.
0x02 byte Route settings. Exact values unknown.
0x03 byte Route settings. Exact values unknown.

Each point in each entry is as follows.

Offset Type Description
0x00 vector A 3D position vector of the route position.
0x0C short Route point settings. Exact values unknown.
0x0E short Padding.

AREA

The AREA section describes areas; used to determine which camera to use for example. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'AREA' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x30 byte structure as follows.

Offset Type Description
0x00 short Area type. Exact values unknown.
0x02 byte Area setting. Exact values unknown.
0x03 byte Area setting. Exact values unknown.
0x04 vector A 3D position vector of the object.
0x10 vector A 3D angle vector of the object's rotation.
0x1C vector A 3D scale vector of the object's scale.
0x28 short[4] Area settings. Exact values unknown.

CAME

The CAME section describes cameras; used to determine cameras for starting routes, time trial pans, etc. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'CAME' in ASCII; Section identifier
0x04 short Number of entries.
0x06 byte Index of the opening pan camera entry.
0x07 byte Padding.

Each entry is a 0x48 byte structure as follows.

Offset Type Description
0x00 byte Camera type. Exact values unknown.
0x01 byte Next Camera entry index.
0x02 byte Unknown.
0x03 byte Unknown.
0x04 short[4] Camera settings. Unknown.
0x0C vector A 3D position vector of the camera.
0x18 vector An unknown 3D vector. Unknown.
0x24 vector An unknown 2D vector. Unknown.
0x2C vector A 3D vector. Location the camara looks to.
0x38 vector A 3D vector. Second location, it changes slowly
0x44 float The speed at which the camera follows the route.

JGPT

The JGPT section describes Jugem points; the respawn positions. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'JGPT' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x1C byte structure as follows.

Offset Type Description
0x00 vector A 3D position vector of the respawn position.
0x0C vector A 3D angle vector of the direction to respawn players in.
0x18 short The ID of this respawn position.
0x1A short Unknown.

CNPT

The CNPT section describes cannon points; the cannon target positions. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'CNPT' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x1C byte structure as follows.

Offset Type Description
0x00 vector A 3D position vector of the cannon position.
0x0C vector A 3D angle vector of the direction to release players from the cannon in.
0x18 short The ID of this cannon position.
0x1A short Shoteffect (0xFFFF is straight, 0x0001 is curved

MSPT

The MSPT section describes MSPT; Unknown function.. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'MSPT' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x1C byte structure as follows.

Offset Type Description
0x00 vector A 3D position vector of this point.
0x0C vector A 3D angle vector of this point.
0x18 short The ID of this entry.
0x1A short Unknown.

STGI

The STGI section describes stage information; information about the course. The header is a 0x8 byte structure as follows.

Offset Type Description
0x00 char[4] 'STGI' in ASCII; Section identifier
0x04 short Number of entries.
0x06 short Padding.

Each entry is a 0x0C byte structure as follows.

Offset Type Description
0x00 byte Number of laps. Not used in normal racing.
0x01 byte Unknown.
0x02 byte Unknown.
0x03 byte Unknown.
0x04 int Timerhandler Unsure
0x08 int Unknown.