Esempio n. 1
0
 public IPXPmx Import(string path, IPERunArgs args)
 {
     try
     {
         form = new ObjImportForm(path, args);
         form.ShowDialog();
         if (form.DialogResult == DialogResult.OK)
         {
             //New importer parses OBJ/MTL files into IPX*-types
             ObjFileImporter importer = new ObjFileImporter(path, builder, form.Settings);
             //If there are errors, notify the user
             if (importer.ErrorNum + importer.ErrorNumMtl > 0)
             {
                 if (MessageBox.Show($"There have been errors during import:\n{importer.ErrorNum} while processing OBJ\n{importer.ErrorNumMtl} while processing MTL\n\nWould you like to open the log file to find out what happened?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                 {
                     System.Diagnostics.Process.Start(importer.LogFileUrl);
                 }
             }
             return(importer.ToPmx());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     //If execution reaches this point, either an error has occured or the user pressed Cancel.
     pmx = builder.Pmx();
     return(pmx);
 }
        public static StaticMesh[] ImportModelFromFile(string filePath)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException(nameof(filePath));
            }

            switch (GetFormatFromFile(filePath))
            {
            case SupportedFormats.Obj:
                var objImporter = new ObjFileImporter(filePath);
                return(objImporter.GetResult());

            default:
                throw new ArgumentException("Unsupported file format");
            }
        }