//contructor public CometTailLoader() { tail = new CometTail (); }
public static void AddCometTail(PSystemBody body, CometTail tail) { Transform scaledVersion = body.scaledVersion.transform; GameObject obj = new GameObject("CometTail"); obj.layer = GameLayers.ScaledSpace; obj.transform.parent = Kopernicus.Utility.Deactivator; var mr = obj.AddComponent <MeshRenderer> (); var mf = obj.AddComponent <MeshFilter> (); var teardrop = new Teardrop(1f, (tail.length / tail.radius), 60, 90); mf.mesh = teardrop; if (Settings.AllowAdvancedCometShader) { mr.sharedMaterial = new Material(Shaders.CometTail); //set default material values mr.sharedMaterial.SetColor("_TintColor", new Color(tail.color.r, tail.color.g, tail.color.b, 0.5f)); mr.sharedMaterial.SetFloat("_RimPower", tail.rimPower); mr.sharedMaterial.SetFloat("_Distortion", tail.distortion); mr.sharedMaterial.SetFloat("_AlphaDistortion", tail.alphaDistortion); mr.sharedMaterial.SetFloat("_ZDistortion", tail.zDistortion); mr.sharedMaterial.SetFloat("_VertexDistortion", 0f); mr.sharedMaterial.SetFloat("_Frequency", tail.frequency); mr.sharedMaterial.SetFloat("_Lacunarity", tail.lacunarity); mr.sharedMaterial.SetFloat("_Gain", tail.gain); } else { mr.sharedMaterial = new Material(Shader.Find(FallbackShader)); //set default material values mr.sharedMaterial.SetColor("_TintColor", new Color(tail.color.r, tail.color.g, tail.color.b, 0.3f)); } mr.castShadows = false; mr.receiveShadows = false; var cometController = obj.AddComponent <CometTailController> (); cometController.targetBodyName = "Sun"; cometController.usingAdvancedShader = Settings.AllowAdvancedCometShader; cometController.type = tail.type; cometController.color = tail.color; cometController.orbit = body.celestialBody.orbit; cometController.opacityCurve = tail.opacityCurve; cometController.brightnessCurve = tail.brightnessCurve; obj.transform.parent = scaledVersion; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = (Vector3.one * tail.length); obj.SetActive(true); obj.layer = GameLayers.ScaledSpace; //initialize comet cometController.Init(); }
public static void AddCometTail(PSystemBody body, CometTail tail) { Transform scaledVersion = body.scaledVersion.transform; GameObject obj = new GameObject ("CometTail"); obj.layer = GameLayers.ScaledSpace; obj.transform.parent = Kopernicus.Utility.Deactivator; var mr = obj.AddComponent<MeshRenderer> (); var mf = obj.AddComponent<MeshFilter> (); var teardrop = new Teardrop (1f, (tail.length / tail.radius), 60, 90); mf.mesh = teardrop; if (Settings.AllowAdvancedCometShader) { mr.sharedMaterial = new Material (Shaders.CometTail); //set default material values mr.sharedMaterial.SetColor ("_TintColor", new Color(tail.color.r, tail.color.g, tail.color.b, 0.5f)); mr.sharedMaterial.SetFloat ("_RimPower", tail.rimPower); mr.sharedMaterial.SetFloat ("_Distortion", tail.distortion); mr.sharedMaterial.SetFloat ("_AlphaDistortion", tail.alphaDistortion); mr.sharedMaterial.SetFloat ("_ZDistortion", tail.zDistortion); mr.sharedMaterial.SetFloat ("_VertexDistortion", 0f); mr.sharedMaterial.SetFloat ("_Frequency", tail.frequency); mr.sharedMaterial.SetFloat ("_Lacunarity", tail.lacunarity); mr.sharedMaterial.SetFloat ("_Gain", tail.gain); } else { mr.sharedMaterial = new Material (Shader.Find(FallbackShader)); //set default material values mr.sharedMaterial.SetColor ("_TintColor", new Color(tail.color.r, tail.color.g, tail.color.b, 0.3f)); } mr.castShadows = false; mr.receiveShadows = false; var cometController = obj.AddComponent<CometTailController> (); cometController.targetBodyName = "Sun"; cometController.usingAdvancedShader = Settings.AllowAdvancedCometShader; cometController.type = tail.type; cometController.color = tail.color; cometController.orbit = body.celestialBody.orbit; cometController.opacityCurve = tail.opacityCurve; cometController.brightnessCurve = tail.brightnessCurve; obj.transform.parent = scaledVersion; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = (Vector3.one * tail.length); obj.SetActive (true); obj.layer = GameLayers.ScaledSpace; //initialize comet cometController.Init (); }