private void buttonImport_Click(object sender, EventArgs e) { using (OpenFileDialog a = new OpenFileDialog() { Filter = "All supported types|*.dae;*.obj;*.bsp|DAE Files|*.dae|OBJ Files|*.obj|BSP Files|*.bsp|All files|*.*", Multiselect = true }) if (a.ShowDialog() == DialogResult.OK) { progressBar1.Minimum = 0; progressBar1.Value = 0; progressBar1.Step = 1; progressBar1.Maximum = a.FileNames.Count(); foreach (string i in a.FileNames) { RenderWareModelFile file = new RenderWareModelFile(Path.GetFileNameWithoutExtension(i) + ".BSP"); file.SetChunkNumberAndName(); if (Path.GetExtension(i).ToLower() == ".obj") { file.SetForRendering(CreateBSPFile(i, ReadOBJFile(i, false)), null); } else if (Path.GetExtension(i).ToLower() == ".dae") { file.SetForRendering(CreateBSPFile(i, ConvertDataFromDAEObject(ReadDAEFile(i), false)), null); } else if (new string[] { ".bsp", ".rg1", ".rp2", ".rx1" }.Contains(Path.GetExtension(i).ToLower())) { file.SetForRendering(ReadFileMethods.ReadRenderWareFile(i), File.ReadAllBytes(i)); } BSPStream.Add(file); listBoxLevelModels.Items.Add(file.fileName); progressBar1.PerformStep(); } progressBar1.Value = 0; } }
private void buttonImport_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog() { Filter = GetImportFilter(), // "All supported types|*.dae;*.obj;*.bsp|DAE Files|*.dae|OBJ Files|*.obj|BSP Files|*.bsp|All files|*.*", Multiselect = true }; if (openFile.ShowDialog() == DialogResult.OK) { progressBar1.Minimum = 0; progressBar1.Value = 0; progressBar1.Step = 1; progressBar1.Maximum = openFile.FileNames.Count(); foreach (string i in openFile.FileNames) { RenderWareModelFile file = new RenderWareModelFile(Path.GetFileNameWithoutExtension(i) + ".BSP"); file.SetChunkNumberAndName(); try { if (new string[] { ".bsp", ".rg1", ".rp2", ".rx1" }.Contains(Path.GetExtension(i).ToLower())) { file.SetForRendering(Program.MainForm.renderer.Device, ReadFileMethods.ReadRenderWareFile(i), File.ReadAllBytes(i)); } else if (Path.GetExtension(i).ToLower() == ".obj" || Path.GetExtension(i).ToLower() == ".dae") { try { if (Path.GetExtension(i).ToLower() == ".obj") { file.SetForRendering(Program.MainForm.renderer.Device, CreateBSPFile(i, ReadOBJFile(i, false), checkBoxTristrip.Checked, checkBoxFlipUVs.Checked), null); } else { file.SetForRendering(Program.MainForm.renderer.Device, CreateBSPFile(i, ConvertDataFromDAEObject(ReadDAEFile(i), false), checkBoxTristrip.Checked, checkBoxFlipUVs.Checked), null); } } catch { file.SetForRendering(Program.MainForm.renderer.Device, CreateBSPFromAssimp(i, checkBoxFlipUVs.Checked), null); } } else { file.SetForRendering(Program.MainForm.renderer.Device, CreateBSPFromAssimp(i, checkBoxFlipUVs.Checked), null); } } catch (Exception ex) { MessageBox.Show($"Error importing {Path.GetFileName(i)} : {ex.Message}"); progressBar1.PerformStep(); continue; } bspRenderer.BSPList.Add(file); listBoxLevelModels.Items.Add(file.fileName); progressBar1.PerformStep(); } progressBar1.Value = 0; } }