Пример #1
0
        public void Draw(OpenGL gl)
        {
            gl.LoadIdentity();
            gl.Translate(position.X, position.Y, position.Z);
            gl.Rotate(rotationAngle, rotation.X, rotation.Y, rotation.Z);
            gl.Scale(scale.X, scale.Y, scale.Z);

            gl.Color(color[0], color[1], color[2], color[3]);
            gl.Begin(OpenGL.GL_TRIANGLES);

            foreach (var group in result.Groups)
            {
                foreach (var face in group.Faces)
                {
                    for (int i = 0; i < face.Count; ++i)
                    {
                        int normalIndex = face[i].NormalIndex;
                        int vertexIndex = face[i].VertexIndex;

                        if (normalIndex > 0)
                        {
                            Normal normal = result.Normals[normalIndex - 1];
                            gl.Normal(normal.X, normal.Y, normal.Z);
                        }
                        ObjLoader.Loader.Data.VertexData.Vertex vertex = result.Vertices[vertexIndex - 1];
                        gl.Vertex(vertex.X, vertex.Y, vertex.Z);
                    }
                }
            }

            gl.End();
        }
Пример #2
0
        public override void Parse(string line)
        {
            string[] parts = line.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);

            var x = parts[0].ParseInvariantFloat();
            var y = parts[1].ParseInvariantFloat();
            var z = parts[2].ParseInvariantFloat();

            var vertex = new Vertex(x, y, z);
            _vertexDataStore.AddVertex(vertex);
        }
Пример #3
0
 public void AddVertex(Vertex vertex)
 {
     ParsedVertex = vertex;
 }
Пример #4
0
 public void AddVertex(Vertex vertex)
 {
     _vertices.Add(vertex);
 }