Ejemplo n.º 1
0
        private void save3diButton_Click(object sender, EventArgs e)
        {
            using (var fileDialog = new SaveFileDialog {
                Title = "Save .3di file", Filter = "DF2 3di Files|*.3di"
            })
            {
                if (fileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var textures = new List <Texture>();
                for (short i = 0; i < textureDataGrid.Rows.Count; i++)
                {
                    var row    = textureDataGrid.Rows[i];
                    var name   = row.Cells[0].Value.ToString();
                    var width  = Convert.ToInt16(row.Cells[1].Value);
                    var height = Convert.ToInt16(row.Cells[2].Value);

                    textures.Add(new Texture(name, i, width, height));
                }

                var df2Model = MqoTo3diConverter.Convert(modelNameTextBox.Text, mqoModel, textures, collision);
                df2Model.SaveToFile(fileDialog.FileName);

                MessageBox.Show("3di saved sucessfully!", "Success");
            }
        }
        private Model Convert()
        {
            var mqo       = MqoModel.Load("Resources/box-object.mqo");
            var collision = MqoModel.Load("Resources/box-collision.mqo");

            return(MqoTo3diConverter.Convert("box", mqo, new List <Texture> {
                new Texture("box", 0, 512, 512)
            }, collision));
        }
        public void CollisionPlanesTest()
        {
            var mqo       = MqoModel.Load("Resources/box-object.mqo");
            var collision = MqoModel.Load("Resources/box-collision.mqo");
            var df2       = MqoTo3diConverter.Convert("box", mqo, new List <Texture> {
                new Texture("box", 0, 512, 512)
            }, collision);
            var expected = File.ReadAllBytes("Resources/collision-planes.3di");
            var actual   = df2.Lods[0].CollisionPlaneVectors.SelectMany(collisionPlane => TestUtils.SerializeToBytes(collisionPlane)).ToArray();

            Assert.True(expected.SequenceEqual(actual));
        }