Esempio n. 1
0
        private void SetMaterialTextures(MyMaterialDescriptor matDesc, Material material)
        {
            TextureSlot texture;

            material.GetMaterialTexture(TextureType.Diffuse, 0, out texture);
            string filePath = texture.FilePath;

            if (filePath.Length < MyMeshPartSolver.ColorMetalSuffix.Length)
            {
                return;
            }
            string str = filePath.Substring(0, filePath.Length - MyMeshPartSolver.ColorMetalSuffix.Length);

            try
            {
                string path2 = MyModelProcessor.GetResourcePathInContent(str + MyMeshPartSolver.ColorMetalSuffix).TrimStart('\\', '/');
                if (File.Exists(Path.Combine(ProgramContext.OutputDir, path2)))
                {
                    matDesc.Textures.Add("ColorMetalTexture", path2);
                }
            }
            catch
            {
            }
            try
            {
                string path2 = MyModelProcessor.GetResourcePathInContent(str + MyMeshPartSolver.NormalGlossSuffix).TrimStart('\\', '/');
                if (File.Exists(Path.Combine(ProgramContext.OutputDir, path2)))
                {
                    matDesc.Textures.Add("NormalGlossTexture", path2);
                }
            }
            catch
            {
            }
            try
            {
                string path2 = MyModelProcessor.GetResourcePathInContent(str + MyMeshPartSolver.AddMapsSuffix).TrimStart('\\', '/');
                if (File.Exists(Path.Combine(ProgramContext.OutputDir, path2)))
                {
                    matDesc.Textures.Add("AddMapsTexture", path2);
                }
            }
            catch
            {
            }
            try
            {
                string path2 = MyModelProcessor.GetResourcePathInContent(str + MyMeshPartSolver.AlphamaskSuffix).TrimStart('\\', '/');
                if (!File.Exists(Path.Combine(ProgramContext.OutputDir, path2)))
                {
                    return;
                }
                matDesc.Textures.Add("AlphamaskTexture", path2);
            }
            catch
            {
            }
        }
Esempio n. 2
0
        private void SetMaterialTextures(MyMaterialDescriptor matDesc, Material material)
        {
            TextureSlot texture;

            material.GetMaterialTexture(TextureType.Diffuse, 0, out texture);


            //Custom Change Nr 1.
            //Always set the path to this instead of filepath of textures.
            //This fixes the problem that assimp can't read pbr materials from max properly
            string filePath = material.Name + "_cm.dds";

            //string filePath = texture.FilePath; <-- original

            if (filePath.Length < MyMeshPartSolver.ColorMetalSuffix.Length)
            {
                return;
            }
            string str = filePath.Substring(0, filePath.Length - MyMeshPartSolver.ColorMetalSuffix.Length);

            try
            {
                string path2 = MyModelProcessor.GetResourcePathInContent(str + MyMeshPartSolver.ColorMetalSuffix).TrimStart('\\', '/');
                //   if (File.Exists(Path.Combine(ProgramContext.OutputDir, path2)))
                matDesc.Textures.Add("ColorMetalTexture", path2);
            }
            catch
            {
            }
            try
            {
                string path2 = MyModelProcessor.GetResourcePathInContent(str + MyMeshPartSolver.NormalGlossSuffix).TrimStart('\\', '/');
                // if (File.Exists(Path.Combine(ProgramContext.OutputDir, path2)))
                matDesc.Textures.Add("NormalGlossTexture", path2);
            }
            catch
            {
            }
            try
            {
                string path2 = MyModelProcessor.GetResourcePathInContent(str + MyMeshPartSolver.AddMapsSuffix).TrimStart('\\', '/');
                //if (File.Exists(Path.Combine(ProgramContext.OutputDir, path2)))
                matDesc.Textures.Add("AddMapsTexture", path2);
            }
            catch
            {
            }
            try
            {
                string path2 = MyModelProcessor.GetResourcePathInContent(str + MyMeshPartSolver.AlphamaskSuffix).TrimStart('\\', '/');
                //  if (!File.Exists(Path.Combine(ProgramContext.OutputDir, path2)))
                //    return;
                matDesc.Textures.Add("AlphamaskTexture", path2);
            }
            catch
            {
            }
        }