예제 #1
0
        public readonly int featureMask;            //1 = color, 2 = specular, 4 = metallic, 8 = hardness

        public TextureSet(ConfigNode node)
        {
            name  = node.GetStringValue("name");
            title = node.GetStringValue("title", name);
            ConfigNode[] texNodes = node.GetNodes("TEXTURE");
            int          len      = texNodes.Length;

            textureData = new TextureSetMaterialData[len];
            for (int i = 0; i < len; i++)
            {
                textureData[i] = new TextureSetMaterialData(texNodes[i]);
            }
            supportsRecoloring     = node.GetBoolValue("recolorable", false);
            recolorableChannelMask = node.GetIntValue("channelMask", 1 | 2 | 4);
            featureMask            = node.GetIntValue("featureMask", 1 | 2 | 4);
            if (node.HasNode("COLORS"))
            {
                ConfigNode     colorsNode = node.GetNode("COLORS");
                RecoloringData c1         = new RecoloringData(colorsNode.GetStringValue("mainColor"));
                RecoloringData c2         = new RecoloringData(colorsNode.GetStringValue("secondColor"));
                RecoloringData c3         = new RecoloringData(colorsNode.GetStringValue("detailColor"));
                maskColors = new RecoloringData[] { c1, c2, c3 };
            }
            else
            {
                maskColors = new RecoloringData[3];
                Color white = Color.white;
                maskColors[0] = new RecoloringData(white, 0, 0);
                maskColors[1] = new RecoloringData(white, 0, 0);
                maskColors[2] = new RecoloringData(white, 0, 0);
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <param name="defaultMode"></param>
        public TextureSet(ConfigNode node, string defaultMode)
        {
            name  = node.GetStringValue("name");
            title = node.GetStringValue("title", name);
            ConfigNode[] texNodes = node.GetNodes("MATERIAL");
            int          len      = texNodes.Length;

            if (len == 0)
            {
                Log.log("Did not find any MATERIAL nodes in texture set:" + name + ", searching for legacy styled TEXTURE nodes.");
                Log.log("Please update the config for the texture-set to fix this error.");
                texNodes = node.GetNodes("TEXTURE");
                len      = texNodes.Length;
            }
            textureData = new TextureSetMaterialData[len];
            for (int i = 0; i < len; i++)
            {
                textureData[i] = new TextureSetMaterialData(this, texNodes[i], defaultMode);
            }
            supportsRecoloring     = node.GetBoolValue("recolorable", false);
            recolorableChannelMask = node.GetIntValue("channelMask", 1 | 2 | 4);
            featureMask            = node.GetIntValue("featureMask", 1 | 2 | 4);
            if (node.HasNode("COLORS"))
            {
                ConfigNode     colorsNode = node.GetNode("COLORS");
                RecoloringData c1         = RecoloringData.ParseColorsBlockEntry(colorsNode.GetStringValue("mainColor"));
                RecoloringData c2         = RecoloringData.ParseColorsBlockEntry(colorsNode.GetStringValue("secondColor"));
                RecoloringData c3         = RecoloringData.ParseColorsBlockEntry(colorsNode.GetStringValue("detailColor"));
                maskColors = new RecoloringData[] { c1, c2, c3 };
            }
            else
            {
                maskColors = new RecoloringData[3];
                Color white = PresetColor.getColor("white").color;//will always return -something-, even if 'white' is undefined
                maskColors[0] = new RecoloringData(white, 0, 0, 1);
                maskColors[1] = new RecoloringData(white, 0, 0, 1);
                maskColors[2] = new RecoloringData(white, 0, 0, 1);
            }
            //loop through materials, and auto-enable 'recoloring' flag if recoloring keyword is set
            len = textureData.Length;
            for (int i = 0; i < len; i++)
            {
                int len2 = textureData[i].shaderProperties.Length;
                for (int k = 0; k < len2; k++)
                {
                    if (textureData[i].shaderProperties[k].name == "TU_RECOLOR")
                    {
                        supportsRecoloring = true;
                    }
                }
            }
        }
예제 #3
0
 private void applyConfig(Transform root, TextureSet set, bool useSetColors, bool useIconShaders = false)
 {
     if (set == null)
     {
         return;
     }
     RecoloringData[] colors = useSetColors? set.maskColors : customColors;
     if (useSetColors)
     {
         customColors = set.maskColors;
         saveColors(customColors);
     }
     //apply the texture set to the base model (and trusses?)
     set.enable(root, colors, useIconShaders);
     if (stockFairing)
     {
         TextureSetMaterialData tsmd = set.textureData[0];
         //adjust the already existing fairing materials and fairing panels
         ModuleProceduralFairing mpf = part.GetComponent <ModuleProceduralFairing>();
         if (mpf != null)
         {
             Material mat;
             if (mpf.FairingMaterial != null && mpf.FairingConeMaterial != null)
             {
                 mat = mpf.FairingMaterial;
                 tsmd.apply(mat, useIconShaders);
                 tsmd.applyRecoloring(mat, colors);
                 mat = mpf.FairingConeMaterial;
                 tsmd.apply(mat, useIconShaders);
                 tsmd.applyRecoloring(mat, colors);
             }
             if (mpf.Panels != null && mpf.Panels.Count > 0)//cones are included in regular panels
             {
                 int len = mpf.Panels.Count;
                 for (int i = 0; i < len; i++)
                 {
                     mat = mpf.Panels[i].mat;
                     tsmd.apply(mat, useIconShaders);
                     tsmd.applyRecoloring(mat, colors);
                     mat = mpf.Panels[i].go.GetComponent <Renderer>().material;
                     tsmd.apply(mat, useIconShaders);
                     tsmd.applyRecoloring(mat, colors);
                 }
             }
         }
     }
 }
예제 #4
0
        //really, could probably just move this back to the base class, possibly with a config bool for toggling enable of the secondary updates
        public void Start()
        {
            TextureSet ts = TexturesUnlimitedLoader.getTextureSet(textureSet);

            if (ts != null)
            {
                //apply the textur set to the base model, use set-specified mask colors (does not support user recoloring)
                ts.enable(part.transform.FindRecursive("model"), ts.maskColors);
                TextureSetMaterialData tsmd = ts.textureData[materialIndex];
                //adjust the already existing fairing materials and fairing panels
                ModuleProceduralFairing mpf = part.GetComponent <ModuleProceduralFairing>();
                if (mpf != null)
                {
                    if (mpf.FairingMaterial != null && mpf.FairingConeMaterial != null)
                    {
                        tsmd.apply(mpf.FairingMaterial);
                        tsmd.apply(mpf.FairingConeMaterial);
                    }
                    if (mpf.Panels != null && mpf.Panels.Count > 0)//cones are included in regular panels
                    {
                        int len = mpf.Panels.Count;
                        for (int i = 0; i < len; i++)
                        {
                            tsmd.apply(mpf.Panels[i].mat);
                            tsmd.apply(mpf.Panels[i].go.GetComponent <Renderer>().material);
                        }
                    }
                }
            }
            //prev shader-only code...
            //Shader shader = TexturesUnlimitedLoader.getShader(this.shader);
            //if (mpf != null && shader != null && mpf.FairingMaterial != null)
            //{
            //    mpf.FairingMaterial.shader = shader;
            //    if (mpf.FairingConeMaterial != null) { mpf.FairingConeMaterial.shader = shader; }
            //    MonoBehaviour.print("Adjusted MPF materials!");
            //    if (mpf.Panels != null && mpf.Panels.Count > 0)//cones are included in regular panels
            //    {
            //        int len = mpf.Panels.Count;
            //        for (int i = 0; i < len; i++)
            //        {
            //            mpf.Panels[i].mat.shader = shader;
            //            mpf.Panels[i].go.GetComponent<Renderer>().material.shader = shader;
            //        }
            //    }
            //}
        }
예제 #5
0
        public TextureSet(ConfigNode node)
        {
            name  = node.GetStringValue("name");
            title = node.GetStringValue("title", name);
            ConfigNode[] texNodes = node.GetNodes("MATERIAL");
            int          len      = texNodes.Length;

            if (len == 0)
            {
                MonoBehaviour.print("Did not find any MATERIAL nodes in texture set:" + name + ", searching for legacy styled TEXTURE nodes.");
                MonoBehaviour.print("Please update the config for the texture-set to fix this error.");
                texNodes = node.GetNodes("TEXTURE");
                len      = texNodes.Length;
            }
            textureData = new TextureSetMaterialData[len];
            for (int i = 0; i < len; i++)
            {
                textureData[i] = new TextureSetMaterialData(texNodes[i]);
            }
            supportsRecoloring     = node.GetBoolValue("recolorable", false);
            recolorableChannelMask = node.GetIntValue("channelMask", 1 | 2 | 4);
            featureMask            = node.GetIntValue("featureMask", 1 | 2 | 4);
            if (node.HasNode("COLORS"))
            {
                ConfigNode     colorsNode = node.GetNode("COLORS");
                RecoloringData c1         = new RecoloringData(colorsNode.GetStringValue("mainColor"));
                RecoloringData c2         = new RecoloringData(colorsNode.GetStringValue("secondColor"));
                RecoloringData c3         = new RecoloringData(colorsNode.GetStringValue("detailColor"));
                maskColors = new RecoloringData[] { c1, c2, c3 };
            }
            else
            {
                maskColors = new RecoloringData[3];
                Color white = Color.white;
                maskColors[0] = new RecoloringData(white, 0, 0);
                maskColors[1] = new RecoloringData(white, 0, 0);
                maskColors[2] = new RecoloringData(white, 0, 0);
            }
        }