Skip to content
Jocelyn Beedie edited this page Jun 10, 2020 · 3 revisions

SPLINE files

SPLINE files represent a 3D curve built from B-Splines.

Spline format

struct Spline {
    float unknown[4]; // Somehow related to transforms
    float transform[16]; // 4x4 transformation matrix
    char junk[16];
    uint16_t unknown2; // Always 2
    uint16_t unknown3; // Always either 56, 184, 312, or 440. Has no effect on format.
    uint32_t num_vertices;
    Vector3 vertices[num_vertices];
    uint32_t num_sections;
    SplineSection sections[num_sections];
    float unknown4[4]; // Always {1.0, 0.0, 0.0, 1.0}
    float length; // The total length of the curve
}

Each spline is split into multiple sections. The lengths of all of its sections always add up to length.

SplineSection

struct SplineSection {
    uint32_t p1;
    uint32_t p2;
    uint32_t p1_t;
    uint32_t p2_t;
    uint32_t unknown; // Always either 0x10000000 or 0x30000000; has no effect on format
    float section_length; // The length of this section
    SplineSubsection subsections[8];
}

SplineSection represents a section of the spline. Each section is a 3-dimensional degree 3 B-Spline with control points [p1, p1_t, p2_t, p2]. The values of p1, p2, p1_t, and p2_t are indices into the vertices array defined in Spline.

Sections also have eight pre-calculated subsections, which can be used to get a fast but rough approximation of the spline. The lengths of each section's subsections always adds up to section_length.

SplineSubsection

struct SplineSubsection {
    float point1[3];
    float point2[3];
    float subsection_length; // The length of this subsection
}

If there is a subsection after this subsection, then point2 of this subsection is equivalent to point1 of the next subsection.

The length of each subsection is approximately the distance between point1 and point2, but differs slightly because of the curvature.

Clone this wiki locally