public void FindModelGrasMaterials()
        {
            Transform[] allTransforms = gameObject.transform.GetComponentsInChildren <Transform>(true).Where(x => x.name == GrassMeshName).ToArray();
            foreach (var transform in allTransforms)
            {
                Renderer grassRenderer = transform.GetComponent <Renderer>();

                grassRenderers.Add(grassRenderer);
                grassMaterials.Add(grassRenderer.material);
                grassRenderer.material.shader = KKGraphics.GetShader("KK/Ground_Multi_NoUV");
            }
        }
Beispiel #2
0
        internal void ReplaceShader(MeshRenderer renderer, string newShaderName)
        {
            if (!KKGraphics.HasShader(newShaderName))
            {
                Log.UserError("No Shader like this found: " + newShaderName);
                return;
            }

            Shader newShader = KKGraphics.GetShader(newShaderName);

            renderer.material.shader = newShader;
            //Log.Normal("Applied Shader: " + newShader.name);
        }
Beispiel #3
0
        /// <summary>
        /// Uses the PQS System to query the color of the undergound
        /// </summary>
        /// <param name="body"></param>
        /// <param name="lat"></param>
        /// <param name="lon"></param>
        /// <returns></returns>


        public void FindModelGrasMaterials()
        {
            Transform[] allTransforms = gameObject.transform.GetComponentsInChildren <Transform>(true).Where(x => x.name == GrasMeshName).ToArray();
            foreach (var transform in allTransforms)
            {
                transform.name = "KKGrass";
                Renderer grasRenderer = transform.GetComponent <Renderer>();
                grasMaterials.Add(grasRenderer.material);
                //grasRenderer.material.mainTexture = KKGraphics.GetTexture(GrasTextureImage);
                grasRenderer.material.mainTexture = KKGraphics.GetTexture(GrasTextureImage, false, 0, true);
                //grasRenderer.material.shader = Shader.Find("KSP/Scenery/Diffuse Multiply");
                grasRenderer.material.shader = KKGraphics.GetShader("KK/Diffuse_Multiply_Random");
            }
        }
        public void FindSquadGrasMaterial()
        {
            Transform[] allTransforms = gameObject.transform.GetComponentsInChildren <Transform>(true).Where(x => x.name == GrassMeshName).ToArray();
            foreach (var transform in allTransforms)
            {
                var renderers = transform.GetComponents <MeshRenderer>();

                foreach (var renderer in renderers)
                {
                    foreach (Material material in renderer.materials.Where(mat => mat.shader.name.StartsWith("KSP/Scenery/Diffuse Ground KSC")))
                    {
                        material.shader = KKGraphics.GetShader("KK/Ground_Multi_NoUV");

                        grassRenderers.Add(renderer);
                        grassMaterials.Add(material);

                        tarmacTiling  = renderer.material.GetTextureScale("_TarmacTexture");
                        GrassMeshName = renderer.transform.name;
                        break;
                    }
                }
            }
        }