private void menuItem6_Click(object sender, EventArgs e) { saveFileDialog1.Filter = "Bitmap table files|*.TBL"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { StreamWriter sw = new StreamWriter(File.Open(saveFileDialog1.FileName, FileMode.Create)); sw.Write(BitmapTableFile.GenerateBitmapsTable(datafile, piggyFile, host.DefaultSoundFile)); sw.Flush(); sw.Close(); sw.Dispose(); string modelPath = Path.GetDirectoryName(saveFileDialog1.FileName); Polymodel model; if (datafile.Models.Count >= 160) { //for (int i = 0; i < datafile.PolygonModels.Count; i++) foreach (int i in BitmapTableFile.pofIndicies) { model = datafile.Models[i]; BinaryWriter bw = new BinaryWriter(File.Open(String.Format("{0}{1}{2}", modelPath, Path.DirectorySeparatorChar, BitmapTableFile.pofNames[i]), FileMode.Create)); POFWriter.SerializePolymodel(bw, model, 8); bw.Close(); bw.Dispose(); } } } }
private void btnExportModel_Click(object sender, EventArgs e) { saveFileDialog1.Filter = "Parallax Object Files|*.pof"; saveFileDialog1.FileName = string.Format("model_{0}.pof", ElementNumber); if (saveFileDialog1.ShowDialog() == DialogResult.OK) { BinaryWriter bw = new BinaryWriter(File.Open(saveFileDialog1.FileName, FileMode.Create)); POFWriter.SerializePolymodel(bw, datafile.Models[ElementNumber], short.Parse(StandardUI.options.GetOption("PMVersion", "8"))); bw.Close(); bw.Dispose(); } }
public void GenerateBSPTest() //note: this mostly just tests ATM that the code executes without error. //Proper results currently need to be visually validated with a tool like Descent 2 Workshop { Polymodel model = LibDescent.Data.POFReader.ReadPOFFile(TestUtils.GetResourceStream("NewConcussion.pof")); model.ExpandSubmodels(); //Build the BSP tree PolymodelBuilder polymodelBuilder = new PolymodelBuilder(); polymodelBuilder.RebuildModel(model); BinaryWriter bw = new BinaryWriter(File.Open("NewConcussionBSP.pof", FileMode.Create)); //the POFWriter API needs some changes... POFWriter.SerializePolymodel(bw, model, 8); bw.Flush(); bw.Close(); bw.Dispose(); }