MREA (Metroid Prime 3)
The .MREA file format is used to define areas in Metroid Prime 3 and Donkey Kong Country Returns. MREA files are broken up into many sections, and each section serves a specific purpose.
This file format needs more research Still a few sections we know nothing about. |
Universal Header
This header is shared between Metroid Prime and Donkey Kong Country, and is fairly straight forward.
Offset | Size | Description |
---|---|---|
0x0 | 4 | Magic Number 0xDEADBEEF |
0x4 | 4 | Version; see hub article |
0x8 | 48 | Transformation Matrix The position of the area in world-space |
0x38 | 4 | Mesh Count |
0x3C | 4 | SCLY Count |
0x40 | 4 | Section Count |
0x0 | 4 | Compressed Block Count |
0x4 | 4 | Section Number Count |
Compressed Blocks
Compressed blocks are handled in the exact same manner as Metroid Prime 2, however with DKCR simply replace LZO with zlib.
Section Numbers
Section Numbers are preceded by the compressed blocks, each section is designated in the following:
let N=Section Number Count
Type | Description |
---|---|
FourCC | Section type |
Long | Section Number |
Repeat N
times, one for each section, and the sections sections are associated with the following FourCC values:
FourCC | Description |
---|---|
AABB | Axis Aligned Bounding Boxes |
APTL | Unknown |
COLI | Collision |
DEPS | Dependencies |
EGMC | Unknown |
GPUD | Submesh data, e.g, vertices, normals, etc. |
LITE | Lights |
LLTE | Unknown |
PFL2 | Path file |
PVS! | Area vis octree, used for culling unseen geometry |
ROCT | Unknown |
RSOS | Revolution Shared Objects |
SOBJ | SCLY Layer data, there can be multiple copies, but only the first is indicated. |
SGEN | Unknown |
WOBJ | Mesh Header, always 0, the number of WOBJ sections is determined by the mesh count in the header. |
Materials
Materials are identical to those found in CMDL files.
Mesh Headers
The WOBJ sections are unique: they don't have a valid section number, and are always set to 0, however they are always in the sections immediately following the Materials, simply iterate through the mesh count and read the following structs:
Main Header
Type | Description | Notes |
---|---|---|
long | Unknown | Most likely visor flags in MP3, unknown use and DKCR |
CTransform4f | Transformation Matrix | Meshes location in world space |
CAABox | Bounding Box | Likely used for Depth sorting as in previous games. |
Submesh Offsets
Type | Description | Notes |
---|---|---|
long (SC) | Submesh count | |
long | Submesh Offsets[SC] | Relative to the start first submesh, (i.e, the first offset points the the end of the first submesh) |
Following the submesh data are two unknown sections, they both seem to be arrays of flags or indices but nothing is known about them.
AROT
Following the WOBJ sections is usually AROT. AROT is a BSP Tree that appears to be used for shot-collision and possibly depth sorting, nothing is known about how to handle this section.
AABB
The AABB section is exactly what it sounds like, it's an array of Axis-Aligned Bounding Boxes, assembling a BVH tree. AABB starts with the number of bounding boxes with each one consisting of the following struct:
Type | Description | Notes |
---|---|---|
CAABox | Axis Aligned Bounding Box | Used to assist depth sorting, and/or collision |
long | Unknown | The first entry in the table always covers the entire, with this value always being -1 |
short | Self Index | 1 indexed position of this particular AABB entry, but ONLY if the previous value is -1. |
short | Self Index | 1 indexed position of this particular AABB entry, but ONLY if the previous value is -1. |
GPU Description Section (GPUD)
The GPUD section is a bit confusing at first glance, however it's really no different from the previous MREA version in terms of ordering. There is also one GPUD per WOBJ section
The section order is as follows:
Vertices
The vertices are always 32bit floats, even in DKCR
Normals
The normals are always 32bit floats.
Colors
Usually 0 filled and completely unused, it's stored in MREA simply for completeness.
Float Texcoords
Metroid Prime 3 uses these exclusively, even for lightmaps, which simplifies UV handling quite a bit.
Short Texcoords
This is only used in DKCR and can be used for anything, not just for lightmaps
Submeshes
The submesh format is exactly the same as the Geometry formats found in Metroid Prime 3 and DKCR.