//**************************************************************************************************** // //**************************************************************************************************** public void Setup(string parent, string spot, int nbSides, float thickness, string material) { GameObject parentObj = GameObject.Find(parent); GameObject spotObj = CORE.HIERARCHY.Resolve(null, spot); if (m_latRing == null) { m_latRing = EarthRing.Create(parentObj, 0.0f, nbSides, thickness, material); } if (m_lngRing == null) { m_lngRing = EarthRing.Create(parentObj, 0.0f, nbSides, thickness, material); } if (m_spot == null) { m_spot = spotObj; } m_latRing.transform.localScale = Vector3.one * 1.0025f; m_lngRing.transform.localScale = Vector3.one * 1.0025f; }
//**************************************************************************************************** // //**************************************************************************************************** public void CreateRings() { float step = (180.0f - (180.0f / NB_RINGS)) / (NB_RINGS - 1); if (m_equator == null) { m_equator = EarthRing.Create(m_earth, 0.0f, 58, 0.01f, "Materials/Equator"); m_equator.name = "Equator"; m_equator.enabled = false; m_equator.transform.localScale = Vector3.one * 1.003f; } for (int ring = 0; ring < NB_RINGS; ++ring) { if (m_rings[ring] == null) { m_rings[ring] = EarthRing.Create(m_earth, m_equator, "Materials/Meridian"); m_rings[ring].name = "Meridian"; m_rings[ring].longitude = ring * step; m_rings[ring].enabled = false; m_rings[ring].transform.localScale = Vector3.one * 1.003f; } } }
//**************************************************************************************************** // //**************************************************************************************************** public void Destroy() { m_latRing = null; m_lngRing = null; m_spot = null; }
//**************************************************************************************************** // //**************************************************************************************************** public static EarthRing Create(GameObject parent, EarthRing model, string material) { EarthRing ring = new GameObject("Ring", typeof(EarthRing)).GetComponent <EarthRing>(); if ((ring != null) && (model != null)) { ring.m_filter = ring.GetComponent <MeshFilter>(); ring.m_mesh = ring.m_filter != null ? ring.m_filter.mesh : null; ring.m_mesh.MarkDynamic(); model.Update(); System.Array.Resize(ref ring.m_ring, model.m_ring.Length); System.Array.Resize(ref ring.m_tans, model.m_tans.Length); System.Array.Resize(ref ring.m_verts, model.m_verts.Length); System.Array.Resize(ref ring.m_tris, model.m_tris.Length); System.Array.Resize(ref ring.m_uv, model.m_uv.Length); System.Array.Copy(model.m_ring, ring.m_ring, model.m_ring.Length); System.Array.Copy(model.m_tans, ring.m_tans, model.m_tans.Length); System.Array.Copy(model.m_verts, ring.m_verts, model.m_verts.Length); System.Array.Copy(model.m_tris, ring.m_tris, model.m_tris.Length); System.Array.Copy(model.m_uv, ring.m_uv, model.m_uv.Length); ring.ApplyGeometry(); ring.material = material; if (parent != null) { ring.transform.parent = parent.transform; ring.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f); ring.transform.localRotation = Quaternion.identity; ring.transform.localScale = Vector3.one; } } return(ring); }