private EntityObject ExportBSpline(BSpline bspline) { List <SplineVertex> vertices = new List <SplineVertex>(); for (int i = 0; i < bspline.Poles.Length; i++) { if (bspline.HasWeights) { vertices.Add(new SplineVertex(Vector3(bspline.Poles[i]), bspline.Weights[i])); } else { vertices.Add(new SplineVertex(Vector3(bspline.Poles[i]))); } } List <double> knots = new List <double>(); for (int i = 0; i < bspline.Knots.Length; i++) { for (int j = 0; j < bspline.Multiplicities[i]; j++) { knots.Add(bspline.Knots[i]); } } return(new netDxf.Entities.Spline(vertices, knots, (short)bspline.Degree)); }
/// <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(); }
public ShowPropertyBSpline(BSpline bSpline, IFrame frame) : base(frame) { this.bSpline = bSpline; InitSubEntries(); base.resourceId = "BSpline.Object"; }
IEnumerator Start() { while (true) { yield return(new WaitForSeconds(0.5f)); if (transform.childCount > 0) { if (points == null || points.Length != transform.childCount) { points = new Vector3[transform.childCount]; } for (int i = 0; i < transform.childCount; i++) { points[i] = transform.GetChild(i).transform.position; } for (int i = 0; i < pointCount; i++) { var t = (i + 0f) / (pointCount - 1); Vector3 point = BSpline.GetBStylePoint(points[0], points[1], points[2], t); lineRender.SetPosition(i, point); } } } }
public ConstrBSplinePoints() { points = new ArrayList(); bSpline = BSpline.Construct(); bSpline.ShowPoints(true, false); closed = false; degree = 3; // könnte auch über einen IntInput gesetzt werden degree = Settings.GlobalSettings.GetIntValue("Constr.BSpline.Degree", 3); }
/// <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); }
// Use this for initialization void Start() { b = new BSpline(ctrl); u = 0f; top_speed = 40f; velocity = 0; lane = Vector3.zero; drag *= weight; int x = 0; for (float i = 0; i < ctrl.Length; i += 0.1f, x++) lane_display[x] = (b.Evaluate(i) - b.Evaluate(i+0.1f)); }
private void InitializePoints() { // čitaj iz datoteke kontrolne točke b-krivulje List <Vector3> points = PointsReader.ReadFile(BSplineFilePath); this.points = points.ToArray(); BSpline bSpline = new BSpline(); // izračunaj točke b-krivulje bSplinePoints = bSpline.CalculateBSpline(points.ToArray()); tangentPoints = bSpline.TangentPoints; }
public static Path <V, D> FromBSpline(BSpline <D> spline, int numNodes) { var nodes = new V[numNodes]; var curr = spline.Knots.First(); var last = spline.Knots.Last() - 0.000001f; var step = (float)(last - curr) / (numNodes - 1); for (int i = 0; i < numNodes; i++) { nodes[i].position = spline.Evaluate(curr); curr = Math.Min(curr + step, last); } return(new Path <V, D> (nodes)); }
public void PartitionOfUnity() { var k = new double[] { 0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 5 }; Func <int, int, Func <double, double> > N = (i, p) => BSpline.Basis(k, i: i, p: p); var us = Generate.LinearSpaced(100, 0, 4.9999); var p = 2; var order = p + 1; foreach (var u in us) { var i = BSpline.KnotSpanFor(k, u); Enumerable.Range(i - p, order).Sum(j => N(j, p)(u)).Should().BeApproximately(1.0, 1e-5); } }
private void OnDrawGizmos() { List <Vector3> points = PointsReader.ReadFile(BSplineFilePath); DrawLines(points); BSpline bSpline = new BSpline(); bSplinePoints = bSpline.CalculateBSpline(points.ToArray()); DrawBSpline(bSplinePoints); if (showTangents) { DrawTangents(bSplinePoints, bSpline.TangentPoints); } }
private void OnSceneGUI() { BSpline bSpline = (BSpline)target; var transforms = bSpline.GetChildrenOrdered(); if (transforms == null || transforms.Length == 1) { return; } // Control points Vector3[] cp = new Vector3[transforms.Length]; // Generated control points for smooth spline Vector3[] gcp = new Vector3[transforms.Length]; // Populate control points from children array for (int i = 0; i < transforms.Length; i++) { cp[i] = transforms[i].position; } // Generate new set of control points gcp[0] = cp[0]; gcp[gcp.Length - 1] = cp[cp.Length - 1]; for (int i = 1; i < gcp.Length - 1; i++) { gcp[i] = cp[i - 1] / 6 + (2 * cp[i]) / 3 + cp[i + 1] / 6; } // Render the spline as separate quadratic bezier spline instances for (int i = 1; i < gcp.Length; i++) { // Construct a Bezier Spline instance and get its curve points var b = new UniSpline.Bezier( gcp[i - 1], (2 * cp[i - 1] / 3) + (cp[i] / 3), gcp[i], cp[i - 1] / 3 + (2 * cp[i] / 3) ); var points = b.GetCurvePoints(bSpline.subdivision); // Render the lines for (int j = 1; j < points.Length; j++) { Handles.DrawLine(points[j - 1], points[j]); } } }
// Use this for initialization void Start() { b = new BSpline(ctrl); u = 0f; top_speed = 40f; velocity = 0; lane = Vector3.zero; drag *= weight; int x = 0; for (float i = 0; i < ctrl.Length; i += 0.1f, x++) { lane_display[x] = (b.Evaluate(i) - b.Evaluate(i + 0.1f)); } }
///------------------------------------------------------------------------------------------------- /// \fn public override void MakeAction(ActionParameters_t toolParameters) /// /// \brief Makes an action /// /// \param toolParameters Options for controlling the tool. ///------------------------------------------------------------------------------------------------- public override void MakeAction(ActionParameters_t toolParameters) { try { BSpline bSpline = (BSpline)(toolParameters); using (Graphics g = Graphics.FromImage(mainView.Image)) { Draw(g, bSpline.pointArray, bSpline.pen); } } catch (Exception) { throw; } }
private Path <P, Vec3> CrossSection(Vec3 start, float top, int nodeCount) { start *= new Vec3(2f, 1f, 1f); var cPoints = new Vec3[] { start, new Vec3(start.X * 0.7f, top * 0.1f, start.Z), new Vec3(start.X * 0.6f, top * 0.7f, start.Z), }; var spline = BSpline <Vec3> .FromControlPoints(2, cPoints.Append (new Vec3(0f, top * 1.5f, start.Z)) .Concat (cPoints.Select(v => new Vec3(-v.X, v.Y, v.Z)).Reverse()) .ToArray()); return(Path <P, Vec3> .FromBSpline(spline, nodeCount)); }
private Path <P, Vec3> CrossSection(Vec3 start, float bottom, int nodeCount) { start.Z -= 0.75f; var cPoints = new Vec3[] { start, new Vec3(start.X * 1.2f, bottom * 0.6f, start.Z), new Vec3(start.X * 0.9f, bottom * 1.2f, start.Z), }; var spline = BSpline <Vec3> .FromControlPoints(2, cPoints.Append (new Vec3(0f, bottom * 1.35f, start.Z)) .Concat (cPoints.Select(v => new Vec3(-v.X, v.Y, v.Z)).Reverse()) .ToArray()); return(Path <P, Vec3> .FromBSpline(spline, nodeCount - 1)); }
public void BSplineKnotSearchShortWork() { { var k = new double[] { 0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 5 }; BSpline.KnotSpanFor(k, 0).Should().Be(2); BSpline.KnotSpanFor(k, 0.5).Should().Be(2); BSpline.KnotSpanFor(k, 1).Should().Be(3); BSpline.KnotSpanFor(k, 2).Should().Be(4); BSpline.KnotSpanFor(k, 5).Should().Be(10); } { var k = new double[] { 0, 0, 1, 1 }; BSpline.KnotSpanFor(k, 0).Should().Be(1); BSpline.KnotSpanFor(k, 0.5).Should().Be(1); BSpline.KnotSpanFor(k, 1).Should().Be(3); } }
private void BuildBSpline() { BSpline spline = new BSpline(); for (int i = 0; i < Entity.sons_.Count; i++) { spline.AddControlPoint(Entity.sons_[i].transform_.WorldPosition()); } spline.Degree = 2; spline.Loop = false; spline.Clamp = true; spline.SetDiscretisation(100); spline.ConstructSpline(); BuildCurve(spline.GetCurve()); }
void Start() { anim = gameObject.GetComponent <Animator> (); anim.SetBool("Accel", true); GameObject track = GameObject.FindGameObjectWithTag("TrackB"); b = new BSpline(track.GetComponentsInChildren <Transform>()); whatTrack = 0; u = 1f; ghost = new GameObject(); top_speed = 120f; velocity = 0f; shift = 4.0f; drag = 2; weight = 10; drag *= weight; lane_change = 0f; first_gear = 10; second_gear = 8; third_gear = 6; fourth_gear = 4; winpage = false; lap_count = 1; }
public CurveNode(int id, Graph parent) : base(id, parent) { Resizable = true; _inputSocketValue = new InputSocket(this, typeof(INumberConnection)); Sockets.Add(_inputSocketValue); Sockets.Add(new OutputSocket(this, typeof(INumberConnection))); _tmpRect = new Rect(); _panelRect = new Rect(); _points = new List <Vector2>(); _points.Add(new Vector2(-1.0f, -1.0f)); _points.Add(new Vector2(0f, 0f)); _points.Add(new Vector2(1.0f, 1.0f)); _spline = new BSpline(_points); _selectedPointIndex = 0; SocketTopOffsetInput = _panelHeight + +_panelMarginTop + 20; }
public void Example2p1() { var k = new double[] { 0, 0, 0, 1, 1, 1 }; BSpline.Basis(k, i: 0, p: 0).ShouldBe(u => 0, -10, 10); // -inf to inf BSpline.Basis(k, i: 1, p: 0).ShouldBe(u => 0, -10, -10); BSpline.Basis(k, i: 2, p: 0).ShouldBe(u => 1, 0, 1); BSpline.Basis(k, i: 3, p: 0).ShouldBe(u => 0, -10, -10); BSpline.Basis(k, i: 4, p: 0).ShouldBe(u => 0, -10, -10); BSpline.Basis(k, i: 0, p: 1).ShouldBe(u => 0, -10, 10); BSpline.Basis(k, i: 1, p: 1).ShouldBe(u => 1 - u, 0, 1); BSpline.Basis(k, i: 1, p: 1).ShouldBe(u => 0, -10, 0); BSpline.Basis(k, i: 1, p: 1).ShouldBe(u => 0, 1, 10); BSpline.Basis(k, i: 0, p: 2).ShouldBe(u => (1 - u).Pow(2), 0, 1); BSpline.Basis(k, i: 1, p: 2).ShouldBe(u => 2 * u * (1 - u), 0, 1); BSpline.Basis(k, i: 2, p: 2).ShouldBe(u => u * u, 0, 1); }
void Start () { GameObject track = GameObject.FindGameObjectWithTag("TrackB"); gameTerrain = Terrain.activeTerrain; bspline = new BSpline (track.GetComponentsInChildren<Transform>()); whatTrack = 0; u = 1f; ghost = new GameObject(); top_speed = 120f; velocity = 0f; shift = 4f; lap_count = 1; power_up = UnityEngine.UI.Image.FindObjectOfType<Image>(); power_up.enabled = false; race_status = UnityEngine.UI.Text.FindObjectOfType<Text>(); drag = 1; lane_change = 0f; first_gear = 6; second_gear = 5; third_gear = 4; fourth_gear = 2; for (int i = 0; i < track.transform.childCount; i++) track.transform.GetChild(i).GetComponent<Renderer>().enabled = false; winpage = false; }
public void Example2p2() { var k = new double[] { 0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 5 }; Func <int, int, Func <double, double> > N = (i, p) => BSpline.Basis(k, i: i, p: p); N(0, 0).ShouldBe(u => 0, -10, 10); N(1, 0).ShouldBe(u => 0, -10, 10); N(2, 0).ShouldBe(u => 1, 0, 1); N(3, 0).ShouldBe(u => 1, 1, 2); N(4, 0).ShouldBe(u => 1, 2, 3); N(5, 0).ShouldBe(u => 1, 3, 4); N(6, 0).ShouldBe(u => 0, -10, 10); N(7, 0).ShouldBe(u => 1, 4, 5); N(8, 0).ShouldBe(u => 0, -10, 10); N(9, 0).ShouldBe(u => 0, -10, 10); N(0, 1).ShouldBe(u => 0, -10, 10); N(1, 1).ShouldBe(u => 1 - u, 0, 1); N(2, 1).ShouldBe(u => 0, -10, 0); N(2, 1).ShouldBe(u => u, 0, 1); N(2, 1).ShouldBe(u => 2 - u, 1, 2); N(2, 1).ShouldBe(u => 0, 2, 10); N(3, 1).ShouldBe(u => 0, -10, 1); N(3, 1).ShouldBe(u => (u - 1), 1, 2); N(3, 1).ShouldBe(u => 3 - u, 2, 3); N(3, 1).ShouldBe(u => 0, 3, 10); N(0, 2).ShouldBe(u => (1 - u).Pow(2), 0, 1); N(1, 2).ShouldBe(u => 2 * u - 3.0 / 2 * u * u, 0, 1); N(1, 2).ShouldBe(u => 0.5 * (2 - u).Pow(2), 1, 2); N(5, 2).ShouldBe(u => (u - 3).Pow(2), 3, 4); N(5, 2).ShouldBe(u => (5 - u).Pow(2), 4, 5); }
public Nose(float middleHeight, float baseHeight, int numPoints, float bottomFlatness) { var spline = BSpline <Vec3> .FromControlPoints(2, new Vec3 (-1f, 0f, 0f), new Vec3 (0f, middleHeight, 0f), new Vec3 (1f, baseHeight, 0f)); Profile = Path <P, Vec3> .FromBSpline(spline, 8); Cone = Lathe <V> .Turn(Profile, turnAxis : Axis.X, offset : new Vec3(0f), stepAngle : MathHelper.TwoPi / numPoints) .ManipulateVertices( Manipulators.Scale <V> (1f, 1f - bottomFlatness, 1f).Where(v => v.position.Y < 0f), true) .RotateY(90f.Radians()) .Color(_color); XSection = Path <P, Vec3> .FromVecs( from v in Cone.Vertices.Furthest (Dir3D.Back) select v.position); }
public void KernelTest() { double[] x, y; double actual; var target = new BSpline(10); x = new double[] { 1, 2, 3, 6, 2, 2, 1 }; y = new double[] { 4, 5, 6, 9, 5, 3, 1 }; actual = target.Function(x, y); Assert.AreEqual(0.00000000070098200355454978, actual); x = new double[] { 5, 11, 2, 9, 4, 5, 4 }; y = new double[] { 4, 5, 1, 1, 3, 3, 4 }; actual = target.Function(x, y); Assert.AreEqual(0.00000000000000017965181746434572, actual); target = new BSpline(20); x = new double[] { 1, 2, 3 }; y = new double[] { 4, 5, 6 }; actual = target.Function(x, y); Assert.AreEqual(0.00020921661189636344, actual); x = new double[] { 5, 11, 2 }; y = new double[] { 4, 5, 1 }; actual = target.Function(x, y); Assert.AreEqual(0.000042265155534640169, actual); target = new BSpline(20); x = new double[] { 0.1, 0.5, 0.01 }; y = new double[] { 0.3, 0.02, 0.04 }; actual = target.Function(x, y); Assert.AreEqual(0.0092334372187475831, actual); x = new double[] { 0.5, 0.11, 0.2 }; y = new double[] { 0.4, 0.5, 0.1 }; actual = target.Function(x, y); Assert.AreEqual(0.0093633595480067857, actual); }
///------------------------------------------------------------------------------------------------- /// \fn private void MainView_MouseClick(object sender, MouseEventArgs e) /// /// \brief Event handler. Called by MainView for mouse click events /// /// \param sender Source of the event. /// \param e Mouse event information. ///------------------------------------------------------------------------------------------------- private void MainView_MouseClick(object sender, MouseEventArgs e) { if (isFirstClick) { doubleBuffer = mainView.Image.Clone() as Image; isFirstClick = false; } if (e.Button == MouseButtons.Left) { isDrawing = true; controlPointsArray.Add(e.Location); } else if (e.Button == MouseButtons.Right) { isDrawing = false; BSpline bSpline = new BSpline(controlPointsArray); bSpline.pen = Setting.GetInstance().Pen; History.GetInstance().PushBackAction( new history.MAction(this, bSpline) ); } }
public void BSplineBasisShouldWork() { var k = new double[] { 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6 }; BSpline.Basis(k, 0, 0, 0).Should().Be(1); BSpline.Basis(k, 0, 0, 0.09).Should().Be(1); BSpline.Basis(k, 0, 0, 1).Should().Be(0); BSpline.Basis(k, p: 0, i: 4, u: 0.4).Should().Be(1); BSpline.Basis(k, p: 0, i: 4, u: 0.49).Should().Be(1); BSpline.Basis(k, p: 0, i: 4, u: 0.5).Should().Be(0); BSpline.Basis(k, p: 1, i: 0, u: 0).Should().Be(0); BSpline.Basis(k, p: 1, i: 0, u: 0.05).Should().BeApproximately(0.5, 1e-5); BSpline.Basis(k, p: 1, i: 0, u: 0.1).Should().Be(1); BSpline.Basis(k, p: 1, i: 0, u: 0.15).Should().BeApproximately(0.5, 1e-5); BSpline.Basis(k, p: 1, i: 0, u: 0.2).Should().Be(0); BSpline.Basis(k, p: 1, i: 4, u: 0.4).Should().Be(0); BSpline.Basis(k, p: 1, i: 4, u: 0.5).Should().Be(1); BSpline.Basis(k, p: 1, i: 4, u: 0.6).Should().Be(0); }
public static void Main(string[] args) { // Create a cubic spline with 7 control points in 2D using // a clamped knot vector. This call is equivalent to: // BSpline spline = new BSpline(7, 2, 3, BSplineType.CLAMPED); BSpline spline = new BSpline(7); // Setup control points. IList <double> ctrlp = spline.ControlPoints; ctrlp[0] = -1.75; // x0 ctrlp[1] = -1.0; // y0 ctrlp[2] = -1.5; // x1 ctrlp[3] = -0.5; // y1 ctrlp[4] = -1.5; // x2 ctrlp[5] = 0.0; // y2 ctrlp[6] = -1.25; // x3 ctrlp[7] = 0.5; // y3 ctrlp[8] = -0.75; // x4 ctrlp[9] = 0.75; // y4 ctrlp[10] = 0.0; // x5 ctrlp[11] = 0.5; // y5 ctrlp[12] = 0.5; // x6 ctrlp[13] = 0.0; // y6 spline.ControlPoints = ctrlp; // Evaluate `spline` at u = 0.4. IList <double> result = spline.Eval(0.4).Result; Console.WriteLine("x = {0}, y = {1}", result[0], result[1]); // Derive `spline` and subdivide it into a sequence of Bezier curves. BSpline beziers = spline.Derive().ToBeziers(); // Evaluate `beziers` at u = 0.3. result = beziers.Eval(0.3).Result; Console.WriteLine("x = {0}, y = {1}", result[0], result[1]); }
// Use this for initialization void Start() { // Debug.Log (b); b = new BSpline(ctrlA); b2 = new BSpline(ctrlB); BS = new BSpline[] { b, b2 }; array = new Transform[][] { new Transform[ctrlA.Length], new Transform[ctrlB.Length] }; array [0] = ctrlA; array [1] = ctrlB; whatTrack = 0; u = 0f; top_speed = 40f; velocity = 0; drag *= weight; lane_change = 0f; for (int i = 0; i < ctrlA.Length; i++) { ctrlA[i].GetComponent <Renderer>().enabled = false; } for (int i = 0; i < ctrlB.Length; i++) { ctrlB[i].GetComponent <Renderer>().enabled = false; } }
public static void Main(string[] args) { // Create a clamped spline of degree 3 in 2D consisting of 7 control points. BSpline spline = new BSpline(3, 2, 7, tsBSplineType.TS_CLAMPED); // Setup the control points. IList <float> ctrlp = spline.ctrlp; ctrlp[0] = -1.75f; // x0 ctrlp[1] = -1.0f; // y0 ctrlp[2] = -1.5f; // x1 ctrlp[3] = -0.5f; // y1 ctrlp[4] = -1.5f; // x2 ctrlp[5] = 0.0f; // y2 ctrlp[6] = -1.25f; // x3 ctrlp[7] = 0.5f; // y3 ctrlp[8] = -0.75f; // x4 ctrlp[9] = 0.75f; // y4 ctrlp[10] = 0.0f; // x5 ctrlp[11] = 0.5f; // y5 ctrlp[12] = 0.5f; // x6 ctrlp[13] = 0.0f; // y6 spline.ctrlp = ctrlp; // Evaluate `spline` at u = 0.4 IList <float> result = spline.evaluate(0.4f).result; Console.WriteLine(String.Format("x = {0}, y = {1}", result[0], result[1])); // Derive `spline` and subdivide it into a sequence of Bezier curves. BSpline beziers = spline.derive().toBeziers(); // Evaluate `beziers` at u = 0.3 result = beziers.evaluate(0.3f).result; // C# does not support the operator '()' Console.WriteLine(String.Format("x = {0}, y = {1}", result[0], result[1])); }
public Canopy(float frontHeight, float backHeight, float bend, int numPoints) { var spline = BSpline <Vec3> .FromControlPoints(2, new Vec3 (-1.1f, 0f, 0f), new Vec3 (-1f, 0.2f, 0f), new Vec3 (-0f, frontHeight, 0f), new Vec3 (1f, backHeight, 0f), new Vec3 (2.5f, 0.1f, 0f), new Vec3 (2.5f, 0f, 0f) ); Profile = Path <P, Vec3> .FromBSpline(spline, numPoints); var angle = 105f.Radians(); Geometry = Lathe <V> .Turn(Profile, Axis.X, new Vec3 (0f), MathHelper.Pi / numPoints, -angle, angle) .RotateY(90f.Radians()) .RotateX(bend.Radians()) .Scale(0.85f, 1f, 1f) .Translate(0f, 0.6f, -2.3f) .Color(VertexColor <Vec3> .DarkGlass) .Reflectivity(0.4f); }
// Use this for initialization void Start() { // Debug.Log (b); b = new BSpline(ctrlA); b2 = new BSpline (ctrlB); //for (int i = 0; i < b.ctlPoint.Length; i++) // Debug.Log (b.ctlPoint [i].position); BS = new BSpline[] { //new BSpline(ctrlA) , b, b2}; //new BSpline(ctrlA)}; //Debug.Log (BS [2]); // for (int i = 0; i < BS.Length; i++) // Debug.Log (BS[i]); //new BSpline(ctrlB)}; array = new Transform[][] { new Transform[ctrlA.Length], new Transform[ctrlB.Length] }; // for (int i = 0; i < ctrlA.Length; i++) // Debug.Log (ctrlA[i].position); //b = BS [0]; //b2 = BS [1]; array [0] = ctrlA; array [1] = ctrlB; //BS [0] = b; //BS [1] = b2; whatTrack = 0; // Debug.Log (BS [whatTrack]); u = 0f; top_speed = 40f; // road_smooth = 0.1f; velocity = 0; lane = Vector3.zero; drag *= weight; }
void Start() { GameObject track = GameObject.FindGameObjectWithTag("TrackB"); gameTerrain = Terrain.activeTerrain; bspline = new BSpline (track.GetComponentsInChildren<Transform>()); whatTrack = 0; u = 1f; ghost = new GameObject(); top_speed = 120f; velocity = 0f; shift = 4f; lap_count = 1; power_up = UnityEngine.UI.Image.FindObjectOfType<Image>(); power_up.enabled = false; race_status = UnityEngine.UI.Text.FindObjectOfType<Text>(); drag = 1; lane_change = 0f; first_gear = 6; second_gear = 5; third_gear = 4; fourth_gear = 2; for (int i = 0; i < track.transform.childCount; i++) track.transform.GetChild(i).GetComponent<Renderer>().enabled = false; winpage = false; }
// Use this for initialization void Start() { // Debug.Log (b); b = new BSpline(ctrlA); b2 = new BSpline (ctrlB); BS = new BSpline[] {b, b2}; array = new Transform[][] {new Transform[ctrlA.Length], new Transform[ctrlB.Length]}; array [0] = ctrlA; array [1] = ctrlB; whatTrack = 0; u = 0f; top_speed = 40f; velocity = 0; drag *= weight; lane_change = 0f; for (int i = 0; i < ctrlA.Length; i++) ctrlA[i].GetComponent<Renderer>().enabled = false; for (int i = 0; i < ctrlB.Length; i++) ctrlB[i].GetComponent<Renderer>().enabled = false; }
void Start() { anim = gameObject.GetComponent<Animator> (); anim.SetBool ("Accel", true); GameObject track = GameObject.FindGameObjectWithTag ("TrackB"); b = new BSpline (track.GetComponentsInChildren<Transform>()); whatTrack = 0; u = 1f; ghost = new GameObject(); top_speed = 120f; velocity = 0f; shift = 4.0f; drag = 2; weight = 10; drag *= weight; lane_change = 0f; first_gear = 10; second_gear = 8; third_gear = 6; fourth_gear = 4; winpage = false; lap_count = 1; }