public CloudLayer(String url, ConfigNode node, String body, Color color, float altitude,
                   TextureSet mainTexture,
                   TextureSet detailTexture,
                   ShaderFloats ScaledShaderFloats,
                   ShaderFloats ShaderFloats,
                   bool useVolume)
 {
     if (!BodyDatabase.ContainsKey(body))
     {
         BodyDatabase.Add(body, new List <CloudLayer>());
     }
     BodyDatabase[body].Add(this);
     if (!ConfigBodyDatabase.ContainsKey(url))
     {
         ConfigBodyDatabase.Add(url, new Dictionary <String, List <CloudLayer> >());
         ConfigBodyDatabase[url].Add(body, new List <CloudLayer>());
     }
     else if (!ConfigBodyDatabase[url].ContainsKey(body))
     {
         ConfigBodyDatabase[url].Add(body, new List <CloudLayer>());
     }
     ConfigBodyDatabase[url][body].Add(this);
     this.url                = url;
     this.node               = node;
     this.body               = body;
     this.color              = color;
     this.altitude           = altitude;
     this.mainTexture        = mainTexture;
     this.detailTexture      = detailTexture;
     this.scaledShaderFloats = ScaledShaderFloats;
     this.shaderFloats       = ShaderFloats;
     this.useVolume          = useVolume;
     Init();
 }
 public void Clone(ShaderFloats toClone)
 {
     FalloffPower         = toClone.FalloffPower;
     FalloffScale         = toClone.FalloffScale;
     DetailDistance       = toClone.DetailDistance;
     MinimumLight         = toClone.MinimumLight;
     FadeDistance         = toClone.FadeDistance;
     RimDistance          = toClone.RimDistance;
     FalloffPowerString   = FalloffPower.ToString("R");
     FalloffScaleString   = FalloffScale.ToString("R");
     DetailDistanceString = DetailDistance.ToString("R");
     MinimumLightString   = MinimumLight.ToString("R");
     FadeDistanceString   = FadeDistance.ToString("R");
     RimDistanceString    = RimDistance.ToString("R");
 }
        internal static bool IsDefaultShaderFloat(ShaderFloats shaderFloats, bool isScaled)
        {
            ShaderFloats compare = GetDefault(isScaled);

            if (shaderFloats.FalloffPower == compare.FalloffPower &&
                shaderFloats.FalloffScale == compare.FalloffScale &&
                shaderFloats.DetailDistance == compare.DetailDistance &&
                shaderFloats.MinimumLight == compare.MinimumLight)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void Init()
        {
            ScaledCloudMaterial   = new Material(CloudShader);
            CloudMaterial         = new Material(CloudShader);
            CloudParticleMaterial = new Material(CloudParticleShader);

            if (scaledShaderFloats == null)
            {
                scaledShaderFloats = GetDefault(true);
            }

            if (shaderFloats == null)
            {
                shaderFloats = GetDefault(false);
            }

            Texture2D tex1 = GameDatabase.Instance.GetTexture("BoulderCo/Clouds/Textures/particle/1", false);
            Texture2D tex2 = GameDatabase.Instance.GetTexture("BoulderCo/Clouds/Textures/particle/2", false);
            Texture2D tex3 = GameDatabase.Instance.GetTexture("BoulderCo/Clouds/Textures/particle/3", false);

            tex1.wrapMode = TextureWrapMode.Clamp;
            tex2.wrapMode = TextureWrapMode.Clamp;
            tex3.wrapMode = TextureWrapMode.Clamp;

            CloudParticleMaterial.SetTexture("_TopTex", tex1);
            CloudParticleMaterial.SetTexture("_LeftTex", tex2);
            CloudParticleMaterial.SetTexture("_FrontTex", tex3);
            CloudParticleMaterial.SetFloat("_DistFade", 1f / 2250f);

            Log("Cloud Material initialized");
            UpdateTextures();
            Log("Generating Overlay...");
            CloudOverlay = Overlay.GeneratePlanetOverlay(body, altitude, ScaledCloudMaterial, CloudMaterial, this.mainTexture.StartOffset);

            if (useVolume)
            {
                CloudOverlay.MacroCallback    = MacroCallback;
                CloudOverlay.DominantCallback = DominantCallback;
            }

            UpdateFloats();
            Log("Textures initialized");
        }
        public CloudLayer(String url, ConfigNode node, String body, Color color, float altitude,
            TextureSet mainTexture,
            TextureSet detailTexture,
            ShaderFloats ScaledShaderFloats,
            ShaderFloats ShaderFloats,
            bool useVolume)
        {
            if (!BodyDatabase.ContainsKey(body))
            {
                BodyDatabase.Add(body, new List<CloudLayer>());
            }
            BodyDatabase[body].Add(this);
            if (!ConfigBodyDatabase.ContainsKey(url))
            {
                ConfigBodyDatabase.Add(url, new Dictionary<String, List<CloudLayer>>());
                ConfigBodyDatabase[url].Add(body, new List<CloudLayer>());
            }
            else if (!ConfigBodyDatabase[url].ContainsKey(body))
            {
                ConfigBodyDatabase[url].Add(body, new List<CloudLayer>());
            }
            ConfigBodyDatabase[url][body].Add(this);
            this.url = url;
            this.node = node;
            this.body = body;
            this.color = color;
            this.altitude = altitude;
            this.mainTexture = mainTexture;

            this.detailTexture = detailTexture;

            this.scaledShaderFloats = ScaledShaderFloats;
            this.shaderFloats = ShaderFloats;

            this.useVolume = useVolume;
            Init();
        }
        internal static bool IsDefaultShaderFloat(ShaderFloats shaderFloats, bool isScaled)
        {
            ShaderFloats compare = GetDefault(isScaled);

            if (shaderFloats.FalloffPower == compare.FalloffPower &&
                shaderFloats.FalloffScale == compare.FalloffScale &&
                shaderFloats.DetailDistance == compare.DetailDistance &&
                shaderFloats.MinimumLight == compare.MinimumLight)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public void Init()
        {
            ScaledCloudMaterial = new Material(CloudShader);
            CloudMaterial = new Material(CloudShader);
            CloudParticleMaterial = new Material(CloudParticleShader);

            if (scaledShaderFloats == null)
            {
                scaledShaderFloats = GetDefault(true);
            }

            if (shaderFloats == null)
            {
                shaderFloats = GetDefault(false);
            }

            Texture2D tex1 = GameDatabase.Instance.GetTexture("BoulderCo/Clouds/Textures/particle/1", false);
            Texture2D tex2 = GameDatabase.Instance.GetTexture("BoulderCo/Clouds/Textures/particle/2", false);
            Texture2D tex3 = GameDatabase.Instance.GetTexture("BoulderCo/Clouds/Textures/particle/3", false);

            tex1.wrapMode = TextureWrapMode.Clamp;
            tex2.wrapMode = TextureWrapMode.Clamp;
            tex3.wrapMode = TextureWrapMode.Clamp;

            CloudParticleMaterial.SetTexture("_TopTex", tex1);
            CloudParticleMaterial.SetTexture("_LeftTex", tex2);
            CloudParticleMaterial.SetTexture("_FrontTex", tex3);
            CloudParticleMaterial.SetFloat("_DistFade", 1f / 2250f);

            Log("Cloud Material initialized");
            UpdateTextures();
            Log("Generating Overlay...");
            CloudOverlay = Overlay.GeneratePlanetOverlay(body, altitude, ScaledCloudMaterial, CloudMaterial, this.mainTexture.StartOffset);

            if (useVolume)
            {
                CloudOverlay.MacroCallback = MacroCallback;
                CloudOverlay.DominantCallback = DominantCallback;
            }

            UpdateFloats();
            Log("Textures initialized");
        }
Пример #8
0
        private void LoadConfigNode(ConfigNode node, string url, bool useVolume, bool defaults)
        {
            //Debug.Log("LoadConfigNode Called"); Called on MainMenu
            ConfigNode loadNode = node.GetNode("SAVED");

            if ((loadNode == null || defaults) && node.HasNode("DEFAULTS"))
            {
                loadNode = node.GetNode("DEFAULTS");
                loadNode.RemoveValue("REMOVED");
            }
            else if (node.HasValue("REMOVED") && bool.Parse(node.GetValue("REMOVED")))
            {
                return;
            }
            else if (defaults && !node.HasNode("DEFAULTS"))
            {
                node.AddValue("REMOVED", true);
                return;
            }
            String    body          = loadNode.GetValue("body");
            Transform bodyTransform = null;

            try
            {
                bodyTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == body);
            }
            catch
            {
            }
            if (bodyTransform != null)
            {
                float        altitude     = float.Parse(loadNode.GetValue("altitude"));
                TextureSet   mTexture     = new TextureSet(loadNode.GetNode("main_texture"), false);
                TextureSet   dTexture     = new TextureSet(loadNode.GetNode("detail_texture"), false);
                ConfigNode   floatsConfig = loadNode.GetNode("shader_floats");
                ShaderFloats shaderFloats = null;
                if (floatsConfig != null)
                {
                    shaderFloats = new ShaderFloats(floatsConfig);
                }
                ConfigNode   scaledfloatsConfig = loadNode.GetNode("scaled_shader_floats");
                ShaderFloats scaledShaderFloats = null;
                if (scaledfloatsConfig != null)
                {
                    scaledShaderFloats = new ShaderFloats(scaledfloatsConfig);
                }
                ConfigNode colorNode = loadNode.GetNode("color");
                Color      color     = new Color(
                    float.Parse(colorNode.GetValue("r")),
                    float.Parse(colorNode.GetValue("g")),
                    float.Parse(colorNode.GetValue("b")),
                    float.Parse(colorNode.GetValue("a")));
                if (useVolume)
                {
                    bool.TryParse(loadNode.GetValue("volume"), out useVolume);
                }
                CloudLayer.Layers.Add(
                    new CloudLayer(url, node, body, color, altitude,
                                   mTexture, dTexture, scaledShaderFloats, shaderFloats, useVolume));
            }
            else
            {
                CloudLayer.Log("body " + body + " does not exist!");
            }
        }
 public void Clone(ShaderFloats toClone)
 {
     FalloffPower = toClone.FalloffPower;
     FalloffScale = toClone.FalloffScale;
     DetailDistance = toClone.DetailDistance;
     MinimumLight = toClone.MinimumLight;
     FadeDistance = toClone.FadeDistance;
     RimDistance = toClone.RimDistance;
     FalloffPowerString = FalloffPower.ToString("R");
     FalloffScaleString = FalloffScale.ToString("R");
     DetailDistanceString = DetailDistance.ToString("R");
     MinimumLightString = MinimumLight.ToString("R");
     FadeDistanceString = FadeDistance.ToString("R");
     RimDistanceString = RimDistance.ToString("R");
 }
        private void LoadConfigNode(ConfigNode node, string url, bool useVolume, bool defaults)
        {
            ConfigNode loadNode = node.GetNode("SAVED");
            if ((loadNode == null || defaults) && node.HasNode("DEFAULTS"))
            {
                loadNode = node.GetNode("DEFAULTS");
                loadNode.RemoveValue("REMOVED");
            }
            else if( node.HasValue("REMOVED") && bool.Parse(node.GetValue("REMOVED")))
            {
                return;
            }
            else if (defaults && !node.HasNode("DEFAULTS"))
            {
                node.AddValue("REMOVED", true);
                return;
            }

            String body = loadNode.GetValue("body");
            Transform bodyTransform = null;
            try
            {
                bodyTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == body);
            }
            catch
            {

            }
            if (bodyTransform != null)
            {
                float altitude = float.Parse(loadNode.GetValue("altitude"));

                TextureSet mTexture = new TextureSet(loadNode.GetNode("main_texture"), false);
                TextureSet dTexture = new TextureSet(loadNode.GetNode("detail_texture"), false);
                ConfigNode floatsConfig = loadNode.GetNode("shader_floats");
                ShaderFloats shaderFloats = null;
                if (floatsConfig != null)
                {
                    shaderFloats = new ShaderFloats(floatsConfig);
                }
                ConfigNode scaledfloatsConfig = loadNode.GetNode("scaled_shader_floats");
                ShaderFloats scaledShaderFloats = null;
                if (scaledfloatsConfig != null)
                {
                    scaledShaderFloats = new ShaderFloats(scaledfloatsConfig);
                }
                ConfigNode colorNode = loadNode.GetNode("color");
                Color color = new Color(
                    float.Parse(colorNode.GetValue("r")),
                    float.Parse(colorNode.GetValue("g")),
                    float.Parse(colorNode.GetValue("b")),
                    float.Parse(colorNode.GetValue("a")));
                if (useVolume)
                {
                    bool.TryParse(loadNode.GetValue("volume"), out useVolume);
                }

                CloudLayer.Layers.Add(
                    new CloudLayer(url, node, body, color, altitude,
                    mTexture, dTexture, scaledShaderFloats, shaderFloats, useVolume));
            }
            else
            {
                CloudLayer.Log("body " + body + " does not exist!");
            }
        }