MREA (Metroid Prime 3): Difference between revisions

>Aruki
>Aruki
 
(23 intermediate revisions by the same user not shown)
Line 3: Line 3:
The '''MREA format''', which defines areas/levels, received another large layout overhaul in Metroid Prime 3. The level geometry data received the biggest update, with a new material format, lot of things being moved around, and a few entirely new sections being introduced. This article covers Metroid Prime 3, the MP3 E3 prototype, and Donkey Kong Country Returns.
The '''MREA format''', which defines areas/levels, received another large layout overhaul in Metroid Prime 3. The level geometry data received the biggest update, with a new material format, lot of things being moved around, and a few entirely new sections being introduced. This article covers Metroid Prime 3, the MP3 E3 prototype, and Donkey Kong Country Returns.


{{research|moderate|There are a few sections we know nothing about.}}
{{research|moderate|Research needed on the area octree and visibility tree sections to verify structure and check for version differences. Also the purpose of the LLTE section is unknown.}}


__TOC__
__TOC__
Line 18: Line 18:
! Offset
! Offset
! Type
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| u32
| u32
| 4
| 1
| '''Magic Number'''; always 0xDEADBEEF
| '''Magic'''
| Always <code>0xDEADBEEF</code>.
|-
|-
| 0x4
| 0x4
| u32
| u32
| 4
| 1
| '''Version'''; see [[MREA (File Format)|hub article]]
| '''Version'''
| See [[MREA (File Format)|hub article]] for a list of possible version numbers.
|-
|-
| 0x8
| 0x8
| float[12]
| float
| 48
| 12
| '''Transform matrix''' (transform of the area in world space)
| '''Area Transform'''
| Matrix that represents the area's transform from the origin. Most area data is pre-transformed, so this matrix is only used occasionally.
|-
|-
| 0x38
| 0x38
| u32
| u32
| 4
| 1
| '''Mesh count'''
| '''World Model Count'''
| Number of world models in this area.
|-
|-
| 0x3C
| 0x3C
| u32
| u32
| 4
| 1
| '''Layer count'''
| '''Script Layer Count'''
| Number of script layers in this area.
|-
|-
| 0x40
| 0x40
| u32
| u32
| 4
| 1
| '''Section count''' (SC)
| '''Data Section Count'''
| Number of data sections in the file.
|-
|-
| 0x44
| 0x44
| u32
| u32
| 4
| 1
| '''Compressed block count'''
| '''Compressed Block Count'''
| Number of compressed data blocks in the file.
|-
|-
| 0x48
| 0x48
| u32
| u32
| 4
| 1
| '''Section number count'''
| '''Section Number Count'''
| Number of section numbers at the end of the header.
|-
|-
| 0x4C
| 0x4C
| u32[5]
| u32
| 0x14
| 5
| '''Padding'''
| '''Padding'''
| Padding bytes that align the file with the next multiple-of-32 offset.
|-
|-
| 0x60
| 0x60
| u32[SC]
| u32
| -
| ''Data Section Count''
| '''Section sizes'''
| '''Data Section Sizes'''
| Array containing the size of each data section in the file. Every size is always a multiple of 32.
|-
|-
| colspan=4 {{unknown|End of main header data; pad to 32 bytes before compressed section definitions}}
| colspan=5 {{unknown|End of main header data; pad to 32 bytes before compressed section definitions}}
|}
|}


Line 83: Line 94:
! Offset
! Offset
! Type
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| u32
| u32
| 4
| 1
| '''Buffer size''' (0x120 bytes larger than uncompressed size - same as uncompressed size for uncompressed blocks)
| '''Buffer Size'''
| This is always 0x120 bytes larger than the uncompressed size on compressed bytes, and the same value as the uncompressed size on uncompressed blocks
|-
|-
| 0x4
| 0x4
| u32
| u32
| 4
| 1
| '''Uncompressed size'''
| '''Uncompressed Size'''
|
|-
|-
| 0x8
| 0x8
| u32
| u32
| 4
| 1
| '''Compressed size''' (if 0, that indicates an uncompressed block)
| '''Compressed Size'''
| This is 0 on uncompressed blocks.
|-
|-
| 0xC
| 0xC
| u32
| u32
| 4
| 1
| '''Section count''' (the number of regular sections contained in this block)
| '''Data Section Count'''
| The number of regular data sections contained in this block.
|-
|-
| 0x10
| 0x10
| colspan=3 {{unknown|Block definition end}}
| colspan=5 {{unknown|Block definition end}}
|}
|}


