Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closest Spline & control points loop in both directions
#11
but I am using "output" only to draw nearestPoint. NextControlPoint and PreviousControlPoint is based on a "nearestSegment".
Reply
#12
(01-29-2021, 03:35 PM)nehvaleem Wrote: but I am using "output" only to draw nearestPoint. NextControlPoint and PreviousControlPoint is based on a "nearestSegment".

Hi again

Sorry my previous message didn't make sense. I wrote it in a hurry knowing that I could not write a long one until now. Now that I am free again, here is the right answer:

It all boils down to the concept of a segment. A segment is the curve between two CPs. In Curvy Splines the choice was made to represent a segment in the code with its first CP. So the curve between CP1 and CP2 will be represented by CP1.
So when you call GetNearestPointTF:
  • on any point between CP1 and CP2, the returned segment is CP1
  • on CP1, the returned segment is CP1
  • on CP2, the returned segment depends on whether there is a CP3:
         - if CP3 exists, that means that CP2 is a valid segment (the curve between CP2 and CP3). In this case the returned segment is CP2
         - if CP3 does not exist, that means that CP2 is not a segment, so the returned segment is CP1
Try visualizing your gizmos on an open spline, I think that my explanation will make sense. If you do so, handle the fact that NextControlPoint or PreviousControlPoint can be null if you are on the edge of the open spline.

I hope this helped.

Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#13
That's explain a lot. Thanks for the clarification. That being said - is there a way just to iterate over control points in a loop? Or do I have to handle it by myself?
Reply
#14
Yes, you can do a for loop on yourSpline.ControlPointsList, or if you want to iterate indefinitely, use a while loop using an index that you increase at every iteration, and apply the % operator to keep you index between 0 and yourSpline.ControlPointsList.Count
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Create spline at run time AnAppGames 2 20 04-20-2021, 07:14 PM
Last Post: _Aka_
  Spline deformation & Bezier spline connection alignment digot 7 70 04-18-2021, 03:39 PM
Last Post: _Aka_
  Spline To Mesh UVs Mos Def 2 130 03-26-2021, 10:43 AM
Last Post: _Aka_
  Is it possible to generate an output spline after the conform path module? bennidhamma@gmail.com 3 171 03-21-2021, 06:37 PM
Last Post: _Aka_

Forum Jump: