/// <summary> /// Generate all B-splines /// </summary> public void GenerateBSplines() { foreach (Lines item in lines) { item.RefreshBSpline(); meshPoints.Add(item.GetSplinePoints()); } for (int i = 0; i < meshPoints[0].Count; i++) { List <Vector3> cp = new List <Vector3>(); for (int j = 0; j < meshPoints.Count; j++) { cp.Add(meshPoints[j][i]); } BSpline bSpline = new BSpline(k, Resolution, cp, UseOpenNodalVector); vertices.AddRange(bSpline.Generate()); //Create a line renderer BSplineRenderer = Instantiate(BSplineObject).GetComponent <LineRenderer>(); Vector3[] tmp = bSpline.Generate(); BSplineRenderer.positionCount = tmp.Length; BSplineRenderer.SetPositions(tmp); } //CreateMesh(); }
/// <summary> /// Refresh the B-Spline with the current control points /// </summary> public void RefreshBSpline() { //Create a new BSpline class CustomBSpline = new BSpline(k, resolution, ControlPoints, UseOpenNodalVector); //Clear the line renderer BSplineRenderer.positionCount = 0; Vector3[] bSpline = CustomBSpline.Generate(); BSplineRenderer.positionCount = bSpline.Length; BSplineRenderer.SetPositions(bSpline); }