public Star(SystemController controller, int seed, GameObject gameObject) : base(controller, gameObject, seed, new CelestialType.Star()) { MeshFilter filter = gameObject.AddComponent <MeshFilter>(); MeshRenderer renderer = gameObject.AddComponent <MeshRenderer>(); filter.mesh = Octahedron.Create(5, radius); Material mat = new Material(controller.materialController.starMaterial); CelestialType starType = new CelestialType.Star(); mat.SetInt("_Temp", (int)Utility.GetRandomBetween(new System.Random(seed), starType.minTemperature, starType.maxTemperature)); renderer.material = mat; renderer.receiveShadows = false; renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; gameObject.transform.localScale = Vector3.one; var light = gameObject.AddComponent <Light>(); light.type = LightType.Point; light.range = 2000000; light.bounceIntensity = 0; light.renderMode = LightRenderMode.ForcePixel; light.intensity = 1; light.shadows = LightShadows.Soft; light.shadowNearPlane = .1f; }
/// <summary> /// add a volumetric atmosphere to a celestial body /// </summary> public void AddAtmosphere(CelestialBody celestialBody) { GameObject atmo = new GameObject("atmosphere"); atmo.AddComponent <MeshFilter>().mesh = Octahedron.Create(5, 1); Material material = controller.materialController.GetMaterialForVolumetricAtmosphere(celestialBody); material.SetColor("_Color1", controller.materialController.GetColor1ForAtmosphere(celestialBody)); material.SetColor("_Color2", controller.materialController.GetColor2ForAtmosphere(celestialBody)); atmo.transform.parent = celestialBody.gameObject.transform; atmo.transform.localScale = Vector3.one * celestialBody.radius * celestialBody.atmosphereRadiusMultiplier; atmo.transform.localPosition = Vector3.zero; atmo.AddComponent <MeshRenderer>().material = material; }
public GasPlanet(SystemController controller, GameObject gameObject, int seed, CelestialBody host = null) : base(controller, gameObject, seed, new CelestialType.GasPlanet(), host) { gameObject.AddComponent <MeshFilter>().mesh = Octahedron.Create(5, radius); gameObject.AddComponent <MeshRenderer>().sharedMaterial = GetMaterial(); }