public DiscreteCurve ConvertToDCurve() { float segLength = 0.1f; List <Vector3> discretePoints = discretizeSpline(segLength); lineRender.SetVertexCount(discretePoints.Count); lineRender.SetPositions(discretePoints.ToArray()); GameObject discretized = new GameObject(); discretized.transform.parent = transform.parent; discretized.name = "DiscretizedCurve" + DiscreteCurve.NextCurveNumber(); DiscreteCurve dCurve = discretized.AddComponent <DiscreteCurve>(); dCurve.InitFromPoints(discretePoints, segLength); LineRenderer lr = dCurve.GetComponent <LineRenderer>(); lr.SetWidth(0.1f, 0.1f); lr.material = lineRender.material; gameObject.SetActive(false); return(dCurve); }
public void SplineToDCurve() { Dictionary <DraggablePoint, DCurveBulb> bulbDict = new Dictionary <DraggablePoint, DCurveBulb>(); foreach (DraggablePoint bulb in bulbs) { DCurveBulb dcBulb = bulb.ConvertToBulb(); dBulbs.Add(dcBulb); bulbDict.Add(bulb, dcBulb); } foreach (CatmullRomSpline spline in splines) { DiscreteCurve dc = spline.ConvertToDCurve(); if (spline.StartBulb) { DCurveBulb parentOfSpline = bulbDict[spline.StartBulb]; dc.parentBulb = parentOfSpline; parentOfSpline.childCurves.Add(dc); } if (spline.EndBulb) { DCurveBulb endOfSpline = bulbDict[spline.EndBulb]; dc.childBulb = endOfSpline; endOfSpline.parentCurve = dc; } AddDCurve(dc); } stage = CanvasStage.DCurve; }
DiscreteCurve ToDiscreteCurve() { DiscreteCurve[] old = FindObjectsOfType <DiscreteCurve>(); foreach (DiscreteCurve curve in old) { Destroy(curve.gameObject); } GameObject obj = new GameObject(); obj.name = "ImpulseDCurve"; DiscreteCurve dc = obj.AddComponent <DiscreteCurve>(); dc.InitFromPoints(displayPoints, 0.1f); LineRenderer lr = dc.GetComponent <LineRenderer>(); lr.SetWidth(0.1f, 0.1f); lr.material = lRenderer.material; lr.SetColors(Color.white, Color.white); Destroy(gameObject); return(dc); }
public void DeleteDCurve(DiscreteCurve dc) { dCurves.Remove(dc); }
public void AddDCurve(DiscreteCurve dc) { dc.containingCanvas = this; dCurves.Add(dc); }