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) publicIReadOnlyList<SplineChunk> SplineChunks { get; } // Resolution of a single bezier spline publicint SplineResolution { get; set; } // Add an interface to the list to listen to the spline changes at runtime/ in editor publicHashSet<IMDM_SplineListener> SplineListeners { get; }
Public Methods
// Add a new, default spline chunk at the end of the spline chunk list publicvoid AddSplineChunkInChain() // Add a new spline chunk with customized data at the end of the spline chunk list publicvoid AddSplineChunk(SplineChunk newSplineChunk) // Insert a new spline chunk at position in the list publicvoid InsertSplineChunk(int insertAtIndex) // Remove the last spline chunk in the list publicvoid RemoveLastSplineChunk() // Remove specific line chunk in the list by index publicvoid RemoveSplineChunk(int splineChunkIndex) // Flip the entire spline by the given option (FlipX, FlipY, FlipZ) publicvoid FlipSpline(SplineFlipOption splineFlipOption) // Invokes the SplineListeners when the spline has been changed publicvoid SplineHasChanged()
// Returns an array of calculated bezier points on the given spline chunk index publicVector3[] CalculateQuadraticBezierPoints(int splineChunkIndex, bool relatedToWorld = true) // Try to snap all the spline points to the ground using raycasting publicvoid TryToSnapAllSplinePoints(LayerMask includeLayers) // Rotate bezier point formula publicstaticQuaternion CalculateQuadraticBezierRotation(Quaternion q0, Quaternion q1, Quaternion q2, float t) // Calculate bezier point formula publicstaticVector3 CalculateQuadraticBezierPoint(float t, Vector3 p0, Vector3 p1, Vector3 p2)