4
edits
>Aruki |
(Surface display list size) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 53: | Line 53: | ||
| u32 | | u32 | ||
| ''Surface Count'' | | ''Surface Count'' | ||
| '''Surface Offsets''' | | '''Surface End Offsets''' | ||
| Relative to the start address of the first surface. | | Relative to the start address of the first surface. | ||
|- | |- | ||
Line 83: | Line 83: | ||
|- | |- | ||
| 0x10 | | 0x10 | ||
| | |u32 | ||
| 1 | |1 | ||
| ''' | |'''Display List Size and Normal Hint''' | ||
| | |The top bit contains an unused "Normal Hint" while the remaining bits are used to specify the display list size. | ||
|- | |- | ||
| 0x14 | | 0x14 | ||
| u32 | | u32 | ||
| 1 | | 1 | ||
| '''Model Pointer Storage''' | | '''Parent Model Pointer Storage''' | ||
| Always 0; the game uses this space at runtime to store a pointer to the parent CCubeModel instance | | Always 0; the game uses this space at runtime to store a pointer to the parent CCubeModel instance | ||
|- | |- | ||
| 0x18 | | 0x18 | ||
| | | u32 | ||
| 1 | |||
| '''Next Surface Pointer Storage''' | | '''Next Surface Pointer Storage''' | ||
| Always 0; the game uses this space at runtime to store a pointer to the next surface | | Always 0; the game uses this space at runtime to store a pointer to the next surface | ||
Line 138: | Line 133: | ||
|} | |} | ||
The primitive data is a | The primitive data is a GX display list. Each primitive begins with a byte that contains the primitive type in the upper 5 bits, and the vertex format setting in the lower 3; see below for possible settings. After that is a 16-bit vertex count, followed by a series of 16-bit vertex attribute indices. | ||
Note that you'll need to check some settings on the material to read the primitive data properly; the material determines which vertex attributes are present. The material also determines whether the surface is using lightmaps; if it is, then the first UV coordinate will be read out of the short UV array instead of the float one. | Note that you'll need to check some settings on the material to read the primitive data properly; the material determines which vertex attributes are present. The material also determines whether the surface is using lightmaps; if it is, then the first UV coordinate will be read out of the short UV array instead of the float one. | ||
There is no primitive count value; you'll need to continue reading data until you hit the end of the | There is no primitive count value; you'll need to continue reading data until you hit the end of the display list. There are a couple values you can use for reference; either the surface's section size, or the surface's end offset. It was originally believed that the display list size was incorrect in a very small number of cases, however it's since been determined that the display list size '''is''' accurate is actually a u32 with the top bit being used as a "Normal Hint", the name of the bit was determined from symbols, but it's actual use has not been determined. Masking the field with 0x7FFFFFFF gives you the correct display list size that works in all cases. | ||
There are 7 primitive types supported by GX, indicated in the upper 5 bits of the flag value. Note that the game only ever actually uses triangles, triangle strips, and triangle fans; however, all of these primitives are supported by GX and are therefore supported by the game, and so they could be used in custom model files. | There are 7 primitive types supported by GX, indicated in the upper 5 bits of the flag value. Note that the game only ever actually uses triangles, triangle strips, and triangle fans; however, all of these primitives are supported by GX and are therefore supported by the game, and so they could be used in custom model files. |