Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        private void PartitionButton_Click(object sender, EventArgs e)
        {
            //Do in a copy to allow undo
            Polymodel        newModel = new Polymodel(model);
            PolymodelBuilder builder  = new PolymodelBuilder();

            try
            {
                builder.RebuildModel(newModel);
            }
            catch (ArgumentException exc)
            {
                MessageBox.Show(exc.Message, "Error partitioning model");
                return;
            }

            ModelReplaceTransaction transaction = new ModelReplaceTransaction("Load model", (object)model, newModel, modelID, tabPage);

            transactionManager.ApplyTransaction(transaction);
            Update(newModel, modelID);
        }