Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clamping the spline length
#1
Hi,

Not sure if this is possible or if I'm just struggling, as the API doesn't really help all that much. I'm looking to clamp the length of a Bezier spline at runtime.

The user will drag a helper object and the aim is to draw a curve from the start point to this object up to a set distance, at which point the curve will stop drawing any further until the user drags out a shorter curve. I can see a Clamp method which doesn't appear to do anything, and I'm at a loss as to what the Extrapolate method does.

Any ideas?!

Thanks,

Ash
Reply
#2
Hi,
Here is a method I quickly coded that does what you want. It surely can be enhanced:

Code:
    private static bool RemoveExcess(CurvySpline spline, Vector3 terminatorWorldPosition)     {         if (spline.IsInitialized == false)             return false;         //The position at which the spline should stop         Vector3 nearestSplinePointToTerminator;         float terminatorTf = spline.GetNearestPointTF(terminatorWorldPosition, out nearestSplinePointToTerminator);         //The index of the last segment to keep, all following segements are removed         int terminatorSegmentIndex = spline.TFToSegmentIndex(terminatorTf);         //remove all control points beyong the terminator         int segmentsCount = spline.Count;         for (int segmentIndex = segmentsCount - 1; segmentIndex >= terminatorSegmentIndex; segmentIndex--)             spline.Delete(spline.Segments[segmentIndex].NextControlPoint);         //Add the last control point         spline.Add(nearestSplinePointToTerminator);         return true;     }
Please consider leaving a review for Curvy Splines, this helps immensely. Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Spline Issue Leading to Unity Freeze Pankaj09 1 462 08-24-2026, 11:28 PM
Last Post: _Aka_
  Connecting Multiple Spline Nodes Issue Ritesh Kadam 1 409 08-22-2026, 11:24 PM
Last Post: _Aka_
  Spline Spots from 2 samples. BitBlit 8 1,661 06-30-2026, 11:49 AM
Last Post: _Aka_
  Best way to duplicate a spline with an offset Kapistijn 8 3,067 04-12-2026, 03:18 PM
Last Post: _Aka_

Forum Jump: