protected void CreatePlanetVertexes(int recursionLevel) { var icosphere = new Icosphere(); icosphere.Create(recursionLevel); PlanetVertexes = icosphere.Vertexes.Select(v => ComputeModelElevation(v)).ToList(); PlanetTriangles = icosphere.Triangles.ToList(); }
void CreatePlanet(float radius, float variation, float seaLevel, Color planetColor, float atmosphereRadius, Color atmosphereColor, bool habitableAtmosphere, Orbit orbit) { PlanetVars planetVars = new PlanetVars(radius, variation, seaLevel, planetColor, atmosphereRadius, atmosphereColor, habitableAtmosphere, orbit); GameObject planet = new GameObject(); Icosphere.Create(planet, 6, planetVars.radius, Mathf.RoundToInt(Random.value * int.MaxValue), planetVars.variation, planetVars.variation); planet.AddComponent <MeshRenderer>(); planet.AddComponent <MeshCollider>(); planet.AddComponent <Orbiter>(); //Generate Material Material planetMaterial = new Material(triplanar); planetMaterial.SetTexture("_MainTex", ground); planetMaterial.SetTexture("_MainTex1", ground); planetMaterial.SetTexture("_MainTex2", ground); planet.GetComponent <MeshRenderer>().material = planetMaterial; //Generate Orbit planet.GetComponent <Orbiter>().orbit = planetVars.orbit; //Make ocean GameObject ocean = new GameObject(); Icosphere.Create(ocean, 6, planetVars.radius, Mathf.RoundToInt(Random.value * int.MaxValue), 0, 0); ocean.AddComponent <MeshRenderer>(); ocean.transform.parent = planet.transform; //Make ocean material Material oceanMaterial = new Material(triplanar); oceanMaterial.SetTexture("_MainTex", water); oceanMaterial.SetTexture("_MainTex1", water); oceanMaterial.SetTexture("_MainTex2", water); ocean.GetComponent <MeshRenderer>().material = oceanMaterial; //Set starting position planet.transform.localScale = new Vector3(radius, radius, radius); planet.transform.position = Orbiter.GetPointOnEclipse(90, planetVars.orbit); }