private void ImportModel(Polymodel original) { int oldNumTextures = original.NumTextures; List <string> newTextureNames = new List <string>(); openFileDialog1.Filter = "Parallax Object Files|*.pof"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string traceto = ""; if (bool.Parse(StandardUI.options.GetOption("TraceModels", bool.FalseString))) { string bareFilename = Path.GetFileName(openFileDialog1.FileName); traceto = StandardUI.options.GetOption("TraceDir", ".") + Path.DirectorySeparatorChar + Path.ChangeExtension(bareFilename, "txt"); } Polymodel model = POFReader.ReadPOFFile(openFileDialog1.FileName, traceto); model.ExpandSubmodels(); //int numTextures = model.n_textures; //datafile.ReplaceModel(ElementNumber, model); datafile.replacedModels[ElementNumber] = model; model.replacementID = ReplacedElementComboBox.SelectedIndex; UpdateModelPanel(ElementNumber); } }
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(); }
private void btnImportModel_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { string traceto = ""; if (bool.Parse(StandardUI.options.GetOption("TraceModels", bool.FalseString))) { string bareFilename = Path.GetFileName(openFileDialog1.FileName); traceto = StandardUI.options.GetOption("TraceDir", ".") + Path.DirectorySeparatorChar + Path.ChangeExtension(bareFilename, "txt"); } Stream stream = File.OpenRead(openFileDialog1.FileName); Polymodel newmodel = POFReader.ReadPOFFile(stream); stream.Close(); stream.Dispose(); newmodel.ExpandSubmodels(); //datafile.ReplaceModel(ElementNumber, model); ModelReplaceTransaction transaction = new ModelReplaceTransaction("Load model", (object)model, newmodel, modelID, tabPage); transactionManager.ApplyTransaction(transaction); Update(model, modelID); } }