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.

Universal Header
This header is shared between Metroid Prime and Donkey Kong Country, and is fairly straight forward.

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:

Repeat  times, one for each section, and the sections sections are associated with the following FourCC values:

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:

Submesh Offsets
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:

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.