Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connection Question
#1
Question 
Hi, so I want to add a spline (which I will call Spline2)  to another spline ( which I will call Spline1) between 2 existing control points, which I have achieved by doing the following :

1. Storing the data for each control point in Spline1 ( including the connection if it has one )
2. Calculating the position on spline1 where spline2 should start.
3. Delete the control points of spline1 ....  Spline.clear()  and Spline.Refresh()
4. Adding the control points back to spline1 using the stored data for each Control point and adding the addition Control point at the appropriate place, with a connection.

The above works fine when  adding spline 2 to spline 1.

Here's where it doesnt go as intended :

If I want to add another spline ( call it spline3 ) to spline1 and therefore another connection ( it might be in a different place to spline 2 so cant just add spline3 to the connection )
When I'm adding the control points back to the spline as in step 4 above.
I try to add spline2/CP0000 to Spline 1 BUT because that Control point already has a connection ( from when I added spline2 to spline 1) it won't add to the connection.
I've tried deleteing the connection & refreshing the spline but it makes no difference.
  Is there somthing else that needs to be "refreshed" or called for this to work.


Code:
static void AddControlPointDataTOSeg ( CurvySplineSegment seg, ControlPoint ControlPoints, int index )
{


seg.AutoHandles = false;
seg.transform.position = ControlPoints.Position;
seg.transform.eulerAngles = ControlPoints.Rotation;
seg.HandleIn = ControlPoints.HandleINLocal;
seg.HandleOut = ControlPoints.HandleOUTLocal;


if (ControlPoints.Connection != null) {
Debug.Log (" A connection should be added for CP " + index + " control points to add = "+ ControlPoints.Connection.Count);
CurvyConnection.Create (seg);

foreach (CurvySplineSegment SegInConnection in ControlPoints.Connection.ControlPointsList) {
Debug.Log (SegInConnection.name + " / " + SegInConnection.transform.parent.name + " should be added to " + index + " " + seg.transform.parent.name);
SegInConnection.Connection.Delete ();
GameObject obj = SegInConnection.transform.transform.parent.gameObject;
Debug.Log (obj.name);
CurvySpline spline = obj.GetComponent<CurvySpline> ();
spline.Refresh ();
seg.Connection.AddControlPoints (SegInConnection);

}



}

}
Reply
#2
Hi
If your CurvySplineSegment has already a connection, avoid creating a new one, and use the existing one by accessing CurvySplineSegment.Connection
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


Possibly Related Threads…
Thread Author Replies Views Last Post
Question question about the local position brucezhu99 4 416 09-18-2021, 12:02 PM
Last Post: _Aka_
  Noob Question Wyldhunt 5 597 09-04-2021, 06:53 PM
Last Post: _Aka_
  Curvy Spline can't export connection? Yang Yi 1 417 07-31-2021, 03:09 PM
Last Post: _Aka_
  Spline deformation & Bezier spline connection alignment digot 7 1,574 04-18-2021, 03:39 PM
Last Post: _Aka_

Forum Jump: