MD Package Technical & APi Documentation
MDM_SplineHandler
Namespace: MDPackage.Modifiers.Splines
MDM_SplineHandler is a complete spline-based solution for managing quadratic bezier curves. Use this mono class to create quadratic bezier splines.
Read more here (Online documentation slide)
Properties
// Readonly list of the created spline chunks (Each chunk consists of a starting point A, control point B and end point C)
public IReadOnlyList<SplineChunk> SplineChunks { get; }
// Resolution of a single bezier spline
public int SplineResolution { get; set; }
// Add an interface to the list to listen to the spline changes at runtime/ in editor
public HashSet<IMDM_SplineListener> SplineListeners { get; }
Public Methods
// Add a new, default spline chunk at the end of the spline chunk list
public void AddSplineChunkInChain()
// Add a new spline chunk with customized data at the end of the spline chunk list
public void AddSplineChunk(SplineChunk newSplineChunk)
// Insert a new spline chunk at position in the list
public void InsertSplineChunk(int insertAtIndex)
// Remove the last spline chunk in the list
public void RemoveLastSplineChunk()
// Remove specific line chunk in the list by index
public void RemoveSplineChunk(int splineChunkIndex)
// Flip the entire spline by the given option (FlipX, FlipY, FlipZ)
public void FlipSpline(SplineFlipOption splineFlipOption)
// Invokes the SplineListeners when the spline has been changed
public void SplineHasChanged()

// Returns an array of calculated bezier points on the given spline chunk index
public Vector3[] CalculateQuadraticBezierPoints(int splineChunkIndex, bool relatedToWorld = true)
// Try to snap all the spline points to the ground using raycasting
public void TryToSnapAllSplinePoints(LayerMask includeLayers)
// Rotate bezier point formula
public static Quaternion CalculateQuadraticBezierRotation(Quaternion q0, Quaternion q1, Quaternion q2, float t)
// Calculate bezier point formula
public static Vector3 CalculateQuadraticBezierPoint(float t, Vector3 p0, Vector3 p1, Vector3 p2)