Esempio n. 1
0
        string GetModelName(string ObjName) //convert bfres to obj and cache in models folder
        {
            if (SkipModels?.Contains(ObjName) ?? false)
            {
                return(null);
            }

            string CachedModelPath = $"{ModelsFolder}\\{ObjName}.obj";

            if (File.Exists(CachedModelPath))
            {
                return(CachedModelPath);
            }
            else if (NoModels)
            {
                return(null);
            }
            else if (BfresConverter.Convert(BfresFromSzs(ObjName), CachedModelPath))
            {
                return(CachedModelPath);
            }

            SkipModels?.Add(ObjName);
            return(null);
        }
Esempio n. 2
0
 public void Convert(string inF, string outF)
 {
     if (inF.EndsWith("bfres"))
     {
         if (!Directory.Exists(Path.GetDirectoryName(outF)))
         {
             Directory.CreateDirectory(Path.GetDirectoryName(outF));
         }
         BfresConverter.Convert(File.ReadAllBytes(inF), outF);
     }
     else
     {
         Console.Write("This tool can only convert BFRES files to OBJ files!\nUsage: BFRES2OBJ.exe <BFRES> <OBJ>");
     }
 }
Esempio n. 3
0
        public ILevel LoadLevel(string file = null)
        {
            if (file == null)
            {
                var opn = new OpenFileDialog()
                {
                    Filter = LevelFormatFilter
                };
                if (opn.ShowDialog() != DialogResult.OK)
                {
                    return(null);
                }
                file = opn.FileName;
            }

            var res = new Level(file);

            string stageName      = new DirectoryInfo(file).Parent.Name;
            string stageModelPath = $"{ModelsFolder}\\{stageName}.obj";

            if (!File.Exists(stageModelPath))
            {
                byte[] CourseBfres = YAZ0.Decompress(Path.GetDirectoryName(file) + "\\course_model.szs");
                if (BfresConverter.Convert(CourseBfres, ModelsFolder) == null)
                {
                    stageModelPath = null;
                }
            }

            if (stageModelPath != null)
            {
                StageDummyModel           = new LevelObj(false, true);
                StageDummyModel.ModelName = $"{stageName}";
                StageDummyModel.Scale     = new System.Windows.Media.Media3D.Vector3D(1, 1, 1);
                res.objs["StageModel - Can't edit"].Add(StageDummyModel);
            }

            GC.Collect();

            return(res);
        }
Esempio n. 4
0
 public bool ConvertModelFile(string ObjName, string path) => BfresConverter.Convert(FindBfres(ObjName), path) != null;