示例#1
0
        /// <summary>
        /// Writes this material and any accompanying textures to a file
        /// </summary>
        /// <param name="path">The file name to write to, without any extensions</param>
        public void WriteToFiles(string path)
        {
            var file = Path.GetFileName(path);

            var mtlText = new List <string>();

            mtlText.Add("# Exported from EffigyMaker");
            mtlText.Add("# Material count 1");
            mtlText.Add("");
            mtlText.Add($"newmtl {Name}");
            mtlText.Add($"Kd 1.000 1.000 1.000");
            mtlText.Add("Ka 1.000000 1.000000 1.000000");
            mtlText.Add("Ks 1.000000 1.000000 1.000000");
            mtlText.Add("Ni 1.450000");
            mtlText.Add("d 1.000000");
            mtlText.Add("illum 2");
            mtlText.Add($"map_Kd {file}.png");
            mtlText.Add($"map_bump {file}_Normals.png");
            //mtlText.Add($"map_Ks {file}_Specular.png"); (ignore specular for now, because its a bit bugged)

            File.WriteAllText(path + ".mtl", string.Join("\n", mtlText));

            File.WriteAllBytes(path + ".png", TextureImage.Encode(SKEncodedImageFormat.Png, 100).ToArray());
            File.WriteAllBytes(path + "_Normals.png", NormalsImage.Encode(SKEncodedImageFormat.Png, 100).ToArray());
            //File.WriteAllBytes(path + "_Specular.png", SpecularImage.Encode(SKEncodedImageFormat.Png, 100).ToArray());
        }