Skip to content

SURFACE

Jocelyn Beedie edited this page Feb 21, 2021 · 7 revisions

SURFACE

This page is under development

Format

struct SurfaceObject {
    TransformationHeader transform;
    uint32_t num_vertices;
    Vector3 vertices[num_vertices];
    uint32_t num_unk0;
    char unk0[24][num_unk0]; // 32 bytes on PS2
    uint32_t num_unk1;
    char unk1[24][num_unk1]; // 32 bytes on PS2
    uint32_t num_surfaces;
    Surface surfaces[num_unk2]; // 140 bytes each
    uint32_t num_curves;
    Curve curves[num_curves]; // 8 bytes each
    uint32_t num_normals;
    Vector3 normals[num_normals]; // 12 bytes each
    uint32_t num_unk5;
    char unk5[104][num_unk5]; // 112 bytes on PS2, contains a 4x4 matrix
    uint32_t num_unk6;
    uint16_t unk6[num_unk6]; // Index into either surfaces or unk5
    uint32_t num_unk7;
    char unk7[24][num_unk7]; // 32 bytes on PS2
    uint8_t weird;
    uint32_t num_unk8;
    char unk8[???][num_unk8]; // still figuring this one out
    uint32_t num_unk9;
    uint32_t unk9[num_unk9];
};

Surface structure

This represents a surface

struct Surface {
    Vector2 texcoords[8]; // texture coordinates
    float unknown2[12]; // More unknown floats; these are constrained to [0.0, 1.0]
    uint16_t normal_indices[4];
    uint16_t curve_indices[4];
    uint32_t curve_order; // Curve order
    char unknown3[32];
    uint32_t index_n6; // Index into unk6
    int32_t materialanim_id; // ID of a MATERIALANIM
};

Each value in Surface.curve_indices is an index into SurfaceObject.curves.

Curve Order

Assume that we have generated an array Curve curves[4] from Surface.curve_indices.

The Surface.curve_order value determines the direction of each curve. When curve_order is 0, then the curves will have a default order. In the default order, curve[0].p2 == curve[1].p1, curve[1].p2 == curve[2].p1, curve[2].p2 == curve[3].p1, and curve[3].p2 == curve[0].p1. These curves will form a square-ish shape from which the surface will be generated.

When Surface.curve_order is not 0, then certain curves will be reversed. This is so that multiple surfaces can share the same curves regardless of orientation. When a curve is reversed, then Curve.p1 and Curve.p2 will be swapped, and Curve.p1_t and Curve.p2_t will be swapped. Surface.curve_order is actually a flag value with the format 0bABCD0. When A is set, curve[0] will be reversed; when B is set, curve[1] will be reversed, etc.

Curve structure

This is a degree 3 Bézier curve.

struct Curve {
    uint16_t p1;
    uint16_t p2;
    uint16_t p1_t;
    uint16_t p2_t;
};

Each element is an index into SurfaceObject.vertices.

Clone this wiki locally