CGFX: Difference between revisions
Planetarian (talk | contribs) m →SOBJ |
m Remove duplicate offset from DICT header |
||
(17 intermediate revisions by 7 users not shown) | |||
Line 19: | Line 19: | ||
|- | |- | ||
| 0x6 | | 0x6 | ||
| | | 0x2 | ||
| CGFX header size | | CGFX header size | ||
|- | |- | ||
| | | 0x8 | ||
| | | 0x4 | ||
| | | Revision | ||
|- | |- | ||
| 0xC | | 0xC | ||
Line 83: | Line 83: | ||
|- | |- | ||
| 3 | | 3 | ||
| | | Materials | ||
|- | |- | ||
| 4 | | 4 | ||
| | | Shaders | ||
|- | |- | ||
| 5 | | 5 | ||
Line 107: | Line 107: | ||
|- | |- | ||
| 11 | | 11 | ||
| | | Visibility animations | ||
|- | |- | ||
| 12 | | 12 | ||
| | | Camera animations | ||
|- | |- | ||
| 13 | | 13 | ||
| | | Light animations | ||
|- | |- | ||
| 14 | | 14 | ||
| | | Emitters | ||
|- | |- | ||
| 15 | | 15 | ||
Line 146: | Line 146: | ||
|- | |- | ||
| 0xC | | 0xC | ||
| 0x4 | |||
| ? | |||
|- | |||
| 0x10 | | 0x10 | ||
| 0x2 | |||
| Unknown. Seems to be shifted left by 4 bits in the source. | |||
|- | |||
| 0x12 | |||
| 0xA | |||
| ? | | ? | ||
|} | |} | ||
Line 175: | Line 183: | ||
| 0xC | | 0xC | ||
| 0x4 | | 0x4 | ||
| | | Offset (self-relative) to object | ||
|} | |} | ||
Line 317: | Line 325: | ||
| 0x20 | | 0x20 | ||
| 0xC | | 0xC | ||
| | | Mesh position offset (X/Y/Z floats) | ||
|- | |- | ||
| 0x2C | | 0x2C | ||
Line 427: | Line 435: | ||
|} | |} | ||
Vertex groups come in a number of different formats. Typically the first vertex group entry is of format 0x40000002 and contains the actual vertex array. | |||
Vertex group format 0x40000002: | |||
Vertex group format | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 440: | Line 447: | ||
| 0x0 | | 0x0 | ||
| 0x4 | | 0x4 | ||
| Flags ( | | Flags (0x40000002) | ||
|- | |- | ||
| 0x4 | | 0x4 | ||
| 0x4 | | 0x4 | ||
| | | ? | ||
|- | |- | ||
| 0x8 | | 0x8 | ||
Line 475: | Line 482: | ||
|- | |- | ||
| 0x24 | | 0x24 | ||
| | | 0x4 | ||
| | | Vertex stride/size in bytes (see below) | ||
|- | |- | ||
| 0x28 | | 0x28 | ||
| 0x4 | | 0x4 | ||
| | | Unknown3 count | ||
|- | |- | ||
| 0x2C | | 0x2C | ||
| 0x4 | | 0x4 | ||
| | | Offset (self-relative) to component declaration offset array | ||
|} | |} | ||
Vertex | Each mesh's primary vertex group contains an array of vertex component declaration objects, defining the order and parameters for each of a vertex's components. | ||
Vertex component declaration: | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 513: | Line 506: | ||
| 0x0 | | 0x0 | ||
| 0x4 | | 0x4 | ||
| Flags ( | | Flags (0x40000001) | ||
|- | |- | ||
| 0x4 | | 0x4 | ||
| 0x4 | | 0x4 | ||
| | | Vertex component type (see below) | ||
|- | |- | ||
| 0x8 | | 0x8 | ||
Line 533: | Line 526: | ||
| 0x14 | | 0x14 | ||
| 0x4 | | 0x4 | ||
| | | ? | ||
|- | |- | ||
| 0x18 | | 0x18 | ||
| 0x4 | | 0x4 | ||
| | | ? | ||
|- | |- | ||
| 0x1C | | 0x1C | ||
Line 548: | Line 541: | ||
|- | |- | ||
| 0x24 | | 0x24 | ||
| | | 0x1 | ||
| | | Component data type (see below) | ||
|- | |||
| 0x25 | |||
| 0x1 | |||
| ? | |||
|- | |||
| 0x26 | |||
| 0x1 | |||
| ? | |||
|- | |||
| 0x27 | |||
| 0x1 | |||
| ? | |||
|- | |- | ||
| 0x28 | | 0x28 | ||
| 0x4 | | 0x4 | ||
| | | Number of values in this component (e.g. XYZ->3, UV->2) | ||
|- | |- | ||
| 0x2C | | 0x2C | ||
| 0x4 | | 0x4 | ||
| | | Multiplier for this component's values (float) | ||
|- | |||
| 0x30 | |||
| 0x4 | |||
| Position of this component within vertex stride | |||
|} | |} | ||
Vertex formats: | Vertex formats with bone data support multiple bone assignment. In this case, the sum of all bone weights is 0x64. | ||
Vertex component types: | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! Vertex | ! Value | ||
! Type | |||
|- | |||
| 0x00 | |||
| Position | |||
|- | |||
| 0x01 | |||
| Normal | |||
|- | |||
| 0x02 | |||
| ? (unobserved) | |||
|- | |||
| 0x03 | |||
| Color | |||
|- | |||
| 0x04 | |||
| UV0 | |||
|- | |||
| 0x05 | |||
| UV1 | |||
|- | |||
| 0x06 | |||
| ? (unobserved, possibly UV2) | |||
|- | |||
| 0x07 | |||
| Weight | |||
|- | |||
| 0x08 | |||
| Index | |||
|} | |||
Vertex component data types: | |||
{| class="wikitable" | |||
|- | |- | ||
! Value | |||
! Type | |||
|- | |- | ||
| | | 0x00 | ||
| | | sbyte | ||
|- | |- | ||
| | | 0x01 | ||
| | | byte | ||
|- | |- | ||
| | | 0x02 | ||
| | | short | ||
|- | |- | ||
| | | 0x03 | ||
| | | ? (unobserved, possibly ushort) | ||
|- | |- | ||
| | | 0x04 | ||
| | | ? (unobserved, possibly int) | ||
|- | |- | ||
| | | 0x05 | ||
| | | ? (unobserved, possibly uint) | ||
|- | |- | ||
| | | 0x06 | ||
| | | float | ||
|} | |} | ||
Vertex | Vertex components are stored as one of the above data types, and the vertex component declaration contains a multiplier that adapts the values to the float version which the game will use. | ||
For example, color RGBA values are stored as bytes, and the multiplier converts them from 0-255 to 0-1.0, and position components using short values are normalized via the multiplier to take advantage of the entire short value range. | |||
== TXOB == | == TXOB == | ||
Line 611: | Line 655: | ||
| 0x4 | | 0x4 | ||
| Magic "TXOB" | | Magic "TXOB" | ||
|- | |||
| 0x8 | |||
| 0x8 | |||
| ? | |||
|- | |- | ||
| 0xC | | 0xC | ||
Line 793: | Line 841: | ||
CANMs are used to store skeletal animation data. | CANMs are used to store skeletal animation data. | ||
== Tools == | |||
* Every File Explorer | |||
* Ohana3DS and its forks | |||
* SPICA | |||
== Links == | == Links == | ||
* Another CGFX Format Description: [http://florian.nouwt.com/wiki/index.php/CGFX_(File_Format) http://florian.nouwt.com/wiki/index.php/CGFX_(File_Format)] | * Another CGFX Format Description (Archived Page): [https://web.archive.org/web/20150511211029/http://florian.nouwt.com/wiki/index.php/CGFX_(File_Format) http://florian.nouwt.com/wiki/index.php/CGFX_(File_Format)] | ||
[[Category:File formats]] |