1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
public void OnShow_Differential_Rings() { if (amd == null) { amd = new ArgosMeshDraft(); } else { amd.Clear(); } GetComponent<MeshRenderer>().enabled = true; setColor(orbitColor); List<Vector3> vInnerLower = new List<Vector3>(); List<Vector3> vOuterLower = new List<Vector3>(); List<Vector3> vInnerUpper = new List<Vector3>(); List<Vector3> vOuterUpper = new List<Vector3>(); List<Vector3> vDisk = new List<Vector3>(); float op = Mathf.PI * 2f; float delta_theta = op / 180; float theta = 0; Vector3 vPos_Lower; Vector3 vPos_Upper; Vector3 vNorm; float w_by_2 = cylinder_Width * 0.66666f;//to differentiate from Helix float rad = cylinder_Radius; Vector3 vZero = (cylinder_Offset + cylinder_Height / 2) * Vector3.up; vDisk.Add(vZero); for (int i = 0; i < 180; i++) { vPos_Lower = rad * Mathf.Cos(theta) * Vector3.right + rad * Mathf.Sin(theta) * Vector3.forward; float theta_Mod = theta % (Mathf.PI*2f/3f); float lout = rad; if (theta_Mod < 60) { lout = (1f - 0.5f * theta_Mod / (Mathf.PI/ 3f)); } else { lout = (0.5f + 0.5f * (theta_Mod - (Mathf.PI / 3f)) / (Mathf.PI / 3f)); } vPos_Lower *= lout; vPos_Upper = vPos_Lower; vNorm = vPos_Lower.normalized; vPos_Lower += cylinder_Offset * Vector3.up; vInnerLower.Add(vPos_Lower - w_by_2 * vNorm); vOuterLower.Add(vPos_Lower + w_by_2 * vNorm); vPos_Lower += (cylinder_Height / 2) * Vector3.up; vDisk.Add(vPos_Lower - w_by_2 * vNorm); vPos_Upper += cylinder_Height * Vector3.up + cylinder_Offset * Vector3.up; vInnerUpper.Add(vPos_Upper - w_by_2 * vNorm); vOuterUpper.Add(vPos_Upper + w_by_2 * vNorm); theta += delta_theta; } amd.Add(MeshDraft.Band(vOuterLower, vInnerLower)); amd.Add(MeshDraft.Band(vInnerUpper, vOuterUpper)); amd.Add(MeshDraft.Band(vInnerLower, vInnerUpper)); amd.Add(MeshDraft.Band(vOuterUpper, vOuterLower)); if (bAdd_Disk) { amd.Add(MeshDraft.TriangleFan(vDisk)); } GetComponent<MeshFilter>().mesh = amd.ToMeshInternal(); } |