Geometry (Donkey Kong Country Returns): Difference between revisions

m
no edit summary
>Aruki
(Created page with "The format for ''geometry'' in Donkey Kong Country Returns appears in the CMDL and MREA formats. __TOC__ ==...")
 
>Aruki
mNo edit summary
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
The format for ''geometry'' in Donkey Kong Country Returns appears in the [[CMDL (Donkey Kong Country Returns)|CMDL]] and [[MREA (Metroid Prime 3)|MREA]] formats.
The format for ''geometry'' in Donkey Kong Country Returns appears in the [[CMDL (Donkey Kong Country Returns)|CMDL]] and [[MREA (Metroid Prime 3)|MREA]] formats.
{{research|minor|There is an unknown value in the surface header, and the possible vertex formats should be documented.}}


__TOC__
__TOC__


=== Geometry ===
== Format ==


An important thing to note off the bat is that both CMDL and MREA files are split up into a number of 32-byte-aligned ''sections''; their respective headers both declare a section count, and list the sizes of each section contained in the file. This is required to navigate to different parts of the file, and is required in order to read the geometry data correctly. Sections are generally split based on the type of data contained in them, so one section might contain vertex coordinates, while another contains a surface (submesh) definition. For the purposes of this article, each subheader will mark the start of a new section; use that as your cue to advance to the next one. Check the [[CMDL (Donkey Kong Country Returns)|CMDL]] or [[MREA (Metroid Prime 3)|MREA]] pages for more info on how the sections work.
An important thing to note off the bat is that both CMDL and MREA files are split up into a number of 32-byte-aligned ''sections''; their respective headers both declare a section count, and list the sizes of each section contained in the file. This is required to navigate to different parts of the file, and is required in order to read the geometry data correctly. Sections are generally split based on the type of data contained in them, so one section might contain vertex coordinates, while another contains a surface (submesh) definition. For the purposes of this article, each subheader will mark the start of a new section; use that as your cue to advance to the next one. Check the [[CMDL (Donkey Kong Country Returns)|CMDL]] or [[MREA (Metroid Prime 3)|MREA]] pages for more info on how the sections work.
Line 11: Line 13:
For vertex attributes, note that there's no count value present anywhere. If you want a rough count, you can divide the size of that attribute's section by the attribute's size; this approach doesn't account for padding, however.
For vertex attributes, note that there's no count value present anywhere. If you want a rough count, you can divide the size of that attribute's section by the attribute's size; this approach doesn't account for padding, however.


==== Vertex Coordinates ====
=== Vertex Coordinates ===


Vertex coords can be stored as either floats or signed shorts, depending whether flag 0x20 is set in the header. If they're shorts, then they need to be divided by 0x2000 to get the corresponding float value. Since they're signed numbers, that means that 0 to 0x7FFF correspond to the range 0.0-4.0, and 0x8000 to 0xFFFF correspond to the range -4.0-0.0.
In the CMDL format, vertex coords can be stored as either floats or signed shorts, depending whether flag 0x20 is set in the header. If they're shorts, then they need to be divided by 0x2000 to get the corresponding float value. Since they're signed numbers, that means that 0 to 0x7FFF correspond to the range 0.0-4.0, and 0x8000 to 0xFFFF correspond to the range -4.0-0.0. In the MREA format, these will always be stored as floats.


==== Normals ====
=== Normals ===


Vertex normals are usually stored as shorts. To get the corresponding float value, read as a signed short and divide by 0x4000.
In the CMDL format, vertex normals are usually stored as shorts. To get the corresponding float value, read as a signed short and divide by 0x4000. In the MREA format, normals are never packed into shorts and are always stored as floats.


==== Vertex Color ====
=== Vertex Color ===


Normally unused, so this section is typically empty and zeroed out.
Normally unused, so this section is typically empty and zeroed out.


==== Float UV Coordinates ====
=== Float UV Coordinates ===


These are stored as a sequence of two floats.
These are stored as a sequence of two floats.


==== Short UV Coordinates ====
=== Short UV Coordinates ===


Like the short vertex coordinates, these are stored as signed shorts that should be divided by 0x2000 to get the corresponding float value. The short UVs section has received a fairly significant increase in usage in DKCR compared to the Prime series; in the Prime games, they were generally only used for lightmaps, whereas in DKCR they're often used by pretty much anything.
Like the short vertex coordinates, these are stored as signed shorts that should be divided by 0x2000 to get the corresponding float value. The short UVs section has received a fairly significant increase in usage in DKCR compared to the Prime series; in the Prime games, they were generally only used for lightmaps, whereas in DKCR they're often used by pretty much anything.


==== Surface Definitions ====
=== Surface Definitions ===


This section is very small and simple; it simply declares a surface count and then lists the offsets to the end of each surface. Following this section, there'll be one additional section per surface.
This section is very small and simple; it simply declares a surface count and then lists the offsets to the end of each surface. Following this section, there'll be one additional section per surface.
Line 54: Line 56:
|}
|}


==== Surface ====
=== Surface ===


There will be one of these sections per surface. Each surface starts with a small 32-byte header; after that, the primitive data begins.
There will be one of these sections per surface. Each surface starts with a small 32-byte header; after that, the primitive data begins.
Line 86: Line 88:
| u32
| u32
| 1
| 1
| {{unknown|Unknown}}
| '''Model Pointer Storage'''
| Always 0?}}
| Always 0. This is filled in at runtime with a pointer to the owner model.
|-
|-
| 0x14
| 0x14
| u32
| u32
| 1
| 1
| {{unknown|Unknown}}
| '''Next Surface Pointer Storage'''
| Always 0?
| Always 0. This is filled in at runtime with a pointer to the next sibling surface.
|-
|-
| 0x18
| 0x18
| u16
| u16
| 1
| 1
| {{unknown|Unknown}}
| '''Skin Matrix Bank Index'''
| Value varies, but is sometimes 0xFFFF
|  
|-
|-
| 0x1A
| 0x1A
Line 117: Line 119:
| 1
| 1
| '''Visibility Group Index'''
| '''Visibility Group Index'''
| This value will be 0xFF if this surface isn't in a visibility group. (Always 0xFF in MREA.)
|-
|-
| 0x1E
| 0x1E
| u16
| u8
| 1
| 1
| '''UV Array Index'''
| '''UV Array Index'''
| If 0, this surface uses the float UVs array; if 1, this surface uses the short UVs array
| If 0, this surface uses the float UVs array; if 1, this surface uses the short UVs array
|-
| 0x1F
| u8
| 1
| '''Extra Data Size'''
| Amount of space taken up by extra data. Always 0 on CMDLs, 0x18 on MREAs.
|-
|-
| 0x20
| 0x20
| colspan=3 {{unknown|End of surface header; primitive data starts}}
| u8
| ''Extra Data Size''
| '''Extra Data'''
| Empty on CMDL; contains a bounding box used for depth sorting on MREA.
|-
| colspan=5 {{unknown|End of surface header; pad to multiple of 32 before primitive data starts}}
|}
|}


Line 161: Line 175:
| Points
| Points
|}
|}
[[Category:File Formats]]
[[Category:Donkey Kong Country Returns]]
Anonymous user