Esempio n. 1
0
        private void loadMqoButton_Click(object sender, EventArgs e)
        {
            using (var fileDialog = new OpenFileDialog {
                Filter = "Metasequoia Files|*.mqo", Title = "Select .mqo file"
            })
            {
                if (fileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                mqoModel = MqoModel.Load(fileDialog.FileName);

                var modelName = Path.GetFileNameWithoutExtension(fileDialog.SafeFileName);
                modelNameTextBox.Text = modelName.Length > 8 ? modelName.Substring(0, 8) : modelName;

                mqoModel.TextureNames.ForEach(texture =>
                                              textureDataGrid.Rows.Add(new object[] { texture, "Stone", 512, 512, false }));

                namePanel.Visible = true;
                placeholderContentLabel.Visible = false;
                texturePanel.Visible            = true;
                addCollisionButton.Enabled      = true;
                save3diButton.Enabled           = true;
                placeholderLabel.Visible        = false;
                vertexCountLabel.Visible        = true;
                faceCountLabel.Visible          = true;

                var mqoObject = mqoModel.Objects[0];
                vertexCountLabel.Text = $"Vertices: {mqoObject.Vertices.Count}";
                faceCountLabel.Text   = $"Faces: {mqoObject.Faces.Count}";
            }
        }
        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));
        }
Esempio n. 4
0
        private void addCollisionButton_Click(object sender, EventArgs e)
        {
            using (var fileDialog = new OpenFileDialog {
                Filter = "Metasequoia Files|*.mqo", Title = "Select collision .mqo file"
            })
            {
                if (fileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                collision = MqoModel.Load(fileDialog.FileName);

                collisionPlaneCountLabel.Visible = true;
                collisionVolumeLabel.Visible     = true;

                collisionPlaneCountLabel.Text = $"CPs: {collision.Objects.SelectMany(obj => obj.Faces).Count()}";
                collisionVolumeLabel.Text     = $"CVs: {collision.Objects.Count}";
            }
        }
Esempio n. 5
0
        public void LoadTest()
        {
            var model     = MqoModel.Load("Resources/box-object.mqo");
            var mqoObject = model.Objects[0];

            Assert.Equal(8, mqoObject.Vertices.Count);
            Assert.Equal(12, mqoObject.Faces.Count);

            var vertex = mqoObject.Vertices[0];

            Assert.Equal(0, vertex.X);
            Assert.Equal(1, vertex.Y);
            Assert.Equal(-1, vertex.Z);

            var face = mqoObject.Faces[0];

            Assert.Equal(0, face.MaterialIndex);
            Assert.True(new List <int> {
                5, 4, 6
            }.SequenceEqual(face.VertexIndices));

            var expectedUVCoordinates = new List <Tuple <double, double> >
            {
                Tuple.Create(1.0, 1.0),
                Tuple.Create(0.0, 1.0),
                Tuple.Create(1.0, 0.0)
            };

            Assert.True(expectedUVCoordinates.SequenceEqual(face.UVCoordinates));

            var expectedTextures = new List <string> {
                "Box.bmp"
            };

            Assert.True(expectedTextures.SequenceEqual(model.TextureNames));
        }