Geometry (Donkey Kong Country Returns): Difference between revisions

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
No edit summary
Line 3: Line 3:
__TOC__
__TOC__


=== Geometry ===
== Geometry ==


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


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


Vertex normals are usually stored as shorts. To get the corresponding float value, read as a signed short and divide by 0x4000.
Vertex normals are usually stored as shorts. To get the corresponding float value, read as a signed short and divide by 0x4000.


==== 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 54:
|}
|}


==== 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.
Anonymous user