// Use this for initialization private void Start() { testCurves = new TestCurves(GetComponent <BGCurve>(), new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent), ObjectToMove, LineRendererMaterial); //Base, OptimizeStraightLines testCurves.Add(new CurveData(testCurves, "BGBaseStraightLines", "Base, OptimizeStraightLines = true", transform.position + new Vector3(-4, 1), new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent) { OptimizeStraightLines = true }, CurveData.MathTypeEnum.Base)); //Base, UsePointPositionsToCalcTangents testCurves.Add(new CurveData(testCurves, "BGBasePos2Tangents", "Base, UsePointPositionsToCalcTangents = true", transform.position + new Vector3(-4, 4), new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent) { UsePointPositionsToCalcTangents = true }, CurveData.MathTypeEnum.Base)); //Adaptive testCurves.Add(new CurveData(testCurves, "BGAdaptive", "Adaptive", transform.position + new Vector3(4, 4), new BGCurveAdaptiveMath.ConfigAdaptive(BGCurveBaseMath.Fields.PositionAndTangent) /* { Tolerance = .2f }*/, CurveData.MathTypeEnum.Adaptive)); //Formula testCurves.Add(new CurveData(testCurves, "BGFormula", "Formula", transform.position + new Vector3(4, 1), new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent), CurveData.MathTypeEnum.Formula)); }
public CurveData(TestCurves testCurves, string name, string description, Vector3 position, BGCurveBaseMath.Config config, MathTypeEnum mathType) : base(new GameObject(name), testCurves.LineRendererMaterial, Color.magenta) { this.testCurves = testCurves; this.description = description; //game object GameObject.transform.position = position; origin = position; //curve Curve = GameObject.AddComponent <BGCurve>(); Curve.Closed = testCurves.Curve.Closed; //add points for (var i = 0; i < testCurves.Curve.PointsCount; i++) { var point = testCurves.Curve[i]; var clonePoint = new BGCurvePoint(Curve, point.PositionLocal, point.ControlType, point.ControlFirstLocal, point.ControlSecondLocal); Curve.AddPoint(clonePoint); } //init math after points are added switch (mathType) { case MathTypeEnum.Base: Math = new BGCurveBaseMath(Curve, config); break; case MathTypeEnum.Formula: #pragma warning disable 0618 Math = new BGCurveFormulaMath(Curve, config); #pragma warning restore 0618 break; case MathTypeEnum.Adaptive: Math = new BGCurveAdaptiveMath(Curve, (BGCurveAdaptiveMath.ConfigAdaptive)config); break; default: throw new ArgumentOutOfRangeException("mathType", mathType, null); } AddObjects(ObjectsCount, testCurves.ObjectToMove, GameObject.transform); //scale down GameObject.transform.localScale = originalScale; }