MREA (Metroid Prime 3): Difference between revisions

>Aruki
>Aruki
 
(14 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 147: Line 147:
|}
|}


<code>WOBJ</code> can be listed multiple times, but its section index is always 0. Every other section number always appears in every MREA file once (none are optional). Here are all 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"
Line 155: Line 155:
! DKCR
! DKCR
|-
|-
| <code>AABB</code>
| <code>WOBJ</code>
| Surface Group Bounding Boxes
| [[#Materials|Materials]] + [[#World Model Definition|World Model Definition]]
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>APTL</code>
| <code>ROCT</code>
| Portal Area
| [[#Area Octree|Area Octree]]
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| <code>COLI</code>
| <code>AABB</code>
| Collision
| [[#Surface Group Bounding Boxes|Surface Group Bounding Boxes]]
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>DEPS</code>
| <code>GPUD</code>
| Dependencies
| [[#GPU Data|World Geometry GPU Data]]
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>EGMC</code>
| <code>DEPS</code>
| Static Geometry Map
| [[#Dependencies|Dependencies]]
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| <code>GPUD</code>
| <code>SOBJ</code>
| World Geometry GPU Data
| [[#Script Layers|Script Layers]]
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>LITE</code>
| <code>SGEN</code>
| Lights
| [[#Generated Script Objects|Generated Script Objects]]
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>LLTE</code>
| <code>COLI</code>
| {{unknown|Unknown}}
| [[#Collision|Collision]]
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>PFL2</code>
| <code>LITE</code>
| Path
| [[#Lights|Lights]]
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| <code>PVS!</code>
| <code>LLTE</code>
| Visibility Tree
| {{unknown|[[#Unknown Section (LLTE)|Unknown]]}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>ROCT</code>
| <code>PVS!</code>
| Area Octree
| [[#Visibility Tree|Visibility Tree]]
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>RSOS</code>
| <code>RSOS</code>
| RSO Module List
| [[#RSO Module List|RSO Module List]]
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>SGEN</code>
| <code>PFL2</code>
| Generated Script Objects
| [[#Path|Path]]
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| <code>SOBJ</code>
| <code>APTL</code>
| Script Layers
| [[#Portal Area|Portal Area]]
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| <code>WOBJ</code>
| <code>EGMC</code>
| World Geometry Declaration (always 0, points to the materials section)
| [[#Static Geometry Map|Static Geometry Map]]
| {{check}}
| {{check}}
| {{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)]]''
 
Identical to the material format found in [[CMDL (File Format)|CMDL]]. There is just one materials section which is shared across all world models.
 
=== 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]]''


=== Mesh Headers ===
=== GPU Data ===
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.
''See [[Geometry (Metroid Prime)]] or [[Geometry (Donkey Kong Country Returns)]]''


==== Main Header ====
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.
|-
|-
| CTransform4f
| u32
| '''Transformation Matrix'''
| 1
| Meshes location in world space
| '''Offset Count'''
| Count of offsets in the next array. Should be equal to the script layer count + 1.
|-
|-
| CAABox
| u32
| '''Bounding Box'''
| ''Offset Count''
| Likely used for Depth sorting as in previous games.
| '''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.
|-
| colspan=5 {{unknown|End of dependencies section}}
|}
|}


==== 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 ===
 
{{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}}


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.
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