-
Notifications
You must be signed in to change notification settings - Fork 1
SPLINE
SPLINE files represent a 3D curve built from B-Splines.
struct Spline {
TransformationHeader transform; // Subtype is 56, 184, 312, or 440; 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
.
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
.
struct SplineSubsection {
Vector3 point1;
Vector3 point2;
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.