public LengthCache(ISpline spline, int cacheSize) : base(cacheSize) { Vector3 p1 = spline.Evaluate(0f); Vector3 p2; Values[0] = 0f; for (int i = 1; i < Values.Length; i++) { p2 = spline.Evaluate((float)i / (Values.Length - 1)); Values[i] = Values[i - 1] + Vector3.Distance(p1, p2); p1 = p2; } }
public static void DebugDrawSpline(ISpline spline, int numMidPoints) { if (numMidPoints < 0) { throw new System.ArgumentOutOfRangeException("numMidPoints"); } for (float i = 0; i < numMidPoints; i++) { Debug.DrawLine( spline.Evaluate(i / numMidPoints), spline.Evaluate((i + 1.0f) / numMidPoints) ); } }
public static Quaternion Twist(ISpline core, float t_core, ISpline guide, float t_guide) { Vector3 corePoint = core.Evaluate(t_core); Vector3 rotationPoint = guide.Evaluate(t_guide); Vector3 tangentBasis = core.Tangent(t_core); tangentBasis = tangentBasis.normalized; Vector3 normalBasis = Vector3.Cross(tangentBasis, rotationPoint - corePoint); normalBasis = normalBasis.normalized; #region Uncomment this region to debug all Twist invocations /* * //Vector3 binormalBasis = Vector3.Cross(normalBasis, tangentBasis); * //binormalBasis = binormalBasis.normalized; * * //Debug.DrawLine(corePoint, corePoint + tangentBasis, Color.blue); * //Debug.DrawLine(corePoint, corePoint + normalBasis, Color.green); * //Debug.DrawLine(corePoint, corePoint + binormalBasis, Color.red); */ #endregion Uncomment this region to debug all Twist invocations return(Quaternion.LookRotation(tangentBasis, normalBasis)); }
public EvaluationCache(ISpline spline, int cacheSize) : base(cacheSize) { for (int i = 0; i < this.Values.Length; i++) { this.Values[i] = spline.Evaluate((float)i / (Values.Length - 1)); } }
public static void DrawTestInterpolate(ISpline worldSpline, float t) { Vector3 targetPoint = worldSpline.Evaluate(t); float sphereSize = PathEditorUtility.Nice3DHandleSize(targetPoint); Handles.color = GetTColor(t); Handles.SphereCap(0, targetPoint, Quaternion.identity, sphereSize); Handles.color = Color.cyan; Handles.DrawAAPolyLine(targetPoint, targetPoint + worldSpline.Tangent(t).normalized); }
/// <summary> /// Evaluates a spline based on the integrated length of the spline. /// </summary> public static Vector3 EvenlyEvaluate(ISpline spline, float percentLength, LengthCache splineLengthCache) { return(spline.Evaluate(t_PercentLength(percentLength, splineLengthCache))); }
/// <summary> /// Evaluates a spline based on the integrated length of the spline. /// </summary> public static Vector3 EvenlyEvaluate(ISpline spline, float percentLength, LengthCache splineLengthCache) { return spline.Evaluate(t_PercentLength(percentLength, splineLengthCache)); }