-
Notifications
You must be signed in to change notification settings - Fork 0
Face Format
All models in the face scene use a custom intermediate node format that's separate from the GeoLayouts in the rest of the game. This is possibly also what is used in 1080 Snowboarding, as concepts are shared between both games.
Each "Command" is the structure:
struct Command {
s32 tag;
u32 param_1;
u32 param_2;
float float_params[3];
};This lets each command encode two optional 32-bit integer/pointer params, and three float params (usually a vector of some sort).
Here is a basic "Object" display list:
MakeDynObj(D_SHAPE, ARBITRARY_SHAPE),
SetNodeGroup(ARBITRARY_SHAPE_VERTICES),
SetPlaneGroup(ARBITRARY_SHAPE_FACES),
SetMaterialGroup(ARBITRARY_SHAPE_MATERIALS),Vertex and face data are stored kind of freeform, as a DataGroup pointer that is initialized with the same enum value as referenced by SetNodeGroup or SetPlaneGroup
See Coordinate Spaces for how vertices are laid out in the scene compared to Blender's axes.
// Somewhere global
static struct GdVtxData arbitrary_vertices = { ARRAY_COUNT(vertex_data), 0x1, vertex_data }; // count of data, flag, data pointer
static struct GdFaceData arbitrary_faces = { ARRAY_COUNT(face_data), 0x1, face_data };
// ...
// Command List
MakeDynObj(D_DATA_GRP, ARBITRARY_SHAPE_VERTICES),
LinkWithPtr(&arbitrary_vertices),
MakeDynObj(D_DATA_GRP, ARBITRARY_SHAPE_FACES),
LinkWithPtr(&arbitrary_faces),
Vertices are just an array of s16[3], but faces are an array of s16[4], where [0] is the material index and [1...] is the actual triangle.
Materials are created using a command list by making a group with a list of materials (only color data). There is no "batching" across objects, so each shape has to store all the material data it will use here.
StartGroup(ARBITRARY_SHAPE_MATERIALS),
MakeDynObj(D_MATERIAL, 0), // enum value is discarded
SetId(0), // Face data references this ID
SetAmbient(0.0, 0.291, 1.0),
SetDiffuse(0.0, 0.291, 1.0),
MakeDynObj(D_MATERIAL, 0),
SetId(1),
SetAmbient(1.0, 0.0, 1.0),
SetDiffuse(1.0, 0.0, 1.0),
EndGroup(ARBITRARY_SHAPE_MATERIALS),
At one point this supported textured materials with a vertex format that also encoded UV data, but this feature has been all but gutted.