internal static GraphicsBuffers ToGraphicsBuffers(this IList <Vector3> vertices, bool lineLoop) { var gb = new GraphicsBuffers(); for (var i = 0; i < vertices.Count; i++) { var v = vertices[i]; gb.AddVertex(v, default(Vector3), default(UV), null); var write = lineLoop ? (i < vertices.Count - 1) : (i % 2 == 0 && i < vertices.Count - 1); if (write) { gb.AddIndex((ushort)i); gb.AddIndex((ushort)(i + 1)); } } return(gb); }
/// <summary> /// Get all buffers required for rendering. /// </summary> public GraphicsBuffers GetBuffers() { var buffers = new GraphicsBuffers(); for (var i = 0; i < this.Vertices.Count; i++) { var v = this.Vertices[i]; buffers.AddVertex(v.Position, v.Normal, v.UV, v.Color); } for (var i = 0; i < this.Triangles.Count; i++) { var t = this.Triangles[i]; buffers.AddIndex((ushort)t.Vertices[0].Index); buffers.AddIndex((ushort)t.Vertices[1].Index); buffers.AddIndex((ushort)t.Vertices[2].Index); } return(buffers); }