public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append('{'); WriteName(sb, "V0"); sb.Append(V0.ToString() + ","); WriteName(sb, "V1"); sb.Append(V1.ToString() + ","); WriteName(sb, "V2"); sb.Append(V2.ToString() + ","); WriteName(sb, "V3"); sb.Append(V3.ToString() + ","); WriteName(sb, "V4"); sb.Append(V4.ToString() + ","); WriteName(sb, "V5"); sb.Append(V5.ToString() + ","); WriteName(sb, "V6"); sb.Append(V6.ToString() + ","); WriteName(sb, "V7"); sb.Append(V7.ToString() + ","); WriteName(sb, "V8"); sb.Append(V8.ToString() + ","); WriteName(sb, "V9"); sb.Append(V9.ToString() + ","); sb.Length--; sb.Append('}'); return(sb.ToString()); }
// Use this for initialization void Start() { if (BuyCarScript.V01A == 0) { BuyCarScript.V01A = 2; } if (BuyCarScript.V01A == 2) { V1.SetActive(true); } if (BuyCarScript.V02A == 2) { V2.SetActive(true); } if (BuyCarScript.V03A == 2) { V3.SetActive(true); } if (BuyCarScript.V04A == 2) { V4.SetActive(true); } if (BuyCarScript.V05A == 2) { V5.SetActive(true); } if (BuyCarScript.V06A == 2) { V6.SetActive(true); } if (BuyCarScript.V07A == 2) { V7.SetActive(true); } if (BuyCarScript.V08A == 2) { V8.SetActive(true); } if (BuyCarScript.V09A == 2) { V9.SetActive(true); } if (BuyCarScript.V10A == 2) { V10.SetActive(true); } car = true; }
public void Left() { if (V2.activeInHierarchy == true) { V1.SetActive(true); V2.SetActive(false); V3.SetActive(false); V4.SetActive(false); V5.SetActive(false); V6.SetActive(false); V7.SetActive(false); V8.SetActive(false); V9.SetActive(false); V10.SetActive(false); } else if (V3.activeInHierarchy == true) { V1.SetActive(false); V2.SetActive(true); V3.SetActive(false); V4.SetActive(false); V5.SetActive(false); V6.SetActive(false); V7.SetActive(false); V8.SetActive(false); V9.SetActive(false); V10.SetActive(false); } else if (V4.activeInHierarchy == true) { V1.SetActive(false); V2.SetActive(false); V3.SetActive(true); V4.SetActive(false); V5.SetActive(false); V6.SetActive(false); V7.SetActive(false); V8.SetActive(false); V9.SetActive(false); V10.SetActive(false); } else if (V5.activeInHierarchy == true) { V1.SetActive(false); V2.SetActive(false); V3.SetActive(false); V4.SetActive(true); V5.SetActive(false); V6.SetActive(false); V7.SetActive(false); V8.SetActive(false); V9.SetActive(false); V10.SetActive(false); } else if (V6.activeInHierarchy == true) { V1.SetActive(false); V2.SetActive(false); V3.SetActive(false); V4.SetActive(false); V5.SetActive(true); V6.SetActive(false); V7.SetActive(false); V8.SetActive(false); V9.SetActive(false); V10.SetActive(false); } else if (V7.activeInHierarchy == true) { V1.SetActive(false); V2.SetActive(false); V3.SetActive(false); V4.SetActive(false); V5.SetActive(false); V6.SetActive(true); V7.SetActive(false); V8.SetActive(false); V9.SetActive(false); V10.SetActive(false); } else if (V8.activeInHierarchy == true) { V1.SetActive(false); V2.SetActive(false); V3.SetActive(false); V4.SetActive(false); V5.SetActive(false); V6.SetActive(false); V7.SetActive(true); V8.SetActive(false); V9.SetActive(false); V10.SetActive(false); } else if (V9.activeInHierarchy == true) { V1.SetActive(false); V2.SetActive(false); V3.SetActive(false); V4.SetActive(false); V5.SetActive(false); V6.SetActive(false); V7.SetActive(false); V8.SetActive(true); V9.SetActive(false); V10.SetActive(false); } else if (V10.activeInHierarchy == true) { V1.SetActive(false); V2.SetActive(false); V3.SetActive(false); V4.SetActive(false); V5.SetActive(false); V6.SetActive(false); V7.SetActive(false); V8.SetActive(false); V9.SetActive(true); V10.SetActive(false); } }
List <V7> temp_V7_list3 = new List <V7>(); // this list will be used for sorting // Start is called before the first frame update void Start() { old_position1 = transform.position; // antenna #1 position in the beginning // in x axis ant1_min_x = old_position1.x - Reachable_distance; ant1_max_x = old_position1.x + Reachable_distance; // in z axis ant1_min_z = old_position1.z - Reachable_distance; ant1_max_z = old_position1.z + Reachable_distance; /////////////////////////////////////////////////////////////////////////////////// /// Start reading data from other scripts /////////////////////////////////////////////////////////////////////////////////// // reading generated MPCs from the mpc spawner script GameObject MPC_Spawner = GameObject.Find("Direct_Solution"); Correcting_polygons MPC_Script = MPC_Spawner.GetComponent <Correcting_polygons>(); MPC1 = MPC_Script.SeenV6_MPC1; V7MPC1 = MPC_Script.SeenV7_MPC1; MPC2 = MPC_Script.SeenV6_MPC2; V7MPC2 = MPC_Script.SeenV7_MPC2; MPC3 = MPC_Script.SeenV6_MPC3; V7MPC3 = MPC_Script.SeenV7_MPC3; // sorted lists by x and z: MPC1 byX_V7MPC1 = V7MPC1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); byZ_V7MPC1 = V7MPC1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // sorted lists by x and z: MPC1 byX_V7MPC2 = V7MPC2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); byZ_V7MPC2 = V7MPC2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // sorted lists by x and z: MPC1 byX_V7MPC3 = V7MPC3.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); byZ_V7MPC3 = V7MPC3.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); /////////////////////////////////////////////////////////////////////////////////// /// Finish reading data from other scripts /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// // search for seen mpcs within the search area /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// /// MPC1 /////////////////////////////////////////////////////////////////////////////////// //Debug.Log("Check0"); for (int i = 0; i < MPC1.Count; i++) { if ((MPC1[i].Coordinates.x > ant1_min_x) && (MPC1[i].Coordinates.x < ant1_max_x) && (MPC1[i].Coordinates.z > ant1_min_z) && (MPC1[i].Coordinates.z < ant1_max_z)) { //inarea_MPC1.Add(i); V7 temp_V7 = new V7(MPC1[i], i); temp_V7_list1.Add(temp_V7); inarea_MPC1.Add(i); } } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists // for MPC1 XMIN_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7[0].Number); XMAX_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7[XsortV7.Count - 1].Number); ZMIN_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7[0].Number); ZMAX_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7[XsortV7.Count - 1].Number); /////////////////////////////////////////////////////////////////////////////////// /// MPC2 /////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < MPC2.Count; i++) { if ((MPC2[i].Coordinates.x > ant1_min_x) && (MPC2[i].Coordinates.x < ant1_max_x) && (MPC2[i].Coordinates.z > ant1_min_z) && (MPC2[i].Coordinates.z < ant1_max_z)) { //inarea_MPC1.Add(i); V7 temp_V7 = new V7(MPC2[i], i); temp_V7_list2.Add(temp_V7); inarea_MPC2.Add(i); } } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists // for MPC2 XMIN_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[0].Number); XMAX_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[XsortV7_2.Count - 1].Number); ZMIN_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[0].Number); ZMAX_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[XsortV7_2.Count - 1].Number); /////////////////////////////////////////////////////////////////////////////////// /// MPC3 /////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < MPC3.Count; i++) { if ((MPC3[i].Coordinates.x > ant1_min_x) && (MPC3[i].Coordinates.x < ant1_max_x) && (MPC3[i].Coordinates.z > ant1_min_z) && (MPC3[i].Coordinates.z < ant1_max_z)) { //inarea_MPC1.Add(i); V7 temp_V7 = new V7(MPC3[i], i); temp_V7_list3.Add(temp_V7); inarea_MPC3.Add(i); } } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists // for MPC3 XMIN_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[0].Number); XMAX_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[XsortV7_3.Count - 1].Number); ZMIN_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[0].Number); ZMAX_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[XsortV7_3.Count - 1].Number); }
// Update is called once per frame private void FixedUpdate() { fixed_update_count += 1; d1 = transform.position - old_position1; fwd = transform.forward; up = transform.up; //Debug.DrawRay(transform.position, fwd, Color.red); //Debug.DrawRay(transform.position, up, Color.yellow); // update the old position. Now, current position become old for the next position. old_position1 = transform.position; // in x axis // for MPC1 ant1_min_x1 += d1.x; ant1_max_x1 += d1.x; // for MPC2 ant1_min_x2 += d1.x; ant1_max_x2 += d1.x; // for MPC3 ant1_min_x3 += d1.x; ant1_max_x3 += d1.x; // in z axis // for MPC1 ant1_min_z1 += d1.z; ant1_max_z1 += d1.z; // for MPC2 ant1_min_z2 += d1.z; ant1_max_z2 += d1.z; // for MPC3 ant1_min_z3 += d1.z; ant1_max_z3 += d1.z; if (Activate_MPC1 || Activate_MPC2 || Activate_MPC3) { // drawing the area around the moving car DrawArea(ant1_min_x1, ant1_max_x1, ant1_min_z1, ant1_max_z1); } ToRemove(temp_V7_list0, d1, ant1_min_x1, ant1_max_x1, ant1_min_z1, ant1_max_z1, out List <int> ToBeRemoved0); ToRemove(temp_V7_list1, d1, ant1_min_x1, ant1_max_x1, ant1_min_z1, ant1_max_z1, out List <int> ToBeRemoved1); ToRemove(temp_V7_list2, d1, ant1_min_x2, ant1_max_x2, ant1_min_z2, ant1_max_z2, out List <int> ToBeRemoved2); ToRemove(temp_V7_list3, d1, ant1_min_x3, ant1_max_x3, ant1_min_z3, ant1_max_z3, out List <int> ToBeRemoved3); if (ToBeRemoved0.Count > 0) // DMC { // remove the elements listed in ToBeRemoved list inarea_DMC = inarea_DMC.Except(ToBeRemoved0).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved0.Count; i++) { temp_V7_list0.RemoveAll(elm => elm.Number == ToBeRemoved0[i]); } } if (ToBeRemoved1.Count > 0) { // remove the elements listed in ToBeRemoved list inarea_MPC1 = inarea_MPC1.Except(ToBeRemoved1).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved1.Count; i++) { temp_V7_list1.RemoveAll(elm => elm.Number == ToBeRemoved1[i]); } // the below function somewhy does not work for class V7 // temp_V7_list1 = temp_V7_list1.Except(temp_remove_list).ToList(); // drawing update if (Activate_MPC1) { // GameObjects can't be used in NativeArray and in all Jobs systems // NativeArray<GameObject> asd = new NativeArray<GameObject>(ToBeRemoved1.Count, Allocator.TempJob); // it won't work for (int i = 0; i < ToBeRemoved1.Count; i++) { int temp_number = ToBeRemoved1[i]; string temp_name = "mpc1 #" + temp_number; near_MPC1 = GameObject.Find(temp_name); near_MPC1.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } } if (ToBeRemoved2.Count > 0) { // remove the elements listed in ToBeRemoved list inarea_MPC2 = inarea_MPC2.Except(ToBeRemoved2).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved2.Count; i++) { temp_V7_list2.RemoveAll(elm => elm.Number == ToBeRemoved2[i]); } // drawing update if (Activate_MPC2) { for (int i = 0; i < ToBeRemoved2.Count; i++) { int temp_number = ToBeRemoved2[i]; string temp_name = "mpc2 #" + temp_number; near_MPC2 = GameObject.Find(temp_name); near_MPC2.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } } if (ToBeRemoved3.Count > 0) { // remove the elements listed in ToBeRemoved list inarea_MPC3 = inarea_MPC3.Except(ToBeRemoved3).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved3.Count; i++) { temp_V7_list3.RemoveAll(elm => elm.Number == ToBeRemoved3[i]); } // drawing update if (Activate_MPC3) { for (int i = 0; i < ToBeRemoved3.Count; i++) { int temp_number = ToBeRemoved3[i]; string temp_name = "mpc3 #" + temp_number; near_MPC3 = GameObject.Find(temp_name); near_MPC3.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } } ToAdd(byX_V7DMC, byZ_V7DMC, d1, ant1_min_x1, XMIN_index0, ant1_max_x1, XMAX_index0, ant1_min_z1, ZMIN_index0, ant1_max_z1, ZMAX_index0, out List <int> ToBeAdd0); ToAdd(byX_V7MPC1, byZ_V7MPC1, d1, ant1_min_x1, XMIN_index1, ant1_max_x1, XMAX_index1, ant1_min_z1, ZMIN_index1, ant1_max_z1, ZMAX_index1, out List <int> ToBeAdd1); ToAdd(byX_V7MPC2, byZ_V7MPC2, d1, ant1_min_x2, XMIN_index2, ant1_max_x2, XMAX_index2, ant1_min_z2, ZMIN_index2, ant1_max_z2, ZMAX_index2, out List <int> ToBeAdd2); ToAdd(byX_V7MPC3, byZ_V7MPC3, d1, ant1_min_x3, XMIN_index3, ant1_max_x3, XMAX_index3, ant1_min_z3, ZMIN_index3, ant1_max_z3, ZMAX_index3, out List <int> ToBeAdd3); if (ToBeAdd0.Count > 0) { // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_DMC.Count + ToBeAdd0.Count); twolists.AddRange(inarea_DMC); twolists.AddRange(ToBeAdd0); inarea_DMC = twolists; for (int i = 0; i < ToBeAdd0.Count; i++) { V7 temp_V7 = new V7(DMC[ToBeAdd0[i]], ToBeAdd0[i]); temp_V7_list0.Add(temp_V7); } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_0 = temp_V7_list0.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_0 = temp_V7_list0.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index0 = byX_V7DMC.FindIndex(V7elm => V7elm.Number == XsortV7_0[0].Number); XMAX_index0 = byX_V7DMC.FindIndex(V7elm => V7elm.Number == XsortV7_0[XsortV7_0.Count - 1].Number); ZMIN_index0 = byZ_V7DMC.FindIndex(V7elm => V7elm.Number == ZsortV7_0[0].Number); ZMAX_index0 = byZ_V7DMC.FindIndex(V7elm => V7elm.Number == ZsortV7_0[XsortV7_0.Count - 1].Number); } if (ToBeAdd1.Count > 0) { // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_MPC1.Count + ToBeAdd1.Count); twolists.AddRange(inarea_MPC1); twolists.AddRange(ToBeAdd1); inarea_MPC1 = twolists; for (int i = 0; i < ToBeAdd1.Count; i++) { V7 temp_V7 = new V7(MPC1[ToBeAdd1[i]], ToBeAdd1[i]); temp_V7_list1.Add(temp_V7); } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_1 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_1 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7_1[0].Number); XMAX_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7_1[XsortV7_1.Count - 1].Number); ZMIN_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7_1[0].Number); ZMAX_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7_1[XsortV7_1.Count - 1].Number); } if (ToBeAdd2.Count > 0) { // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_MPC2.Count + ToBeAdd2.Count); twolists.AddRange(inarea_MPC2); twolists.AddRange(ToBeAdd2); inarea_MPC2 = twolists; // Update edges of the updated list InArea: See explanation about the complexity in MPC1 for (int i = 0; i < ToBeAdd2.Count; i++) { V7 temp_V7 = new V7(MPC2[ToBeAdd2[i]], ToBeAdd2[i]); temp_V7_list2.Add(temp_V7); } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[0].Number); XMAX_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[XsortV7_2.Count - 1].Number); ZMIN_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[0].Number); ZMAX_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[XsortV7_2.Count - 1].Number); } if (ToBeAdd3.Count > 0) { // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_MPC3.Count + ToBeAdd3.Count); twolists.AddRange(inarea_MPC3); twolists.AddRange(ToBeAdd3); inarea_MPC3 = twolists; // Update edges of the updated list InArea: See explanation about the complexity in MPC1 for (int i = 0; i < ToBeAdd3.Count; i++) { //Debug.Log("Fixed update step = " + fixed_update_count + "; ToBeAdd3[" + i + "] = " + ToBeAdd3[i] + "; byX_V7MPC3 count = " + byX_V7MPC3.Count + "; byZ_V7MPC3 = " + byX_V7MPC3.Count); V7 temp_V7 = new V7(MPC3[ToBeAdd3[i]], ToBeAdd3[i]); temp_V7_list3.Add(temp_V7); } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[0].Number); XMAX_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[XsortV7_3.Count - 1].Number); ZMIN_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[0].Number); ZMAX_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[XsortV7_3.Count - 1].Number); } //float startTime_org = Time.realtimeSinceStartup; seen_MPC1 = new List <int>(); for (int i = 0; i < inarea_MPC1.Count; i++) { Vector3 temp_direction = MPC1[inarea_MPC1[i]].Coordinates - transform.position; if (Vector3.Dot(MPC1[inarea_MPC1[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, MPC1[inarea_MPC1[i]].Coordinates)) { seen_MPC1.Add(inarea_MPC1[i]); // Adding antenna radiation pattern if (Antenna_pattern) { float cos_az = Vector3.Dot(temp_direction.normalized, fwd); float cos_el = Vector3.Dot(temp_direction.normalized, up); float horizont_att = 0.5f - 0.5f * cos_az; float vertical_att; if (cos_el <= 0) { vertical_att = cos_el + 1; } else { vertical_att = 1 - cos_el; } //Debug.Log(vertical_att * horizont_att); seen_MPC1_att.Add(vertical_att * horizont_att); } else { seen_MPC1_att.Add(1f); } if (Activate_MPC1) { int temp_number = inarea_MPC1[i]; string temp_name = "mpc1 #" + temp_number; near_MPC1 = GameObject.Find(temp_name); near_MPC1.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } } seen_MPC2 = new List <int>(); for (int i = 0; i < inarea_MPC2.Count; i++) { Vector3 temp_direction = MPC2[inarea_MPC2[i]].Coordinates - transform.position; if (Vector3.Dot(MPC2[inarea_MPC2[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, MPC2[inarea_MPC2[i]].Coordinates)) { seen_MPC2.Add(inarea_MPC2[i]); if (Antenna_pattern) { float cos_az = Vector3.Dot(temp_direction.normalized, fwd); float cos_el = Vector3.Dot(temp_direction.normalized, up); float horizont_att = 0.5f - 0.5f * cos_az; float vertical_att; if (cos_el <= 0) { vertical_att = cos_el + 1; } else { vertical_att = 1 - cos_el; } //Debug.Log(vertical_att * horizont_att); seen_MPC2_att.Add(vertical_att * horizont_att); } else { seen_MPC2_att.Add(1f); } if (Activate_MPC2) { int temp_number = inarea_MPC2[i]; string temp_name = "mpc2 #" + temp_number; near_MPC2 = GameObject.Find(temp_name); near_MPC2.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } } seen_MPC3 = new List <int>(); for (int i = 0; i < inarea_MPC3.Count; i++) { Vector3 temp_direction = MPC3[inarea_MPC3[i]].Coordinates - transform.position; if (Vector3.Dot(MPC3[inarea_MPC3[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, MPC3[inarea_MPC3[i]].Coordinates)) { seen_MPC3.Add(inarea_MPC3[i]); if (Antenna_pattern) { float cos_az = Vector3.Dot(temp_direction.normalized, fwd); float cos_el = Vector3.Dot(temp_direction.normalized, up); float horizont_att = 0.5f - 0.5f * cos_az; float vertical_att; if (cos_el <= 0) { vertical_att = cos_el + 1; } else { vertical_att = 1 - cos_el; } //Debug.Log(vertical_att * horizont_att); seen_MPC3_att.Add(vertical_att * horizont_att); } else { seen_MPC3_att.Add(1f); } if (Activate_MPC3) { int temp_number = inarea_MPC3[i]; string temp_name = "mpc3 #" + temp_number; near_MPC3 = GameObject.Find(temp_name); near_MPC3.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } } //float startTime_org = Time.realtimeSinceStartup; seen_DMC = new List <int>(); for (int i = 0; i < inarea_DMC.Count; i++) { Vector3 temp_direction = DMC[inarea_DMC[i]].Coordinates - transform.position; if (Vector3.Dot(DMC[inarea_DMC[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, DMC[inarea_DMC[i]].Coordinates)) { seen_DMC.Add(inarea_DMC[i]); // Adding antenna radiation pattern if (Antenna_pattern) { float cos_az = Vector3.Dot(temp_direction.normalized, fwd); float cos_el = Vector3.Dot(temp_direction.normalized, up); float horizont_att = 0.5f - 0.5f * cos_az; float vertical_att; if (cos_el <= 0) { vertical_att = cos_el + 1; } else { vertical_att = 1 - cos_el; } //Debug.Log(vertical_att * horizont_att); seen_DMC_att.Add(vertical_att * horizont_att); } else { seen_DMC_att.Add(1f); } } } } //Debug.Log("Check Time Org: " + ((Time.realtimeSinceStartup - startTime_org) * 1000000f) + " microsec"); /* * float startTime_upd = Time.realtimeSinceStartup; * NativeArray<RaycastHit> results = new NativeArray<RaycastHit>(inarea_DMC.Count, Allocator.TempJob);//(inarea_MPC1.Count + inarea_MPC2.Count + inarea_MPC3.Count, Allocator.TempJob); * NativeArray<RaycastCommand> commands = new NativeArray<RaycastCommand>(inarea_DMC.Count, Allocator.TempJob);//(inarea_MPC1.Count + inarea_MPC2.Count + inarea_MPC3.Count, Allocator.TempJob); * var seen_DMC_upd = new List<int>(); * //var seen_MPC1_upd = new List<int>(); * //var seen_MPC2_upd = new List<int>(); * //var seen_MPC3_upd = new List<int>(); * * for (int i = 0; i < inarea_DMC.Count; i++) * { * Vector3 temp_direction = DMC[inarea_DMC[i]].Coordinates - transform.position; * commands[i] = new RaycastCommand(transform.position, temp_direction.normalized, temp_direction.magnitude); * } * * JobHandle RayCast_handle = RaycastCommand.ScheduleBatch(commands, results, 5, default); * RayCast_handle.Complete(); * for (int i = 0; i < inarea_DMC.Count; i++) * { * if (results[i].collider == null) * { * seen_DMC_upd.Add(inarea_DMC[i]); * } * } * ////// comment here * for (int i = 0; i < inarea_MPC1.Count; i++) * { * Vector3 temp_direction = MPC1[inarea_MPC1[i]].Coordinates - transform.position; * commands[i] = new RaycastCommand(transform.position, temp_direction.normalized, temp_direction.magnitude); * } * for (int i = 0; i < inarea_MPC2.Count; i++) * { * Vector3 temp_direction = MPC2[inarea_MPC2[i]].Coordinates - transform.position; * commands[inarea_MPC1.Count + i] = new RaycastCommand(transform.position, temp_direction.normalized, temp_direction.magnitude); * } * for (int i = 0; i < inarea_MPC3.Count; i++) * { * Vector3 temp_direction = MPC3[inarea_MPC3[i]].Coordinates - transform.position; * commands[inarea_MPC1.Count + inarea_MPC2.Count + i] = new RaycastCommand(transform.position, temp_direction.normalized, temp_direction.magnitude); * } * * for (int i = 0; i < inarea_MPC1.Count; i++) * { * if (results[i].collider == null) * { * seen_MPC1_upd.Add(inarea_MPC1[i]); * } * } * for (int i = inarea_MPC1.Count; i < inarea_MPC1.Count + inarea_MPC2.Count; i++) * { * if (results[i].collider == null) * { * seen_MPC2_upd.Add(inarea_MPC2[i - inarea_MPC1.Count]); * } * } * for (int i = inarea_MPC1.Count + inarea_MPC2.Count; i < results.Length; i++) * { * if (results[i].collider == null) * { * seen_MPC3_upd.Add(inarea_MPC3[i - inarea_MPC1.Count - inarea_MPC2.Count]); * } * } * ////// comment here ends * * // Dispose the buffers * results.Dispose(); * commands.Dispose(); * * Debug.Log("Check Time Upd: " + ((Time.realtimeSinceStartup - startTime_upd) * 1000000f) + " microsec"); */ }
// Update is called once per frame void Update() { d1 = transform.position - old_position1; // update the old position. Now, current position become old for the next position. old_position1 = transform.position; // in x axis ant1_min_x += d1.x; ant1_max_x += d1.x; // in z axis ant1_min_z += d1.z; ant1_max_z += d1.z; if (Activate_MPC1 || Activate_MPC2 || Activate_MPC3) { // drawing the area around the moving car DrawArea(ant1_min_x, ant1_max_x, ant1_min_z, ant1_max_z); } ToRemove(temp_V7_list1, d1, ant1_min_x, ant1_max_x, ant1_min_z, ant1_max_z, out List <int> ToBeRemoved1); ToRemove(temp_V7_list2, d1, ant1_min_x, ant1_max_x, ant1_min_z, ant1_max_z, out List <int> ToBeRemoved2); ToRemove(temp_V7_list3, d1, ant1_min_x, ant1_max_x, ant1_min_z, ant1_max_z, out List <int> ToBeRemoved3); /* //this approach also slower than the standard one * * float startTime2 = Time.realtimeSinceStartup; * ToRemoveParralel(temp_V7_list1, inarea_MPC1, d1, ant1_min_x, ant1_max_x, ant1_min_z, ant1_max_z, out List<int> ToBeRomeved); * Debug.Log("Check 2: " + ((Time.realtimeSinceStartup - startTime2) * 1000000f) + " microsec"); */ if (ToBeRemoved1.Count > 0) { // Debug.Log("Something to delete"); // remove the elements listed in ToBeRemoved list inarea_MPC1 = inarea_MPC1.Except(ToBeRemoved1).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved1.Count; i++) { temp_V7_list1.RemoveAll(elm => elm.Number == ToBeRemoved1[i]); } // the below function somewhy does not work for class V7 // temp_V7_list1 = temp_V7_list1.Except(temp_remove_list).ToList(); // drawing update if (Activate_MPC1) { // GameObjects can't be used in NativeArray and in all Jobs systems // NativeArray<GameObject> asd = new NativeArray<GameObject>(ToBeRemoved1.Count, Allocator.TempJob); // it won't work for (int i = 0; i < ToBeRemoved1.Count; i++) { int temp_number = ToBeRemoved1[i]; string temp_name = "mpc1 #" + temp_number; near_MPC1 = GameObject.Find(temp_name); near_MPC1.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } } if (ToBeRemoved2.Count > 0) { // remove the elements listed in ToBeRemoved list inarea_MPC2 = inarea_MPC2.Except(ToBeRemoved2).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved2.Count; i++) { temp_V7_list2.RemoveAll(elm => elm.Number == ToBeRemoved2[i]); } // drawing update if (Activate_MPC2) { for (int i = 0; i < ToBeRemoved2.Count; i++) { int temp_number = ToBeRemoved2[i]; string temp_name = "mpc2 #" + temp_number; near_MPC2 = GameObject.Find(temp_name); near_MPC2.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } } if (ToBeRemoved3.Count > 0) { // remove the elements listed in ToBeRemoved list inarea_MPC3 = inarea_MPC3.Except(ToBeRemoved3).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved3.Count; i++) { temp_V7_list3.RemoveAll(elm => elm.Number == ToBeRemoved3[i]); } // drawing update if (Activate_MPC3) { for (int i = 0; i < ToBeRemoved3.Count; i++) { int temp_number = ToBeRemoved3[i]; string temp_name = "mpc3 #" + temp_number; near_MPC3 = GameObject.Find(temp_name); near_MPC3.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } } ToAdd(byX_V7MPC1, byZ_V7MPC1, d1, ant1_min_x, XMIN_index1, ant1_max_x, XMAX_index1, ant1_min_z, ZMIN_index1, ant1_max_z, ZMAX_index1, out List <int> ToBeAdd1); ToAdd(byX_V7MPC2, byZ_V7MPC2, d1, ant1_min_x, XMIN_index2, ant1_max_x, XMAX_index2, ant1_min_z, ZMIN_index2, ant1_max_z, ZMAX_index2, out List <int> ToBeAdd2); ToAdd(byX_V7MPC3, byZ_V7MPC3, d1, ant1_min_x, XMIN_index3, ant1_max_x, XMAX_index3, ant1_min_z, ZMIN_index3, ant1_max_z, ZMAX_index3, out List <int> ToBeAdd3); if (ToBeAdd1.Count > 0) { //Debug.Log("Something to add"); // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_MPC1.Count + ToBeAdd1.Count); twolists.AddRange(inarea_MPC1); twolists.AddRange(ToBeAdd1); inarea_MPC1 = twolists; /* * float startTime1 = Time.realtimeSinceStartup; * * // Update edges of the updated list InArea * List<V7> test_V7_list1 = new List<V7>(); * for (int i = 0; i < inarea_MPC1.Count; i++) * { * V7 temp_V7 = new V7(MPC1[inarea_MPC1[i]], inarea_MPC1[i]); * test_V7_list1.Add(temp_V7); * } * * Debug.Log("Check 1: " + ((Time.realtimeSinceStartup - startTime1) * 1000000f) + "microsec, size of the list = " + test_V7_list1.Count); */ // this approach tens of times quicker // float startTime2 = Time.realtimeSinceStartup; for (int i = 0; i < ToBeAdd1.Count; i++) { V7 temp_V7 = new V7(MPC1[ToBeAdd1[i]], ToBeAdd1[i]); temp_V7_list1.Add(temp_V7); } // Debug.Log("Check 2: " + ((Time.realtimeSinceStartup - startTime2) * 1000000f) + "microsec, size of the list = " + temp_V7_list1.Count); // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_1 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_1 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7_1[0].Number); XMAX_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7_1[XsortV7_1.Count - 1].Number); ZMIN_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7_1[0].Number); ZMAX_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7_1[XsortV7_1.Count - 1].Number); } if (ToBeAdd2.Count > 0) { // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_MPC2.Count + ToBeAdd2.Count); twolists.AddRange(inarea_MPC2); twolists.AddRange(ToBeAdd2); inarea_MPC2 = twolists; // Update edges of the updated list InArea: See explanation about the complexity in MPC1 for (int i = 0; i < ToBeAdd2.Count; i++) { V7 temp_V7 = new V7(MPC2[ToBeAdd2[i]], ToBeAdd2[i]); temp_V7_list2.Add(temp_V7); } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[0].Number); XMAX_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[XsortV7_2.Count - 1].Number); ZMIN_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[0].Number); ZMAX_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[XsortV7_2.Count - 1].Number); } if (ToBeAdd3.Count > 0) { // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_MPC3.Count + ToBeAdd3.Count); twolists.AddRange(inarea_MPC3); twolists.AddRange(ToBeAdd3); inarea_MPC3 = twolists; // Update edges of the updated list InArea: See explanation about the complexity in MPC1 for (int i = 0; i < ToBeAdd3.Count; i++) { V7 temp_V7 = new V7(MPC3[ToBeAdd3[i]], ToBeAdd3[i]); temp_V7_list3.Add(temp_V7); } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[0].Number); XMAX_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[XsortV7_3.Count - 1].Number); ZMIN_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[0].Number); ZMAX_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[XsortV7_3.Count - 1].Number); } float startTime1 = Time.realtimeSinceStartup; seen_MPC1 = new List <int>(); for (int i = 0; i < inarea_MPC1.Count; i++) { Vector3 temp_direction = MPC1[inarea_MPC1[i]].Coordinates - transform.position; if (Vector3.Dot(MPC1[inarea_MPC1[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, MPC1[inarea_MPC1[i]].Coordinates)) { seen_MPC1.Add(inarea_MPC1[i]); if (Activate_MPC1) { int temp_number = inarea_MPC1[i]; string temp_name = "mpc1 #" + temp_number; near_MPC1 = GameObject.Find(temp_name); near_MPC1.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } } seen_MPC2 = new List <int>(); for (int i = 0; i < inarea_MPC2.Count; i++) { Vector3 temp_direction = MPC2[inarea_MPC2[i]].Coordinates - transform.position; if (Vector3.Dot(MPC2[inarea_MPC2[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, MPC2[inarea_MPC2[i]].Coordinates)) { seen_MPC2.Add(inarea_MPC2[i]); if (Activate_MPC2) { int temp_number = inarea_MPC2[i]; string temp_name = "mpc2 #" + temp_number; near_MPC2 = GameObject.Find(temp_name); near_MPC2.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } } seen_MPC3 = new List <int>(); for (int i = 0; i < inarea_MPC3.Count; i++) { Vector3 temp_direction = MPC3[inarea_MPC3[i]].Coordinates - transform.position; if (Vector3.Dot(MPC3[inarea_MPC3[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, MPC3[inarea_MPC3[i]].Coordinates)) { seen_MPC3.Add(inarea_MPC3[i]); if (Activate_MPC3) { int temp_number = inarea_MPC3[i]; string temp_name = "mpc3 #" + temp_number; near_MPC3 = GameObject.Find(temp_name); near_MPC3.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } } //float time1 = (Time.realtimeSinceStartup - startTime1) *1000000f; Debug.Log("Check 1: " + ((Time.realtimeSinceStartup - startTime1) * 1000000f) + " microsec"); /* * var threelists = new List<V7>(temp_V7_list1.Count + temp_V7_list2.Count + temp_V7_list3.Count); * threelists.AddRange(temp_V7_list1); * threelists.AddRange(temp_V7_list2); * threelists.AddRange(temp_V7_list3); * * float startTime2 = Time.realtimeSinceStartup; * //Seen_MPC_Parallel(List < V7 > InAreaMPC, Vector3 position, out List<int> SeenMPCID) * * Seen_MPC_Parallel(threelists, transform.position, out List<int> SeenMPCID); * //Seen_MPC_Parallel(temp_V7_list1, transform.position, out List<int> SeenMPCID1); * //Seen_MPC_Parallel(temp_V7_list2, transform.position, out List<int> SeenMPCID2); * //Seen_MPC_Parallel(temp_V7_list3, transform.position, out List<int> SeenMPCID3); * * //float time2 = (Time.realtimeSinceStartup - startTime2) * 1000000f; * Debug.Log("Check 2: " + ((Time.realtimeSinceStartup - startTime2) * 1000000f) + " microsec"); */ }
// Start is called before the first frame update void Start() { old_position1 = transform.position; // antenna #1 position in the beginning // in x axis // for MPC1 and DMC ant1_min_x1 = old_position1.x - ReachableDistance; ant1_max_x1 = old_position1.x + ReachableDistance; // for MPC2 ant1_min_x2 = old_position1.x - ReachableDistance / 2; ant1_max_x2 = old_position1.x + ReachableDistance / 2; // for MPC3 ant1_min_x3 = old_position1.x - ReachableDistance / 3; ant1_max_x3 = old_position1.x + ReachableDistance / 3; // in z axis // for MPC1 and DMC ant1_min_z1 = old_position1.z - ReachableDistance; ant1_max_z1 = old_position1.z + ReachableDistance; // for MPC2 ant1_min_z2 = old_position1.z - ReachableDistance / 2; ant1_max_z2 = old_position1.z + ReachableDistance / 2; // for MPC3 ant1_min_z3 = old_position1.z - ReachableDistance / 3; ant1_max_z3 = old_position1.z + ReachableDistance / 3; /////////////////////////////////////////////////////////////////////////////////// /// Start reading data from other scripts /////////////////////////////////////////////////////////////////////////////////// // reading generated MPCs from the mpc spawner script GameObject MPC_Spawner = GameObject.Find("Direct_Solution"); Correcting_polygons MPC_Script = MPC_Spawner.GetComponent <Correcting_polygons>(); DMC = MPC_Script.SeenV6_DMC; V7DMC = MPC_Script.SeenV7_DMC; MPC1 = MPC_Script.SeenV6_MPC1; V7MPC1 = MPC_Script.SeenV7_MPC1; MPC2 = MPC_Script.SeenV6_MPC2; V7MPC2 = MPC_Script.SeenV7_MPC2; MPC3 = MPC_Script.SeenV6_MPC3; V7MPC3 = MPC_Script.SeenV7_MPC3; // sorted lists by x and z: DMC byX_V7DMC = V7DMC.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); byZ_V7DMC = V7DMC.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // sorted lists by x and z: MPC1 byX_V7MPC1 = V7MPC1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); byZ_V7MPC1 = V7MPC1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // sorted lists by x and z: MPC1 byX_V7MPC2 = V7MPC2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); byZ_V7MPC2 = V7MPC2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // sorted lists by x and z: MPC1 //float startTime_org = Time.realtimeSinceStartup; byX_V7MPC3 = V7MPC3.OrderBy(ASD => ASD.CoordNorm.Coordinates.x).ToList(); //Debug.Log("Check Time Org Sort: " + ((Time.realtimeSinceStartup - startTime_org) * 1000000f) + " microsec"); byZ_V7MPC3 = V7MPC3.OrderBy(QWE => QWE.CoordNorm.Coordinates.z).ToList(); /* * byX_V7MPC3 = V7MPC3;//.OrderBy(ASD => ASD.CoordNorm.Coordinates.x).ToList(); * SortV7byX sortV7ByX = new SortV7byX(); * byX_V7MPC3.Sort(sortV7ByX); * * float startTime_upd = Time.realtimeSinceStartup; * byZ_V7MPC3 = V7MPC3;//.OrderBy(QWE => QWE.CoordNorm.Coordinates.z).ToList(); * SortV7byZ sortV7ByZ = new SortV7byZ(); * byZ_V7MPC3.Sort(sortV7ByZ); * Debug.Log("Check Time Upd Sort: " + ((Time.realtimeSinceStartup - startTime_upd) * 1000000f) + " microsec"); */ /////////////////////////////////////////////////////////////////////////////////// /// Finish reading data from other scripts /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// // search for seen mpcs within the search area /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// /// DMC /////////////////////////////////////////////////////////////////////////////////// //Debug.Log("Check0"); for (int i = 0; i < DMC.Count; i++) { if ((DMC[i].Coordinates.x > ant1_min_x1) && (DMC[i].Coordinates.x < ant1_max_x1) && (DMC[i].Coordinates.z > ant1_min_z1) && (DMC[i].Coordinates.z < ant1_max_z1)) { //inarea_MPC1.Add(i); V7 temp_V7 = new V7(DMC[i], i); temp_V7_list0.Add(temp_V7); inarea_DMC.Add(i); } } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_0 = temp_V7_list0.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_0 = temp_V7_list0.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists // for MPC1 XMIN_index0 = byX_V7DMC.FindIndex(V7elm => V7elm.Number == XsortV7_0[0].Number); XMAX_index0 = byX_V7DMC.FindIndex(V7elm => V7elm.Number == XsortV7_0[XsortV7_0.Count - 1].Number); ZMIN_index0 = byZ_V7DMC.FindIndex(V7elm => V7elm.Number == ZsortV7_0[0].Number); ZMAX_index0 = byZ_V7DMC.FindIndex(V7elm => V7elm.Number == ZsortV7_0[XsortV7_0.Count - 1].Number); /////////////////////////////////////////////////////////////////////////////////// /// MPC1 /////////////////////////////////////////////////////////////////////////////////// //Debug.Log("Check0"); for (int i = 0; i < MPC1.Count; i++) { if ((MPC1[i].Coordinates.x > ant1_min_x1) && (MPC1[i].Coordinates.x < ant1_max_x1) && (MPC1[i].Coordinates.z > ant1_min_z1) && (MPC1[i].Coordinates.z < ant1_max_z1)) { //inarea_MPC1.Add(i); V7 temp_V7 = new V7(MPC1[i], i); temp_V7_list1.Add(temp_V7); inarea_MPC1.Add(i); } } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists // for MPC1 XMIN_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7[0].Number); XMAX_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7[XsortV7.Count - 1].Number); ZMIN_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7[0].Number); ZMAX_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7[XsortV7.Count - 1].Number); /////////////////////////////////////////////////////////////////////////////////// /// MPC2 /////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < MPC2.Count; i++) { if ((MPC2[i].Coordinates.x > ant1_min_x2) && (MPC2[i].Coordinates.x < ant1_max_x2) && (MPC2[i].Coordinates.z > ant1_min_z2) && (MPC2[i].Coordinates.z < ant1_max_z2)) { //inarea_MPC1.Add(i); V7 temp_V7 = new V7(MPC2[i], i); temp_V7_list2.Add(temp_V7); inarea_MPC2.Add(i); } } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists // for MPC2 XMIN_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[0].Number); XMAX_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[XsortV7_2.Count - 1].Number); ZMIN_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[0].Number); ZMAX_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[XsortV7_2.Count - 1].Number); /////////////////////////////////////////////////////////////////////////////////// /// MPC3 /////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < MPC3.Count; i++) { if ((MPC3[i].Coordinates.x > ant1_min_x3) && (MPC3[i].Coordinates.x < ant1_max_x3) && (MPC3[i].Coordinates.z > ant1_min_z3) && (MPC3[i].Coordinates.z < ant1_max_z3)) { //inarea_MPC1.Add(i); V7 temp_V7 = new V7(MPC3[i], i); temp_V7_list3.Add(temp_V7); inarea_MPC3.Add(i); } } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists // for MPC3 XMIN_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[0].Number); XMAX_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[XsortV7_3.Count - 1].Number); ZMIN_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[0].Number); ZMAX_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[XsortV7_3.Count - 1].Number); }
// Start is called before the first frame update void Start() { GameObject MPC_Spawner = GameObject.Find("MPC_spawner"); Scatterers_Spawning2 MPC_Script = MPC_Spawner.GetComponent <Scatterers_Spawning2>(); List <Vector3> MPC1 = MPC_Script.MPC1_possiblepositionList; List <Vector3> MPC2 = MPC_Script.MPC2_possiblepositionList; List <Vector3> MPC3 = MPC_Script.MPC3_possiblepositionList; /* * Debug.Log("Number of MPC1 is " + MPC1.Count); * for (int i = 0; i < MPC1.Count; i++) * { * GameObject cleared_sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); * * cleared_sphere.transform.position = MPC1[i]; * Destroy(cleared_sphere.GetComponent<SphereCollider>()); // remove collider * var sphereRenderer = cleared_sphere.GetComponent<Renderer>(); * sphereRenderer.material = MPC2_mat; * cleared_sphere.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); * } */ // Declaring buildings and observation points Buildings = GameObject.FindGameObjectsWithTag("Reflecting_Obstacles"); // The number of observation points should not be too big, a few is enough Observation_Points = GameObject.FindGameObjectsWithTag("Observation_Points"); // Define the main road direction Vector3 main_axis = (Observation_Points[0].transform.position - Observation_Points[1].transform.position).normalized; Vector3 perp_axis = new Vector3(main_axis.z, 0, -main_axis.x); // subset of the seen Buldings List <GameObject> Building_list = new List <GameObject>(); // Going through all observation points for (int k = 0; k < Observation_Points.Length; k++) { // analyzing which buidings are seen for (int b = 0; b < Buildings.Length; b++) { Vector3[] vrtx = Buildings[b].GetComponent <MeshFilter>().mesh.vertices; Vector3[] nrml = Buildings[b].GetComponent <MeshFilter>().mesh.normals; int seen_vrtx_count = 0; for (int v = 0; v < vrtx.Length; v++) { if (vrtx[v].y == 0) { if (!Physics.Linecast(Observation_Points[k].transform.position, vrtx[v] + 1.1f * nrml[v])) { seen_vrtx_count += 1; } } } if (seen_vrtx_count != 0) { if (!Building_list.Contains(Buildings[b])) { Building_list.Add(Buildings[b]); } } } } // deactivating nonseen buildings for (int b = 0; b < Buildings.Length; b++) { if (!Building_list.Contains(Buildings[b])) { Buildings[b].SetActive(false); } } Debug.Log("The number of seen Buildings = " + Building_list.Count); List <Vector3> GlobalMPC1 = new List <Vector3>(); List <Vector3> GlobalMPC2 = new List <Vector3>(); List <Vector3> GlobalMPC3 = new List <Vector3>(); // analyzing each seen building separately for (int k = 0; k < Building_list.Count; k++) { // writing MPCs into a txt file //string writePath; List <string> Obj_List = new List <string>(); Vector3[] vrtx = Building_list[k].GetComponent <MeshFilter>().mesh.vertices; Vector3[] nrml = Building_list[k].GetComponent <MeshFilter>().mesh.normals; List <Vector3> floor_vrtx = new List <Vector3>(); List <Vector3> floor_nrml = new List <Vector3>(); var pairs = new List <V6>(); List <Vector3> possible_vrtx = new List <Vector3>(); List <Vector3> possible_nrml = new List <Vector3>(); for (int l = 0; l < vrtx.Length; l++) { if (vrtx[l].y == 0 && Mathf.Abs(nrml[l].y) < 0.9) { floor_vrtx.Add(vrtx[l]); floor_nrml.Add(nrml[l]); // adding coordinates and normals of the vertices into a single object V6 (like a N x 6 matrix) V6 valid_pair = new V6(vrtx[l], nrml[l]); pairs.Add(valid_pair); } } // finding the edges of each building List <Vector3> SortedByX = floor_vrtx.OrderBy(vertex => vertex.x).ToList(); List <Vector3> SortedByZ = floor_vrtx.OrderBy(vertex => vertex.z).ToList(); float x_l = SortedByX[0].x - WW1; // x left float x_r = SortedByX[SortedByX.Count - 1].x + WW1; // x right float z_d = SortedByZ[0].z - WW1; // z down float z_u = SortedByZ[SortedByX.Count - 1].z + WW1; // z up // searching which scatterers are located near the building NearbyElements(x_l, x_r, z_d, z_u, MPC1, out List <Vector3> NeabyMPC1); NearbyElements(x_l, x_r, z_d, z_u, MPC2, out List <Vector3> NeabyMPC2); NearbyElements(x_l, x_r, z_d, z_u, MPC3, out List <Vector3> NeabyMPC3); ////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Defining areas around building where scatterers can be located ////////////////////////////////////////////////////////////////////////////////////////////////////////// // defining necessary elements for the polygon that connects the last and the first vertices Vector3 n1_0 = floor_nrml[floor_vrtx.Count - 1]; Vector3 p1_0 = floor_vrtx[floor_vrtx.Count - 1]; Vector3 s1_0 = floor_vrtx[floor_vrtx.Count - 1] + WW1 * floor_nrml[floor_vrtx.Count - 1]; Vector3 n2_0 = floor_nrml[0]; Vector3 p2_0 = floor_vrtx[0]; Vector3 s2_0 = floor_vrtx[0] + WW1 * floor_nrml[0]; Area34 area = new Area34(p1_0, s1_0, p2_0, s2_0); //DrawArea(area); PickMPC(n1_0, p1_0, s1_0, n2_0, p2_0, s2_0, NeabyMPC1, out List <V6> MPC1_V6); PickMPC(n1_0, p1_0, s1_0, n2_0, p2_0, s2_0, NeabyMPC2, out List <V6> MPC2_V6); PickMPC(n1_0, p1_0, s1_0, n2_0, p2_0, s2_0, NeabyMPC3, out List <V6> MPC3_V6); //int MPC1_num = 0; for (int ii = 0; ii < MPC1_V6.Count; ii++) { if (!GlobalMPC1.Contains(MPC1_V6[ii].Coordinates)) { SeenV6_MPC1.Add(MPC1_V6[ii]); V7 tempV7_MPC1 = new V7(MPC1_V6[ii], MPC1_num); SeenV7_MPC1.Add(tempV7_MPC1); GlobalMPC1.Add(MPC1_V6[ii].Coordinates); GameObject cleared_sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); cleared_sphere.transform.position = MPC1_V6[ii].Coordinates; Destroy(cleared_sphere.GetComponent <SphereCollider>()); // remove collider // cleared_sphere.name = "Building #" + k + "; mpc1 #" + MPC1_num; cleared_sphere.name = "mpc1 #" + MPC1_num; var sphereRenderer = cleared_sphere.GetComponent <Renderer>(); sphereRenderer.material = MPC1_mat; cleared_sphere.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); MPC1_num += 1; } } //int MPC2_num = 0; for (int ii = 0; ii < MPC2_V6.Count; ii++) { if (!GlobalMPC2.Contains(MPC2_V6[ii].Coordinates)) { SeenV6_MPC2.Add(MPC2_V6[ii]); V7 tempV7_MPC2 = new V7(MPC2_V6[ii], MPC2_num); SeenV7_MPC2.Add(tempV7_MPC2); GlobalMPC2.Add(MPC2_V6[ii].Coordinates); GameObject cleared_sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); cleared_sphere.transform.position = MPC2_V6[ii].Coordinates; Destroy(cleared_sphere.GetComponent <SphereCollider>()); // remove collider cleared_sphere.name = "mpc2 #" + MPC2_num; var sphereRenderer = cleared_sphere.GetComponent <Renderer>(); sphereRenderer.material = MPC2_mat; cleared_sphere.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); MPC2_num += 1; } } //int MPC3_num = 0; for (int ii = 0; ii < MPC3_V6.Count; ii++) { if (!GlobalMPC3.Contains(MPC3_V6[ii].Coordinates)) { SeenV6_MPC3.Add(MPC3_V6[ii]); V7 tempV7_MPC3 = new V7(MPC3_V6[ii], MPC3_num); SeenV7_MPC3.Add(tempV7_MPC3); GlobalMPC3.Add(MPC3_V6[ii].Coordinates); GameObject cleared_sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); cleared_sphere.transform.position = MPC3_V6[ii].Coordinates; Destroy(cleared_sphere.GetComponent <SphereCollider>()); // remove collider cleared_sphere.name = "mpc3 #" + MPC3_num; var sphereRenderer = cleared_sphere.GetComponent <Renderer>(); sphereRenderer.material = MPC3_mat; cleared_sphere.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); MPC3_num += 1; } } // draw areas for all vertices Vector3 point1 = new Vector3(0.0f, 0.0f, 0.0f); Vector3 point2 = new Vector3(0.0f, 0.0f, 0.0f); Vector3 shift1 = new Vector3(0.0f, 0.0f, 0.0f); Vector3 shift2 = new Vector3(0.0f, 0.0f, 0.0f); for (int l = 0; l < floor_vrtx.Count - 1; l++) { point1 = floor_vrtx[l]; point2 = floor_vrtx[l + 1]; shift1 = floor_vrtx[l] + WW1 * floor_nrml[l]; shift2 = floor_vrtx[l + 1] + WW1 * floor_nrml[l + 1]; PickMPC(floor_nrml[l], point1, shift1, floor_nrml[l + 1], point2, shift2, NeabyMPC1, out List <V6> for_MPC1_V6); PickMPC(floor_nrml[l], point1, shift1, floor_nrml[l + 1], point2, shift2, NeabyMPC2, out List <V6> for_MPC2_V6); PickMPC(floor_nrml[l], point1, shift1, floor_nrml[l + 1], point2, shift2, NeabyMPC3, out List <V6> for_MPC3_V6); for (int ii = 0; ii < for_MPC1_V6.Count; ii++) { if (!GlobalMPC1.Contains(for_MPC1_V6[ii].Coordinates)) { SeenV6_MPC1.Add(for_MPC1_V6[ii]); V7 tempV7_MPC1 = new V7(for_MPC1_V6[ii], MPC1_num); SeenV7_MPC1.Add(tempV7_MPC1); GlobalMPC1.Add(for_MPC1_V6[ii].Coordinates); GameObject cleared_sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); cleared_sphere.transform.position = for_MPC1_V6[ii].Coordinates; Destroy(cleared_sphere.GetComponent <SphereCollider>()); // remove collider cleared_sphere.name = "mpc1 #" + MPC1_num; var sphereRenderer = cleared_sphere.GetComponent <Renderer>(); sphereRenderer.material = MPC1_mat; cleared_sphere.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); MPC1_num += 1; } } for (int ii = 0; ii < for_MPC2_V6.Count; ii++) { if (!GlobalMPC2.Contains(for_MPC2_V6[ii].Coordinates)) { SeenV6_MPC2.Add(for_MPC2_V6[ii]); V7 tempV7_MPC2 = new V7(for_MPC2_V6[ii], MPC2_num); SeenV7_MPC2.Add(tempV7_MPC2); GlobalMPC2.Add(for_MPC2_V6[ii].Coordinates); GameObject cleared_sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); cleared_sphere.transform.position = for_MPC2_V6[ii].Coordinates; Destroy(cleared_sphere.GetComponent <SphereCollider>()); // remove collider cleared_sphere.name = "mpc2 #" + MPC2_num; var sphereRenderer = cleared_sphere.GetComponent <Renderer>(); sphereRenderer.material = MPC2_mat; cleared_sphere.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); MPC2_num += 1; } } for (int ii = 0; ii < for_MPC3_V6.Count; ii++) { if (!GlobalMPC3.Contains(for_MPC3_V6[ii].Coordinates)) { SeenV6_MPC3.Add(for_MPC3_V6[ii]); V7 tempV7_MPC3 = new V7(for_MPC3_V6[ii], MPC3_num); SeenV7_MPC3.Add(tempV7_MPC3); GlobalMPC3.Add(for_MPC3_V6[ii].Coordinates); GameObject cleared_sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); cleared_sphere.transform.position = for_MPC3_V6[ii].Coordinates; Destroy(cleared_sphere.GetComponent <SphereCollider>()); // remove collider cleared_sphere.name = "mpc3 #" + MPC3_num; var sphereRenderer = cleared_sphere.GetComponent <Renderer>(); sphereRenderer.material = MPC3_mat; cleared_sphere.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); MPC3_num += 1; } } area = new Area34(point1, shift1, point2, shift2); //DrawArea(area); } //Area2D(vv1, vv2, out float S11); } Debug.Log("Number of seen MPC1 = " + SeenV6_MPC1.Count); Debug.Log("Number of seen MPC2 = " + SeenV6_MPC2.Count); Debug.Log("Number of seen MPC3 = " + SeenV6_MPC3.Count); }
public string IsError() { if (string.IsNullOrWhiteSpace(GrsName)) { return("Укажите наименование ГРС"); } if (string.IsNullOrWhiteSpace(SubGrsName)) { return("Укажите наименование замерной нитки"); } if (Psantimeter > 0) { if (V1 + V2 + V3 + V9 + V10 + V11 > 0) { CalculateSmallK(); } else { K = SmallKConstants.KAll; } } else { if (V1 != 0 && !V1.CheckIntervalParams(90m, 97.9m)) { return("V1 параметр \"Объёмная концентрация метана\" несоответсвует"); } if (V2 != 0 && !V2.CheckIntervalParams(0.75m, 4.75m)) { return("V2 параметр \"Объёмная концентрация этана\" несоответсвует"); } if (V3 != 0 && !V3.CheckIntervalParams(0.30m, 3.5m)) { return("V3 параметр \"Объёмная концентрация пропана\" несоответсвует"); } if (V4 != 0 && !V4.CheckIntervalParams(0.01m, 0.5m)) { return("V4 параметр \"Объёмная концентрация i-бутана\" несоответсвует"); } if (!V5.CheckIntervalParams(0m, 0.4m)) { return("V5 параметр \"Объёмная концентрация n-бутана\" несоответсвует"); } if (!V6.CheckIntervalParams(0m, 0.2m)) { return("V6 параметр \"Объёмная концентрация i-пентана\" несоответсвует"); } if (!V7.CheckIntervalParams(0m, 0.15m)) { return("V7 параметр \"Объёмная концентрация n-пентана\" несоответсвует"); } if (!V8.CheckIntervalParams(0m, 0.3m)) { return("V8 параметр \"Объёмная концентрация гексана\" несоответсвует"); } if (V9 != 0 && !V9.CheckIntervalParams(0.1m, 2.5m)) { return("V9 параметр \"Объёмная концентрация углекислого газа\" несоответсвует"); } if (V10 != 0 && !V10.CheckIntervalParams(0.2m, 1.3m)) { return("V10 параметр \"Объёмная концентрация азота\" несоответсвует"); } if (!V11.CheckIntervalParams(0m, 0.3m)) { return("V11 параметр \"Объёмная концентрация кислорода\" несоответсвует"); } if (K == 0) { CalculateSmallK(); } else if (!K.CheckIntervalParams(1.24m, 2.1m)) { return("k параметр \"Объёмный показатель адиабаты\" несоответсвует"); } else { this.IsCalculateK = false; } } if (Z == 0) { this.Z = 0.882m; } else if (!Z.CheckIntervalParams(0.6m, 0.9999m)) { return("z параметр \"Коэффициент сжимаемости\" несоответсвует"); } if (!Pvxod.CheckIntervalParams(0.01m, 6m)) { return("Pвх параметр \"Давление газа на входе в ДГА\" несоответсвует"); } if (!Pvixod.CheckIntervalParams(0.01m, 4m)) { return("Pвых параметр \"Давление газа на выходе из ДГА\" несоответсвует"); } if (!Q.CheckIntervalParams(100m, 100000000m)) { return("Q параметр \"Расход газа по нитке\" несоответсвует"); } if (!Temperature.CheckIntervalParams(10m, 90m)) { return("t параметр \"Температура\" несоответсвует"); } if ((Nnominal > 0 && EffectProcent == 0) || (Nnominal == 0 && EffectProcent > 0)) { return("Укажите Nnominal и Procent, чтобы узнать эффективность расчета"); } CalculateParams(); return(string.Empty); }
// Start is called before the first frame update void Start() { float t_original = Time.realtimeSinceStartup; GameObject MPC_Spawner = GameObject.Find("MPC_spawner"); Scatterers_Spawning2 MPC_Script = MPC_Spawner.GetComponent <Scatterers_Spawning2>(); List <Vector3> MPC1 = MPC_Script.MPC1_possiblepositionList; List <Vector3> MPC2 = MPC_Script.MPC2_possiblepositionList; List <Vector3> MPC3 = MPC_Script.MPC3_possiblepositionList; List <Vector3> DMC = MPC_Script.DMC_possiblepositionList; // Declaring buildings and observation points Buildings = GameObject.FindGameObjectsWithTag("Reflecting_Obstacles"); // The number of observation points should not be too big, a few is enough Observation_Points = GameObject.FindGameObjectsWithTag("Observation_Points"); // Define the main road direction Vector3 main_axis = (Observation_Points[0].transform.position - Observation_Points[1].transform.position).normalized; Vector3 perp_axis = new Vector3(main_axis.z, 0, -main_axis.x); // subset of the seen Buldings List <GameObject> Building_list = new List <GameObject>(); // Going through all observation points for (int k = 0; k < Observation_Points.Length; k++) { // analyzing which buidings are seen for (int b = 0; b < Buildings.Length; b++) { Vector3[] vrtx = Buildings[b].GetComponent <MeshFilter>().mesh.vertices; Vector3[] nrml = Buildings[b].GetComponent <MeshFilter>().mesh.normals; int seen_vrtx_count = 0; for (int v = 0; v < vrtx.Length; v++) { if (vrtx[v].y == 0) { if (!Physics.Linecast(Observation_Points[k].transform.position, vrtx[v] + 1.1f * nrml[v])) { seen_vrtx_count += 1; } } } if (seen_vrtx_count != 0) { if (!Building_list.Contains(Buildings[b])) { Building_list.Add(Buildings[b]); } } } } // deactivating nonseen buildings for (int b = 0; b < Buildings.Length; b++) { if (!Building_list.Contains(Buildings[b])) { Buildings[b].SetActive(false); } } Debug.Log("The number of seen Buildings = " + Building_list.Count); List <Vector3> GlobalMPC1 = new List <Vector3>(); List <Vector3> GlobalMPC2 = new List <Vector3>(); List <Vector3> GlobalMPC3 = new List <Vector3>(); List <Vector3> GlobalDMC = new List <Vector3>(); // analyzing each seen building separately for (int k = 0; k < Building_list.Count; k++) { // writing MPCs into a txt file //string writePath; List <string> Obj_List = new List <string>(); Vector3[] vrtx = Building_list[k].GetComponent <MeshFilter>().mesh.vertices; Vector3[] nrml = Building_list[k].GetComponent <MeshFilter>().mesh.normals; List <Vector3> floor_vrtx = new List <Vector3>(); List <Vector3> floor_nrml = new List <Vector3>(); var pairs = new List <V6>(); List <Vector3> possible_vrtx = new List <Vector3>(); List <Vector3> possible_nrml = new List <Vector3>(); for (int l = 0; l < vrtx.Length; l++) { if (vrtx[l].y == 0 && Mathf.Abs(nrml[l].y) < 0.9) { floor_vrtx.Add(vrtx[l]); floor_nrml.Add(nrml[l]); // adding coordinates and normals of the vertices into a single object V6 (like a N x 6 matrix) V6 valid_pair = new V6(vrtx[l], nrml[l]); pairs.Add(valid_pair); } } // finding the edges of each building List <Vector3> SortedByX = floor_vrtx.OrderBy(vertex => vertex.x).ToList(); List <Vector3> SortedByZ = floor_vrtx.OrderBy(vertex => vertex.z).ToList(); float x_l = SortedByX[0].x - WW2; // x left float x_r = SortedByX[SortedByX.Count - 1].x + WW2; // x right float z_d = SortedByZ[0].z - WW2; // z down float z_u = SortedByZ[SortedByX.Count - 1].z + WW2; // z up // searching which scatterers are located near the building NearbyElements(x_l, x_r, z_d, z_u, MPC1, out List <Vector3> NearbyMPC1); NearbyElements(x_l, x_r, z_d, z_u, MPC2, out List <Vector3> NearbyMPC2); NearbyElements(x_l, x_r, z_d, z_u, MPC3, out List <Vector3> NearbyMPC3); NearbyElements(x_l, x_r, z_d, z_u, DMC, out List <Vector3> NearbyDMC); ////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Defining areas around building where scatterers can be located ////////////////////////////////////////////////////////////////////////////////////////////////////////// // defining necessary elements for the polygon that connects the last and the first vertices Vector3 n1_0 = floor_nrml[floor_vrtx.Count - 1]; Vector3 p1_0 = floor_vrtx[floor_vrtx.Count - 1]; Vector3 s1_0 = floor_vrtx[floor_vrtx.Count - 1] + WW1 * floor_nrml[floor_vrtx.Count - 1]; Vector3 dmc_s1_0 = floor_vrtx[floor_vrtx.Count - 1] + WW2 * floor_nrml[floor_vrtx.Count - 1]; Vector3 n2_0 = floor_nrml[0]; Vector3 p2_0 = floor_vrtx[0]; Vector3 s2_0 = floor_vrtx[0] + WW1 * floor_nrml[0]; Vector3 dmc_s2_0 = floor_vrtx[0] + WW2 * floor_nrml[0]; Area34 area = new Area34(p1_0, s1_0, p2_0, s2_0); //DrawArea(area); PickMPC(n1_0, p1_0, s1_0, n2_0, p2_0, s2_0, NearbyMPC1, out List <V6> MPC1_V6); PickMPC(n1_0, p1_0, s1_0, n2_0, p2_0, s2_0, NearbyMPC2, out List <V6> MPC2_V6); PickMPC(n1_0, p1_0, s1_0, n2_0, p2_0, s2_0, NearbyMPC3, out List <V6> MPC3_V6); PickMPC(n1_0, p1_0, dmc_s1_0, n2_0, p2_0, dmc_s2_0, NearbyMPC3, out List <V6> DMC_V6); //int MPC1_num = 0; for (int ii = 0; ii < MPC1_V6.Count; ii++) { if (!GlobalMPC1.Contains(MPC1_V6[ii].Coordinates)) { SeenV6_MPC1.Add(MPC1_V6[ii]); V7 tempV7_MPC1 = new V7(MPC1_V6[ii], MPC1_num); SeenV7_MPC1.Add(tempV7_MPC1); GlobalMPC1.Add(MPC1_V6[ii].Coordinates); //Entity newMPC1Entity = entityManager.Instantiate(MPC1_entity); //entityManager.SetComponentData(newMPC1Entity, new Position); //EntityManager.SetComponentData(newMPC1Entity, new Translation { Value = MPC1_V6[ii].Coordinates }) ; //MPC1_Prefab.transform.position = MPC1_V6[ii].Coordinates; if (MPC_visualizer_ECS == true) { GameObject MPC1_clone = Instantiate(MPC1_Prefab, MPC1_V6[ii].Coordinates, Quaternion.identity); MPC1_clone.name = "mpc1 #" + MPC1_num; } MPC1_num += 1; } } //int MPC2_num = 0; for (int ii = 0; ii < MPC2_V6.Count; ii++) { if (!GlobalMPC2.Contains(MPC2_V6[ii].Coordinates)) { SeenV6_MPC2.Add(MPC2_V6[ii]); V7 tempV7_MPC2 = new V7(MPC2_V6[ii], MPC2_num); SeenV7_MPC2.Add(tempV7_MPC2); GlobalMPC2.Add(MPC2_V6[ii].Coordinates); if (MPC_visualizer_ECS == true) { GameObject MPC2_clone = Instantiate(MPC2_Prefab, MPC2_V6[ii].Coordinates, Quaternion.identity); MPC2_clone.name = "mpc2 #" + MPC2_num; } MPC2_num += 1; } } //int MPC3_num = 0; for (int ii = 0; ii < MPC3_V6.Count; ii++) { if (!GlobalMPC3.Contains(MPC3_V6[ii].Coordinates)) { SeenV6_MPC3.Add(MPC3_V6[ii]); V7 tempV7_MPC3 = new V7(MPC3_V6[ii], MPC3_num); SeenV7_MPC3.Add(tempV7_MPC3); GlobalMPC3.Add(MPC3_V6[ii].Coordinates); if (MPC_visualizer_ECS == true) { GameObject MPC3_clone = Instantiate(MPC3_Prefab, MPC3_V6[ii].Coordinates, Quaternion.identity); MPC3_clone.name = "mpc3 #" + MPC3_num; } MPC3_num += 1; } } //int DMC_num = 0; for (int ii = 0; ii < DMC_V6.Count; ii++) { if (!GlobalDMC.Contains(DMC_V6[ii].Coordinates)) { SeenV6_DMC.Add(DMC_V6[ii]); V7 tempV7_DMC = new V7(DMC_V6[ii], DMC_num); SeenV7_DMC.Add(tempV7_DMC); GlobalDMC.Add(DMC_V6[ii].Coordinates); if (MPC_visualizer_ECS == true) { GameObject DMC_clone = Instantiate(DMC_Prefab, DMC_V6[ii].Coordinates, Quaternion.identity); DMC_clone.name = "mpc3 #" + DMC_num; } DMC_num += 1; } } // draw areas for all vertices Vector3 point1 = new Vector3(0.0f, 0.0f, 0.0f); Vector3 point2 = new Vector3(0.0f, 0.0f, 0.0f); Vector3 shift1 = new Vector3(0.0f, 0.0f, 0.0f); Vector3 shift2 = new Vector3(0.0f, 0.0f, 0.0f); Vector3 dmc_shift1 = new Vector3(0.0f, 0.0f, 0.0f); Vector3 dmc_shift2 = new Vector3(0.0f, 0.0f, 0.0f); for (int l = 0; l < floor_vrtx.Count - 1; l++) { point1 = floor_vrtx[l]; point2 = floor_vrtx[l + 1]; shift1 = floor_vrtx[l] + WW1 * floor_nrml[l]; shift2 = floor_vrtx[l + 1] + WW1 * floor_nrml[l + 1]; dmc_shift1 = floor_vrtx[l] + WW2 * floor_nrml[l]; dmc_shift2 = floor_vrtx[l + 1] + WW2 * floor_nrml[l + 1]; Area34 area_forloop = new Area34(point1, dmc_shift1, point2, dmc_shift2); //DrawArea(area_forloop); PickMPC(floor_nrml[l], point1, shift1, floor_nrml[l + 1], point2, shift2, NearbyMPC1, out List <V6> for_MPC1_V6); PickMPC(floor_nrml[l], point1, shift1, floor_nrml[l + 1], point2, shift2, NearbyMPC2, out List <V6> for_MPC2_V6); PickMPC(floor_nrml[l], point1, shift1, floor_nrml[l + 1], point2, shift2, NearbyMPC3, out List <V6> for_MPC3_V6); // picking DMCs PickMPC(floor_nrml[l], point1, dmc_shift1, floor_nrml[l + 1], point2, dmc_shift2, NearbyDMC, out List <V6> for_DMC_V6); // MPC1 for (int ii = 0; ii < for_MPC1_V6.Count; ii++) { if (!GlobalMPC1.Contains(for_MPC1_V6[ii].Coordinates)) { SeenV6_MPC1.Add(for_MPC1_V6[ii]); V7 tempV7_MPC1 = new V7(for_MPC1_V6[ii], MPC1_num); SeenV7_MPC1.Add(tempV7_MPC1); GlobalMPC1.Add(for_MPC1_V6[ii].Coordinates); if (MPC_visualizer_ECS == true) { GameObject clone = Instantiate(MPC1_Prefab, for_MPC1_V6[ii].Coordinates, Quaternion.identity); clone.name = "mpc1 #" + MPC1_num; } MPC1_num += 1; } } // MPC2 for (int ii = 0; ii < for_MPC2_V6.Count; ii++) { if (!GlobalMPC2.Contains(for_MPC2_V6[ii].Coordinates)) { SeenV6_MPC2.Add(for_MPC2_V6[ii]); V7 tempV7_MPC2 = new V7(for_MPC2_V6[ii], MPC2_num); SeenV7_MPC2.Add(tempV7_MPC2); GlobalMPC2.Add(for_MPC2_V6[ii].Coordinates); if (MPC_visualizer_ECS == true) { GameObject MPC2_clone = Instantiate(MPC2_Prefab, for_MPC2_V6[ii].Coordinates, Quaternion.identity); MPC2_clone.name = "mpc2 #" + MPC2_num; } MPC2_num += 1; } } // MPC3 for (int ii = 0; ii < for_MPC3_V6.Count; ii++) { if (!GlobalMPC3.Contains(for_MPC3_V6[ii].Coordinates)) { SeenV6_MPC3.Add(for_MPC3_V6[ii]); V7 tempV7_MPC3 = new V7(for_MPC3_V6[ii], MPC3_num); SeenV7_MPC3.Add(tempV7_MPC3); GlobalMPC3.Add(for_MPC3_V6[ii].Coordinates); if (MPC_visualizer_ECS == true) { GameObject MPC3_clone = Instantiate(MPC3_Prefab, for_MPC3_V6[ii].Coordinates, Quaternion.identity); MPC3_clone.name = "mpc3 #" + MPC3_num; } MPC3_num += 1; } } // DMCs for (int ii = 0; ii < for_DMC_V6.Count; ii++) { if (!GlobalDMC.Contains(for_DMC_V6[ii].Coordinates)) { SeenV6_DMC.Add(for_DMC_V6[ii]); V7 tempV7_DMC = new V7(for_DMC_V6[ii], DMC_num); SeenV7_DMC.Add(tempV7_DMC); GlobalDMC.Add(for_DMC_V6[ii].Coordinates); if (MPC_visualizer_ECS == true) { GameObject DMC_clone = Instantiate(DMC_Prefab, for_DMC_V6[ii].Coordinates, Quaternion.identity); DMC_clone.name = "dmc #" + DMC_num; } DMC_num += 1; } } } //Area2D(vv1, vv2, out float S11); } Debug.Log("Number of seen MPC1 = " + SeenV7_MPC1.Count + "; check number " + MPC1_num); Debug.Log("Number of seen MPC2 = " + SeenV7_MPC2.Count + "; check number " + MPC2_num); Debug.Log("Number of seen MPC3 = " + SeenV7_MPC3.Count + "; check number " + MPC3_num); Debug.Log("Number of seen DMCs = " + SeenV7_DMC.Count + "; check number " + DMC_num); Debug.Log("Check Time t_original: " + ((Time.realtimeSinceStartup - t_original) * 1000f) + " ms"); }
// Update is called once per frame private void FixedUpdate() { d1 = transform.position - old_position1; fwd = transform.forward; up = transform.up; //Debug.DrawRay(transform.position, fwd, Color.red); //Debug.DrawRay(transform.position, up, Color.yellow); // update the old position. Now, current position become old for the next position. old_position1 = transform.position; // in x axis ant1_min_x += d1.x; ant1_max_x += d1.x; // in z axis ant1_min_z += d1.z; ant1_max_z += d1.z; if (Activate_MPC1 || Activate_MPC2 || Activate_MPC3) { // drawing the area around the moving car DrawArea(ant1_min_x, ant1_max_x, ant1_min_z, ant1_max_z); } ToRemove(temp_V7_list1, d1, ant1_min_x, ant1_max_x, ant1_min_z, ant1_max_z, out List <int> ToBeRemoved1); ToRemove(temp_V7_list2, d1, ant1_min_x, ant1_max_x, ant1_min_z, ant1_max_z, out List <int> ToBeRemoved2); ToRemove(temp_V7_list3, d1, ant1_min_x, ant1_max_x, ant1_min_z, ant1_max_z, out List <int> ToBeRemoved3); if (ToBeRemoved1.Count > 0) { // remove the elements listed in ToBeRemoved list inarea_MPC1 = inarea_MPC1.Except(ToBeRemoved1).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved1.Count; i++) { temp_V7_list1.RemoveAll(elm => elm.Number == ToBeRemoved1[i]); } // the below function somewhy does not work for class V7 // temp_V7_list1 = temp_V7_list1.Except(temp_remove_list).ToList(); // drawing update if (Activate_MPC1) { // GameObjects can't be used in NativeArray and in all Jobs systems // NativeArray<GameObject> asd = new NativeArray<GameObject>(ToBeRemoved1.Count, Allocator.TempJob); // it won't work for (int i = 0; i < ToBeRemoved1.Count; i++) { int temp_number = ToBeRemoved1[i]; string temp_name = "mpc1 #" + temp_number; near_MPC1 = GameObject.Find(temp_name); near_MPC1.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } } if (ToBeRemoved2.Count > 0) { // remove the elements listed in ToBeRemoved list inarea_MPC2 = inarea_MPC2.Except(ToBeRemoved2).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved2.Count; i++) { temp_V7_list2.RemoveAll(elm => elm.Number == ToBeRemoved2[i]); } // drawing update if (Activate_MPC2) { for (int i = 0; i < ToBeRemoved2.Count; i++) { int temp_number = ToBeRemoved2[i]; string temp_name = "mpc2 #" + temp_number; near_MPC2 = GameObject.Find(temp_name); near_MPC2.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } } if (ToBeRemoved3.Count > 0) { // remove the elements listed in ToBeRemoved list inarea_MPC3 = inarea_MPC3.Except(ToBeRemoved3).ToList(); // update the seen MPCs list for (int i = 0; i < ToBeRemoved3.Count; i++) { temp_V7_list3.RemoveAll(elm => elm.Number == ToBeRemoved3[i]); } // drawing update if (Activate_MPC3) { for (int i = 0; i < ToBeRemoved3.Count; i++) { int temp_number = ToBeRemoved3[i]; string temp_name = "mpc3 #" + temp_number; near_MPC3 = GameObject.Find(temp_name); near_MPC3.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } } ToAdd(byX_V7MPC1, byZ_V7MPC1, d1, ant1_min_x, XMIN_index1, ant1_max_x, XMAX_index1, ant1_min_z, ZMIN_index1, ant1_max_z, ZMAX_index1, out List <int> ToBeAdd1); ToAdd(byX_V7MPC2, byZ_V7MPC2, d1, ant1_min_x, XMIN_index2, ant1_max_x, XMAX_index2, ant1_min_z, ZMIN_index2, ant1_max_z, ZMAX_index2, out List <int> ToBeAdd2); ToAdd(byX_V7MPC3, byZ_V7MPC3, d1, ant1_min_x, XMIN_index3, ant1_max_x, XMAX_index3, ant1_min_z, ZMIN_index3, ant1_max_z, ZMAX_index3, out List <int> ToBeAdd3); if (ToBeAdd1.Count > 0) { // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_MPC1.Count + ToBeAdd1.Count); twolists.AddRange(inarea_MPC1); twolists.AddRange(ToBeAdd1); inarea_MPC1 = twolists; for (int i = 0; i < ToBeAdd1.Count; i++) { V7 temp_V7 = new V7(MPC1[ToBeAdd1[i]], ToBeAdd1[i]); temp_V7_list1.Add(temp_V7); } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_1 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_1 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7_1[0].Number); XMAX_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7_1[XsortV7_1.Count - 1].Number); ZMIN_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7_1[0].Number); ZMAX_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7_1[XsortV7_1.Count - 1].Number); } if (ToBeAdd2.Count > 0) { // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_MPC2.Count + ToBeAdd2.Count); twolists.AddRange(inarea_MPC2); twolists.AddRange(ToBeAdd2); inarea_MPC2 = twolists; // Update edges of the updated list InArea: See explanation about the complexity in MPC1 for (int i = 0; i < ToBeAdd2.Count; i++) { V7 temp_V7 = new V7(MPC2[ToBeAdd2[i]], ToBeAdd2[i]); temp_V7_list2.Add(temp_V7); } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[0].Number); XMAX_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[XsortV7_2.Count - 1].Number); ZMIN_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[0].Number); ZMAX_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[XsortV7_2.Count - 1].Number); } if (ToBeAdd3.Count > 0) { // add the elements listed in ToBeAdd list var twolists = new List <int>(inarea_MPC3.Count + ToBeAdd3.Count); twolists.AddRange(inarea_MPC3); twolists.AddRange(ToBeAdd3); inarea_MPC3 = twolists; // Update edges of the updated list InArea: See explanation about the complexity in MPC1 for (int i = 0; i < ToBeAdd3.Count; i++) { V7 temp_V7 = new V7(MPC3[ToBeAdd3[i]], ToBeAdd3[i]); temp_V7_list3.Add(temp_V7); } // finding edges of inarea_MPC1 in x and z directions List <V7> XsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList(); List <V7> ZsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList(); // finding elements indexes in the sorted lists XMIN_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[0].Number); XMAX_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[XsortV7_3.Count - 1].Number); ZMIN_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[0].Number); ZMAX_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[XsortV7_3.Count - 1].Number); } seen_MPC1 = new List <int>(); for (int i = 0; i < inarea_MPC1.Count; i++) { Vector3 temp_direction = MPC1[inarea_MPC1[i]].Coordinates - transform.position; if (Vector3.Dot(MPC1[inarea_MPC1[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, MPC1[inarea_MPC1[i]].Coordinates)) { seen_MPC1.Add(inarea_MPC1[i]); // Adding antenna radiation pattern if (Antenna_pattern) { float cos_az = Vector3.Dot(temp_direction.normalized, fwd); float cos_el = Vector3.Dot(temp_direction.normalized, up); float horizont_att = 0.5f - 0.5f * cos_az; float vertical_att; if (cos_el <= 0) { vertical_att = cos_el + 1; } else { vertical_att = 1 - cos_el; } //Debug.Log(vertical_att * horizont_att); seen_MPC1_att.Add(vertical_att * horizont_att); } else { seen_MPC1_att.Add(1f); } if (Activate_MPC1) { int temp_number = inarea_MPC1[i]; string temp_name = "mpc1 #" + temp_number; near_MPC1 = GameObject.Find(temp_name); near_MPC1.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } } seen_MPC2 = new List <int>(); for (int i = 0; i < inarea_MPC2.Count; i++) { Vector3 temp_direction = MPC2[inarea_MPC2[i]].Coordinates - transform.position; if (Vector3.Dot(MPC2[inarea_MPC2[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, MPC2[inarea_MPC2[i]].Coordinates)) { seen_MPC2.Add(inarea_MPC2[i]); if (Antenna_pattern) { float cos_az = Vector3.Dot(temp_direction.normalized, fwd); float cos_el = Vector3.Dot(temp_direction.normalized, up); float horizont_att = 0.5f - 0.5f * cos_az; float vertical_att; if (cos_el <= 0) { vertical_att = cos_el + 1; } else { vertical_att = 1 - cos_el; } //Debug.Log(vertical_att * horizont_att); seen_MPC2_att.Add(vertical_att * horizont_att); } else { seen_MPC2_att.Add(1f); } if (Activate_MPC2) { int temp_number = inarea_MPC2[i]; string temp_name = "mpc2 #" + temp_number; near_MPC2 = GameObject.Find(temp_name); near_MPC2.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } } seen_MPC3 = new List <int>(); for (int i = 0; i < inarea_MPC3.Count; i++) { Vector3 temp_direction = MPC3[inarea_MPC3[i]].Coordinates - transform.position; if (Vector3.Dot(MPC3[inarea_MPC3[i]].Normal, temp_direction) < 0) { if (!Physics.Linecast(transform.position, MPC3[inarea_MPC3[i]].Coordinates)) { seen_MPC3.Add(inarea_MPC3[i]); if (Antenna_pattern) { float cos_az = Vector3.Dot(temp_direction.normalized, fwd); float cos_el = Vector3.Dot(temp_direction.normalized, up); float horizont_att = 0.5f - 0.5f * cos_az; float vertical_att; if (cos_el <= 0) { vertical_att = cos_el + 1; } else { vertical_att = 1 - cos_el; } //Debug.Log(vertical_att * horizont_att); seen_MPC3_att.Add(vertical_att * horizont_att); } else { seen_MPC3_att.Add(1f); } if (Activate_MPC3) { int temp_number = inarea_MPC3[i]; string temp_name = "mpc3 #" + temp_number; near_MPC3 = GameObject.Find(temp_name); near_MPC3.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } } }