MREA (Metroid Prime)

See MREA (File Format) for the other revisions of this format.

The MREA format defines areas (rooms) in Metroid Prime. It's a massive format that contains tons of different data, including terrain geometry, collision, objects, lights, and more.

Format
Like CMDL, MREA files are split up into a number of 32-byte aligned sections. Every section both starts and ends on a 32-byte boundary. These are used to separate different parts of the file; different types of sections typically indicate different sets of data. The header declares the section count and the size of each one; using these is the only way to navigate the file.

Data Sections
MREA data sections are in the file in the following order:

World Geometry
See Materials (Metroid Prime) and Geometry (Metroid Prime)

MREA files have one material section, followed by a number of world models, each of which has its own set of geometry sections. There's couple small differences you'll usually see on world models compared to regular CMDL ones:


 * Normals are always shorts, so vertex format 0 is never used.
 * Most world models use lightmaps, so normally the first UV coordinate on each vertex will read from the short UV array. This isn't always the case, though; you need to make sure you check the material so you know where to read from.
 * Surfaces will usually have a bounding box in the extra data in the surface header. This bounding box is used for depth sorting.
 * Each world model starts with an extra header section which is formatted like this:

Area Octree
The AROT section stores the area's octree, accelerating back-to-front rendering of contained meshes, it is also used for spacial queries such as collision.

Script Layers
The SCLY section contains data for objects.

Collision
You have three guesses what the collision section is for, and the first two don't count.

Unknown Section
This one is sandwiched between collision and lights, and usually just contains a single 32-bit "1". Purpose is unknown.

Lights
This section is for dynamic lights, see the Light article for details.

Visibility Tree
This section is labeled "VISI". This section is sometimes not actually present in the file, labeled with a size of 0.

Path
This is the final section in the file; it's always 0x20 bytes, and its only value is a single PATH file ID.

Tools

 * Parax's MREA maxscript can import MREA terrain geometry into 3DS Max.