Exemplo n.º 1
0
        private void CreateTree(string filePath)
        {
            RawObjModel model = RawObjLoader.LoadRawObj(filePath);

            if (model == null)
            {
                MessageBox.Show("Could not load Model" + filePath);
                return;
            }
            else if (model.Meshes == null || !model.Meshes.Any())
            {
                MessageBox.Show("Loaded model is empty" + filePath);
                return;
            }

            Bind();
            List <int> indices = new List <int>();

            foreach (Mesh mesh in model.Meshes)
            {
                indices.AddRange(mesh.Indices);
            }
            RawModel = model;
            SetVerticesBuffer(model.Vertices.ToArray(), renderer.PositionAttribute);
            SetIndicesBuffer(indices.ToArray());
            SetNormalsBuffer(model.Normals.ToArray(), renderer.NormalAttribute);
            SetTextureBuffer(model.TextureCoordinates.ToArray(), renderer.TextureCoordAttribute);
            UnBind();
        }
Exemplo n.º 2
0
        private void CreateAircraft(string filePath)
        {
            RawObjModel model = RawObjLoader.LoadRawObj(filePath);

            if (model == null)
            {
                MessageBox.Show("Could not load Model" + Resources.AircraftModel);
                return;
            }
            else if (model.Meshes == null || model.Meshes.Count == 0)
            {
                MessageBox.Show("Loaded model is empty" + Resources.AircraftModel);
                return;
            }

            Bind();
            List <int> indices = new List <int>();

            foreach (Mesh mesh in model.Meshes)
            {
                indices.AddRange(mesh.Indices);
            }

            _rawModel = model;
            SetVerticesBuffer(model.Vertices.ToArray(), renderer.PositionAttribute);
            SetIndicesBuffer(indices.ToArray());
            SetNormalsBuffer(model.Normals.ToArray(), renderer.NormalAttribute);
            UnBind();
        }