TorsionImpulseCurve MakeTorsionImpulseCurve(List <float> impulses, List <float> arcPoints, List <float> curvatureList, List <float> torsionList) { Debug.Log("Arc length of DC = " + ArcLength); Vector3 startingNormal = Vector3.Cross(startingBinormal, startingTangent); OrthonormalFrame startFrame = new OrthonormalFrame(startingTangent, startingNormal, startingBinormal); List <float> arcSteps = new List <float>(); for (int i = 0; i < arcPoints.Count - 1; i++) { arcSteps.Add(arcPoints[i + 1] - arcPoints[i]); } GameObject obj = new GameObject(); obj.name = "TorsionApproxCurve"; TorsionImpulseCurve impulseCurve = obj.AddComponent <TorsionImpulseCurve>(); impulseCurve.InitFromData(impulses, arcSteps, curvatureList, torsionList, startFrame, StartingPoint); impulseCurve.SetMaterial(lineRender.material); return(impulseCurve); }
TorsionImpulseCurve MakeTorsionImpulseCurve(List <float> impulses, List <float> arcPoints, float constTorsion) { float averageCurvature = AverageCurvature(); Vector3 startingNormal = Vector3.Cross(startingBinormal, startingTangent); OrthonormalFrame startFrame = new OrthonormalFrame(startingTangent, startingNormal, startingBinormal); List <float> arcSteps = new List <float>(); for (int i = 0; i < arcPoints.Count - 1; i++) { arcSteps.Add(arcPoints[i + 1] - arcPoints[i]); } GameObject obj = new GameObject(); obj.name = "TorsionApproxCurve"; TorsionImpulseCurve impulseCurve = obj.AddComponent <TorsionImpulseCurve>(); impulseCurve.InitFromData(impulses, arcSteps, averageCurvature, constTorsion, startFrame, StartingPoint); impulseCurve.SetMaterial(lineRender.material); impulseCurve.BulbShrinkRatio = ActualShrinkRatio; return(impulseCurve); }
public void DCurveToTIC() { // Clear away the old stuff foreach (TorsionImpulseCurve tic in tiCurves) { Destroy(tic.gameObject); } tiCurves.Clear(); foreach (DCurveBulb dcb in tiBulbs) { Destroy(dcb.gameObject); } tiBulbs.Clear(); Dictionary <DCurveBulb, DCurveBulb> bulbDict = new Dictionary <DCurveBulb, DCurveBulb>(); foreach (DCurveBulb origBulb in dBulbs) { DCurveBulb newBulb = origBulb.Duplicate(); tiBulbs.Add(newBulb); bulbDict.Add(origBulb, newBulb); } foreach (DiscreteCurve dc in dCurves) { TorsionImpulseCurve impulseCurve = dc.MakeImpulseCurve(); tiCurves.Add(impulseCurve); impulseCurve.transform.parent = transform; if (dc.parentBulb) { DCurveBulb newParent = bulbDict[dc.parentBulb]; newParent.childCurves.Add(impulseCurve); impulseCurve.StartJuncture = newParent; } if (dc.childBulb) { DCurveBulb newChild = bulbDict[dc.childBulb]; newChild.parentCurve = impulseCurve; impulseCurve.EndJuncture = newChild; } } tiCreated = true; }
void AddAxes() { foreach (TelescopeShell shell in segment.shells) { GameObject axisObj = new GameObject(); TorsionImpulseCurve axis = axisObj.AddComponent <TorsionImpulseCurve>(); List <float> impulses = new List <float>(); impulses.Add(0); List <float> arcs = new List <float>(); arcs.Add(shell.length); OrthonormalFrame frame = new OrthonormalFrame(Vector3.forward, Vector3.up, Vector3.left); axis.InitFromData(impulses, arcs, shell.curvature, -shell.torsion, frame, Vector3.zero); LineRenderer axisLR = axis.GetComponent <LineRenderer>(); axisLR.useWorldSpace = false; axisLR.material = lineMaterial; axis.transform.parent = shell.transform; axis.transform.localPosition = Vector3.zero; axis.transform.localRotation = Quaternion.identity; } }