BezierSpline
A class in Root.Township, Alta.Bezier.
A cubic Bezier spline component: control points in groups of three per curve, with free, aligned or mirrored handles and optional looping. Used by spline displays, terrain splines, forest spline instructions and some effects.
- Listed in Utilities and other Alta namespaces
- Inherits or implements
MonoBehaviour,IInstructionResult - Attributes
SelectionBase
Constructors
| Member | What it is |
|---|---|
BezierSpline() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
SplineChangedHandler Changed | Called whenever the spline changes. |
3 private and internal fields
| Member | What it is |
|---|---|
private bool isLooping | Backing field for IsLooping. |
private BezierControlPointMode[] modes | Handle mode per curve joint (free, aligned, mirrored), one more entry than there are curves. |
private Vector3[] points | Local-space control points: each curve uses four, sharing its end point with the next curve. |
Properties
Methods
| Member | What it is |
|---|---|
void AddCurve() | Adds one more curve to the end, one unit apart along X, and keeps the loop closed if looping. |
void AddDisplay(GameObject display) | Instantiates a display prefab under the spline and generates every SplineDisplay in it. |
static BezierSpline Create(params Vector3[] points) | Creates a game object with a spline from the given points. Handle modes aren't set, so editing may fail until Reset (probably). |
Vector3 GetControlPoint(int index) | A control point in local space. |
BezierControlPointMode GetControlPointMode(int index) | Handle mode for the control point's joint; free if unset. |
Vector3 GetDirection(float t) | Normalized world-space direction at t (0 to 1 along the whole spline). |
Vector3 GetPoint(float t) | World-space point at t (0 to 1 along the whole spline). |
Vector3 GetPointLocal(int curve, float t) | Local-space point at t along the whole spline, or at t on one curve. |
Vector3 GetPointLocal(float t) | Local-space point at t along the whole spline, or at t on one curve. |
Vector3 GetVelocity(float t) | World-space derivative at t along the whole spline. |
void Insert(int index) | Inserts a new curve at a joint index. |
void Refresh() | Raises Changed. |
void Reset() | Resets to one straight curve along X. |
void SetControlPoint(int index, Vector3 point) | Moves a control point; moving a joint also moves its handles, and the handle mode is enforced. |
void SetControlPointMode(int index, BezierControlPointMode mode) | Sets the handle mode of a joint and enforces it. |
3 private and internal methods
| Member | What it is |
|---|---|
private void EnforceMode(int index) | Moves the opposite handle of a control point so it matches the point's mode (mirrored or aligned). Free points are left alone. |
private void OnChanged() | Raises Changed. Called after any edit to points, modes or looping. |
private void Alta.Static.IInstructionResult.Undo() | Explicit IInstructionResult implementation: destroys the spline's GameObject. |
Used in
Members of other types that take, return or hold a BezierSpline: