Difference between revisions of "CMDL (Metroid Prime)"
(→Materials) |
(→Tools) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
== Format == | == Format == | ||
− | CMDL 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 | + | CMDL files are split up into a number of 32-byte aligned ''data sections''. Every data section both starts and ends on a 32-byte boundary. These are used to separate different parts of the file; different data sections typically indicate different sets of data. The header declares the data section count and the size of each one; using these is the only way to navigate the file. |
=== Header === | === Header === | ||
Line 13: | Line 13: | ||
{| class="wikitable" | {| class="wikitable" | ||
! Offset | ! Offset | ||
− | ! | + | ! Type |
− | ! | + | ! Count |
+ | ! Name | ||
+ | ! Notes | ||
|- | |- | ||
| 0x0 | | 0x0 | ||
− | | | + | | u32 |
− | | '''Magic''' | + | | 1 |
+ | | '''Magic''' | ||
+ | | Always <code>0xDEADBABE</code>. | ||
|- | |- | ||
| 0x4 | | 0x4 | ||
− | | | + | | u32 |
− | | '''Version''' | + | | 1 |
+ | | '''Version''' | ||
+ | | See [[CMDL (File Format)|hub article]] for a list of possible version numbers. | ||
|- | |- | ||
| 0x8 | | 0x8 | ||
− | | | + | | u32 |
− | | '''Flags''' | + | | 1 |
+ | | '''Flags''' | ||
+ | | [[#Flags|See below]] | ||
|- | |- | ||
| 0xC | | 0xC | ||
− | | | + | | float |
− | | '''Axis- | + | | 6 |
+ | | '''Model Axis-Aligned Bounding Box''' | ||
+ | | | ||
|- | |- | ||
| 0x24 | | 0x24 | ||
− | | | + | | u32 |
− | | '''Section | + | | 1 |
+ | | '''Data Section Count''' | ||
+ | | Count of data sections in the file. | ||
|- | |- | ||
| 0x28 | | 0x28 | ||
− | | | + | | u32 |
− | | '''Material | + | | 1 |
+ | | '''Material Set Count''' | ||
+ | | Count of material sets in the model. There will be one materials section per set in the file. | ||
|- | |- | ||
| 0x2C | | 0x2C | ||
− | | | + | | u32 |
− | | '''Section | + | | ''Data Section Count'' |
− | | | + | | '''Data Section Sizes''' |
− | + | | | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
− | | 5 | + | | colspan=5 {{unknown|End of header; pad to 32 bytes before section data begins}} |
− | | | + | |
|} | |} | ||
Line 75: | Line 72: | ||
| 0 | | 0 | ||
| 0x1 | | 0x1 | ||
− | | | + | | Indicates the model is skinned (no ingame effect) |
|- | |- | ||
| 1 | | 1 | ||
Line 102: | Line 99: | ||
== Tools == | == Tools == | ||
− | * [https://drive.google.com/file/d/0B9MLV21H7SDvYXRtTWlFRGQ3ZjA/edit?usp=sharing | + | * [https://drive.google.com/file/d/0B9MLV21H7SDvYXRtTWlFRGQ3ZjA/edit?usp=sharing Aruki's CMDL Maxscript] will import CMDL files into 3DS Max. |
[[Category:File Formats]] | [[Category:File Formats]] |
Latest revision as of 00:12, 28 March 2017
This article is for the CMDL format from the Metroid Prime series. See CMDL (File Format) for the other revisions of this format.
The CMDL format is the model format used in the Metroid Prime series. The format's stayed relatively consistent throughout the trilogy, with modifications only really being made to the materials section.
Format
CMDL files are split up into a number of 32-byte aligned data sections. Every data section both starts and ends on a 32-byte boundary. These are used to separate different parts of the file; different data sections typically indicate different sets of data. The header declares the data section count and the size of each one; using these is the only way to navigate the file.
Header
Offset | Type | Count | Name | Notes |
---|---|---|---|---|
0x0 | u32 | 1 | Magic | Always 0xDEADBABE .
|
0x4 | u32 | 1 | Version | See hub article for a list of possible version numbers. |
0x8 | u32 | 1 | Flags | See below |
0xC | float | 6 | Model Axis-Aligned Bounding Box | |
0x24 | u32 | 1 | Data Section Count | Count of data sections in the file. |
0x28 | u32 | 1 | Material Set Count | Count of material sets in the model. There will be one materials section per set in the file. |
0x2C | u32 | Data Section Count | Data Section Sizes | |
End of header; pad to 32 bytes before section data begins |
Flags
Bit | Hex | Description |
---|---|---|
0 | 0x1 | Indicates the model is skinned (no ingame effect) |
1 | 0x2 | Toggle short normals |
2 | 0x4 | Enable short UV array |
Materials
See Materials (Metroid Prime) and Materials (Metroid Prime 3)
CMDL files can have multiple material sets; each set will get its own section. The main catch with reading materials is to mind the version number; extra values were added starting in version 3 (Echoes Demo).
The material format was completely revamped in Metroid Prime 3, but the way the format supports multiple material sets is the same.
Geometry
There are a couple little catches when reading the CMDL geometry format. First, the short UV array will always be completely empty (size of 0) whenever it's present; however, if the corresponding flag isn't set in the header, then the short UV section will be omitted entirely. Second, even though the header has a flag to indicate the format of the normals, the vertex format setting in the primitive data is what actually controls how the normals are read. Finally, an extra vertex attribute was added starting in version 4 that you'll need to watch out for; it precedes the position attribute.
Tools
- Aruki's CMDL Maxscript will import CMDL files into 3DS Max.