コード例 #1
0
        private static void AddMaterials(string fullFileName, ISceneEngine sceneEngine, string line, ref string mtlName, ActionResult <SceneElement> actionResult)
        {
            var currentDirectory = Environment.CurrentDirectory;

            try
            {
                var fileInfo = new FileInfo(fullFileName);
                if (line.StartsWith("mtllib") && fullFileName != null && fileInfo.Exists && fileInfo.Directory != null)
                {
                    // Set current directory in case a relative path to material file is used.
                    // ReSharper disable once AssignNullToNotNullAttribute
                    Environment.CurrentDirectory = fileInfo.Directory.FullName;

                    // Load materials file.
                    var mtlPath = ReadMaterialValue(line);
                    if (!File.Exists(mtlPath))
                    {
                        actionResult.AddWarning(Resources.Message_AddMaterials_File_with_material_N_not_found, mtlPath);
                        return;
                    }
                    LoadMaterials(mtlPath, sceneEngine);
                }

                if (line.StartsWith("usemtl"))
                {
                    mtlName = ReadMaterialValue(line);
                }
            }
            finally
            {
                Environment.CurrentDirectory = currentDirectory;
            }
        }
コード例 #2
0
        private static void AddMaterials(string fullFileName, ISceneEngine sceneEngine, string line, ref string mtlName, ActionResult<SceneElement> actionResult)
        {
            var currentDirectory = Environment.CurrentDirectory;
            try
            {
                var fileInfo = new FileInfo(fullFileName);
                if (line.StartsWith("mtllib") && fullFileName != null && fileInfo.Exists && fileInfo.Directory != null)
                {
                    // Set current directory in case a relative path to material file is used.
                    // ReSharper disable once AssignNullToNotNullAttribute
                    Environment.CurrentDirectory = fileInfo.Directory.FullName;

                    // Load materials file.
                    var mtlPath = ReadMaterialValue(line);
                    if (!File.Exists(mtlPath))
                    {
                        actionResult.AddWarning(Resources.Message_AddMaterials_File_with_material_N_not_found, mtlPath);
                        return;
                    }
                    LoadMaterials(mtlPath, sceneEngine);
                }

                if (line.StartsWith("usemtl"))
                    mtlName = ReadMaterialValue(line);
            }
            finally
            {
                Environment.CurrentDirectory = currentDirectory;
            }
        }