==== Section Numbers ====
==== Section Numbers ====


The section numbers portion of the header indicates the index of each major data chunk. Some of these chunks contain multiple sections; in that case the number will point to the first section of the chunk. Each number is a short 8-byte struct:
The section numbers portion of the header indicates the section index of each major data chunk. Some of these chunks contain multiple sections; in that case the number will point to the first section of the chunk. Each number is a short 8-byte struct:


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Type
! Type
! Size
! Count
! Description
! Name
|-
|-
| 0x0
| 0x0
| char[4]
| char
| 4
| 4
| '''Section type'''
| '''Section Type'''
|-
|-
| 0x4
| 0x4
| u32
| u32
| 4
| 1
| '''Section number'''
| '''Section Index'''
|}
|}


Here are all the possible section numbers and what they are:
<code>WOBJ</code> can be listed multiple times, but its section index is always 0 (pointing to the materials section). Every other section number always appears in every MREA file once (none are optional). Here are all possible section numbers and what they are, in the order that they appear in the file: (note this is both the order the section numbers are listed in as well as the order that the sections themselves appear in the file)


{| class="wikitable"
{| class="wikitable"
! FourCC
! FourCC
! Description
! Description
! MP3
! DKCR
|-
|-
| AABB
| <code>WOBJ</code>
| Axis Aligned Bounding Boxes
| [[#Materials|Materials]] + [[#World Model Definition|World Model Definition]]
| {{check}}
| {{check}}
|-
|-
| APTL
| <code>ROCT</code>
| PTLA file
| [[#Area Octree|Area Octree]]
| {{check}}
| {{check}}
|-
|-
| COLI
| <code>AABB</code>
| Collision
| [[#Surface Group Bounding Boxes|Surface Group Bounding Boxes]]
| {{check}}
| {{check}}
|-
|-
| DEPS
| <code>GPUD</code>
| Dependencies
| [[#GPU Data|World Geometry GPU Data]]
| {{check}}
| {{check}}
|-
|-
| EGMC
| <code>DEPS</code>
| EGMC file
| [[#Dependencies|Dependencies]]
| {{check}}
| {{check}}
|-
|-
| GPUD
| <code>SOBJ</code>
| GPU Data (level geometry)
| [[#Script Layers|Script Layers]]
| {{check}}
| {{check}}
|-
|-
| LITE
| <code>SGEN</code>
| Lights
| [[#Generated Script Objects|Generated Script Objects]]
| {{check}}
| {{check}}
|-
|-
| LLTE
| <code>COLI</code>
| {{unknown|Unknown}}
| [[#Collision|Collision]]
| {{check}}
| {{check}}
|-
|-
| PFL2
| <code>LITE</code>
| PATH file
| [[#Lights|Lights]]
| {{check}}
| {{check}}
|-
|-
| PVS!
| <code>LLTE</code>
| Probable Visibility Set
| {{unknown|[[#Unknown Section (LLTE)|Unknown]]}}
| {{check}}
| {{check}}
|-
|-
| ROCT
| <code>PVS!</code>
| Area Octree (AROT)
| [[#Visibility Tree|Visibility Tree]]
| {{check}}
| {{check}}
|-
|-
| RSOS
| <code>RSOS</code>
| RSO file list (Revolution Shared Object)
| [[#RSO Module List|RSO Module List]]
| {{check}}
| {{check}}
|-
|-
| SGEN
| <code>PFL2</code>
| Script Generator layer (SCGN)
| [[#Path|Path]]
| {{check}}
| {{nocheck}}
|-
|-
| SOBJ
| <code>APTL</code>
| Script Object layers (SCLY)
| [[#Portal Area|Portal Area]]
| {{check}}
| {{nocheck}}
|-
|-
| WOBJ
| <code>EGMC</code>
| World Object; always 0, points to the materials section
| [[#Static Geometry Map|Static Geometry Map]]
| {{check}}
| {{nocheck}}
|}
|}


=== Materials ===  
=== Materials ===  
[[Materials (Metroid Prime 3)|Materials]] are identical to those found in [[CMDL (Metroid Prime 3)|CMDL]] files.
''See [[Materials (Metroid Prime 3)]]''


=== Mesh Headers ===
Identical to the material format found in [[CMDL (File Format)|CMDL]]. There is just one materials section which is shared across all world models.
The WOBJ sections correspond to the header for a world mesh. Those sections are unique, in that they don't have a valid section number, which is always 0. However, they are always in the sections immediately following the materials. Each mesh header takes up 4 sections - the main header, the surface offsets, the mesh info table, and the unknown table.


==== Main Header ====
=== World Model Definition ===
 
The world geometry definitions always appear immediately following the materials section. Each definition is a sequence of four sections. All four of these sections are identical to their structure in the previous MREA formats in both MP3 and DKCR, so check those pages:
 
* [[MREA (Metroid Prime)#World Geometry|World Model Header]]
* [[Geometry (Metroid Prime)#Surface Offsets|Surface Definitions]]
* [[Geometry (Metroid Prime)#Surface Group IDs|Surface Group IDs]]
* [[Geometry (Metroid Prime)#Surface Lookup Table|Surface Lookup Table]]
 
=== Area Octree ===
''See [[AROT (MREA Section)]]''
 
=== Surface Group Bounding Boxes ===
''See [[MREA (Metroid Prime 2)#Surface Group Bounding Boxes]]''
 
=== GPU Data ===
''See [[Geometry (Metroid Prime)]] or [[Geometry (Donkey Kong Country Returns)]]''
 
This section contains the GPU buffer data used to render world geometry. This is generally the same as in previous games, with the following sequence of sections repeated once per world model:
 
* '''Vertices''': Always floats; world geometry vertices are never packed into shorts.
* '''Normals''': Always floats; world geometry normals are never packed into shorts.
* '''Colors''': Contains 32-bit RGBA8 colors. This section is not used in any official assets and is always zeroed out.
* '''Float UV Coordinates''': In Metroid Prime 3, this is the only UV coordinates section, so it's used for everything.
* '''Short UV Coordinates''': Only appears in Donkey Kong Country Returns; can be used for anything, not only lightmaps as in previous games.
* '''Surfaces''': One section per surface. For details on the structure of these sections check [[Geometry (Metroid Prime)#Surface|Geometry (Metroid Prime)]] page for MP3 and the [[Geometry (Donkey Kong Country Returns)#Surface|Geometry (Donkey Kong Country Returns)]] page for DKCR.
 
=== Dependencies ===
 
{{research|minor|How does this section work with SCGN?}}
 
This section is basically a list of all resources that this area depends on, not unlike a [[DGRP (File Format)|DGRP]] file. After the initial dependency list, there's a second array which provides a list of offsets into the dependency list. These offsets are used to indicate which dependencies are needed for individual script layers, with the last offset pointing to resources that are used by the area itself as a whole (world geometry textures and the [[#Path|PATH]]/[[#Portal Area|PTLA]]/[[#Static Geometry Map|EGMC]] assets).
 
[[STRM (File Format)|STRM]] assets are not included in this list.


{| class="wikitable"
{| class="wikitable"
! Type
! Type
! Description
! Count
! Name
! Notes
! Notes
|-
|-
| long
| u32
| '''Unknown'''
| 1
| Most likely visor flags in MP3, unknown in DKCR
| '''Dependency Count'''
| Count of dependencies in the next array.
|-
| [[#Dependency|Dependency]]
| ''Dependency Count''
| '''Dependency List'''
| List of resources used by this area.
|-
| u32
| 1
| '''Offset Count'''
| Count of offsets in the next array. Should be equal to the script layer count + 1.
|-
|-
| CTransform4f
| u32
| '''Transformation Matrix'''
| ''Offset Count''
| Meshes location in world space
| '''Dependency List Offsets'''
| Each element is an offset into the dependency list to indicate where the dependencies for individual script layers begins. There's one offset per script layer, then the last offset points to resources used by the area itself outside of script layers.
|-
|-
| CAABox
| colspan=5 {{unknown|End of dependencies section}}
| '''Bounding Box'''
| Likely used for Depth sorting as in previous games.
|}
|}


==== Surface Offsets ====
==== Dependency ====


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Type
! Description
! Count
! Notes
! Name
|-
| 0x0
| Asset ID
| 1
| '''Dependency Asset ID'''
|-
|-
| long
| 0x8
| '''Surface count''' (SC)
| char
|
| 4
| '''Dependency Asset Type'''
|-
|-
| long
| 0xC
| '''Surface Offsets[SC]'''
| colspan=3 {{unknown|End of dependency}}
| Relative to the start first surface (i.e. the first offset points the the end of the first surface)
|}
|}


==== Mesh IDs ====
=== Script Layers ===


The next section contains a table of shorts that associates each surface in the mesh with a mesh ID. It starts with a 16-bit count (which always matches the mesh's surface count). The full extent of what exactly the data is and what it's used for is unknown, but it's accessed by various other components to identify world geometry.
{{todo|This section is known, needs documentation written}}
 
=== Generated Script Objects ===
 
{{todo|Almost identical to script layers but there are some slight differences in the header}}
 
This section is an extra [[#Script Layers|script layer]] that contains generated objects (anything spawned by a Generator).
 
=== Collision ===
 
''Main article: [[Area Collision (File Format)]]''
 
=== Lights ===
''See [[Lights (Metroid Prime)]]
 
=== Unknown Section (LLTE) ===
 
This section always contains just a single 32-bit 1. It doesn't appear to do anything, so the purpose of this section is unknown.
 
=== Visibility Tree ===
 
{{research|major|This section is largely unknown}}
 
=== RSO Module List ===
 
This section is a list of RSO modules used by script objects in the area. Like the dependencies section, there's also a list of offsets to indicate which RSOs are used by each script layer.


{| class="wikitable"
{| class="wikitable"
! Type
! Type
! Description
! Count
! Name
! Notes
! Notes
|-
|-
| long
| u32
| {{unknown|'''Unknown'''}}
| 1
| Usually a very similar value to the mesh ID, sometimes the same number
| '''RSO Count'''
| Count of RSO modules listed in the next array.
|-
|-
| long
| string
| '''Mesh ID'''
| ''RSO Count''
|  
| '''RSO Module List'''
| This is a series of zero-terminated strings. Each string is the filename of a .rso file.
|-
| u32
| 1
| '''Offset Count'''
| Count of offsets in the next array. Should be equal to the script layer count * 2.
|-
| u32
| ''Offset Count''
| '''RSO Module List Offsets'''
| Each element is an offset into the RSO module list to indicate which modules are required by each script layer. For some reason there are two offsets per script layer.
|-
| colspan=4 {{unknown|End of RSOs section}}
|}
|}


There is one more section after this one before the next mesh header begins that contains unknown data.
=== Path ===


=== AROT ===
This section only contains a single [[PATH (File Format)|PATH]] asset ID.
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 ===
{| class="wikitable"
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
 
! Count
{|class="wikitable"
! Name
!Type
!Description
!Notes
|-
|-
|CAABox
| Asset ID
|'''Axis Aligned Bounding Box'''
| 1
|Used to assist depth sorting, and/or collision
| '''Area PATH Resource'''
|-
|-
|long
| colspan=3 {{unknown|End of section}}
|'''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) ===
=== Portal Area ===
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:
This section only contains a single [[PTLA (File Format)|PTLA]] asset ID.
==== Vertices ====
The vertices are always 32bit floats, even in DKCR


==== Normals ====
{| class="wikitable"
The normals are always 32bit floats.
! Type
! Count
! Name
|-
| Asset ID
| 1
| '''Area PTLA Resource'''
|-
| colspan=3 {{unknown|End of section}}
|}


==== Colors ====
=== Static Geometry Map ===
Usually 0 filled and completely unused, it's stored in MREA simply for completeness.


==== Float Texcoords ====
This section only contains a single [[EGMC (File Format)|EGMC]] asset ID.
Metroid Prime 3 uses these exclusively, even for lightmaps, which simplifies UV handling quite a bit.


==== Short Texcoords ====
{| class="wikitable"
This is only used in DKCR and can be used for anything, not just for lightmaps
! Type
 
! Count
==== Submeshes ====
! Name
The submesh format is exactly the same as the Geometry formats found in Metroid Prime 3 and DKCR.
|-
| Asset ID
| 1
| '''Area EGMC Resource'''
|-
| colspan=3 {{unknown|End of section}}
|}


[[Category:File Formats]]
[[Category:File Formats]]
[[Category:Metroid Prime 3: Corruption]]
[[Category:Metroid Prime 3: Corruption]]
[[Category:Donkey Kong Country Returns]]
[[Category:Donkey Kong Country Returns]]
Anonymous user