public ITransmission FixedBody(IBody body, float x, float y) { Wheel1.FixedBody(body, -x, y); Wheel2.FixedBody(body, x, y); return(this); }
void Start() { moveLift = Lift.GetComponent <DOTMoving>(); rotationWheel1 = Wheel1.GetComponent <DOTRotation>(); rotationWheel2 = Wheel2.GetComponent <DOTRotation>(); moveLift.enabled = false; rotationWheel1.enabled = false; rotationWheel2.enabled = false; }
public void Update() { Axis.StartPoint = Wheel1.Center; Axis.EndPoint = Wheel2.Center; Wheel1.Radius = WheelRadius; Wheel2.Radius = WheelRadius; Wheel1.Update(); Wheel2.Update(); Axis.Update(); }
public void selectWheel(int wheelIndex, int blueprintNo) { Wheel selectedWheel = null; if (wheelIndex == 0) { selectedWheel = new Wheel1(); } else if (wheelIndex == 1) { selectedWheel = new Wheel2(); } else { selectedWheel = new Wheel3(); } warplan.blueprints[blueprintNo].wheel = selectedWheel; }
public void Draw() { Wheel1.Draw(); Wheel2.Draw(); }
public void Update() { Wheel1.Update(); Wheel2.Update(); }
public void Move(float value) { Wheel1.Move(value); Wheel2.Move(value); }
public void CreateBasicMesh() { SidePanel1 panelScript = GameObject.Find("SidePanel1").GetComponent <SidePanel1> (); Wheel1 wheelScript = GameObject.Find("Wheel1").GetComponent <Wheel1> (); radius = wheelScript.radius; height = wheelScript.height; sides = wheelScript.sides; #region Vertices int nbVerticesCap = sides + 1; // bottom + top + sides Vector3[] vertices = new Vector3[nbVerticesCap + nbVerticesCap + sides * 2 + 2]; int vert = 0; float twoPi = Mathf.PI * 2f; // Bottom cap vertices [vert++] = new Vector3(0f, 0f, 0f); while (vert <= sides) { float rad = (float)vert / sides * twoPi; vertices [vert] = new Vector3(Mathf.Cos(rad) * radius, 0f, Mathf.Sin(rad) * radius); vert++; } // Top cap vertices [vert++] = new Vector3(0f, height, 0f); while (vert <= sides * 2 + 1) { float rad = (float)(vert - sides - 1) / sides * twoPi; vertices [vert] = new Vector3(Mathf.Cos(rad) * radius, height, Mathf.Sin(rad) * radius); vert++; } // Sides int v = 0; while (vert <= vertices.Length - 4) { float rad = (float)v / sides * twoPi; vertices [vert] = new Vector3(Mathf.Cos(rad) * radius, height, Mathf.Sin(rad) * radius); vertices [vert + 1] = new Vector3(Mathf.Cos(rad) * radius, 0, Mathf.Sin(rad) * radius); vert += 2; v++; } vertices [vert] = vertices [sides * 2 + 2]; vertices [vert + 1] = vertices [sides * 2 + 3]; #endregion #region Triangles int nbTriangles = sides + sides + sides * 2; int[] triangles = new int[nbTriangles * 3 + 3]; // Bottom cap int tri = 0; int i = 0; while (tri < sides - 1) { triangles [i] = 0; triangles [i + 1] = tri + 1; triangles [i + 2] = tri + 2; tri++; i += 3; } triangles [i] = 0; triangles [i + 1] = tri + 1; triangles [i + 2] = 1; tri++; i += 3; // Top cap //tri++; while (tri < sides * 2) { triangles [i] = tri + 2; triangles [i + 1] = tri + 1; triangles [i + 2] = nbVerticesCap; tri++; i += 3; } triangles [i] = nbVerticesCap + 1; triangles [i + 1] = tri + 1; triangles [i + 2] = nbVerticesCap; tri++; i += 3; tri++; // Sides while (tri <= nbTriangles) { triangles [i] = tri + 2; triangles [i + 1] = tri + 1; triangles [i + 2] = tri + 0; tri++; i += 3; triangles [i] = tri + 1; triangles [i + 1] = tri + 2; triangles [i + 2] = tri + 0; tri++; i += 3; } #endregion mesh.vertices = vertices; mesh.triangles = triangles; wheelPos = wheelScript.wheelPos; float zPos = Vector3.Lerp(panelScript.mesh.vertices[8], panelScript.mesh.vertices[10], wheelPos).z; gameObject.transform.position = new Vector3(panelScript.mesh.vertices[0].x - 0.1f, 0, zPos); gameObject.transform.rotation = Quaternion.Euler(0, 0, -90.0f); mesh.RecalculateNormals(); }