public TrackNodeCurve (CubicBezier cubicBezier, TrackSegmentModify segmentModify,Grouping grouping) { this.Group = grouping; this.cubicBezier = cubicBezier; this.SegmentModify = segmentModify; P0 = AddTrackCurveNode ( SegmentModify.TrackSegment.transform.TransformPoint (cubicBezier.p0),TrackNode.NodeType.PO ); P1 = AddTrackCurveNode (SegmentModify.TrackSegment.transform.TransformPoint (cubicBezier.p1), TrackNode.NodeType.P1); P2 = AddTrackCurveNode (SegmentModify.TrackSegment.transform.TransformPoint (cubicBezier.p2),TrackNode.NodeType.P2); P3 = AddTrackCurveNode (SegmentModify.TrackSegment.transform.TransformPoint (cubicBezier.p3),TrackNode.NodeType.P3); if ((grouping == Grouping.End || grouping == Grouping.Both) && SegmentModify.GetNextSegment(true) == null) { ExtrudeNode = AddExtrudeNode (SegmentModify.TrackSegment.transform.TransformPoint (cubicBezier.p3) + SegmentModify.TrackSegment.getTangentPoint(1f)*.3f); } }
public bool ConnectWithForwardSegment(TrackSegmentModify next) { TrackSegment.isConnectedToNextSegment = true; next.TrackSegment.isConnectedToPreviousSegment = true; float magnitude = Mathf.Abs((next.GetFirstCurve.P0.GetGlobal () - next.GetFirstCurve.P1.GetGlobal ()).magnitude); GetLastCurve.P2.SetPoint(GetLastCurve.P3.GetGlobal() + (next.TrackSegment.getTangentPoint(0f) *-1f* magnitude)); next.TrackSegment.calculateLengthAndNormals (GetLastCurve.SegmentModify.TrackSegment); next.CalculateStartBinormal (false); invalidate = true; return true; }