public static VboEntity BuildPlane(Vector3 position, Quaternion rotation, Vector3 scale, Color4 color, int xd, int yd) { var name = "plane_" + xd + "," + yd; if (!BufferLibrary.HasBuffer(name + "_" + color.ToArgb() + ":v")) { var verts = new List <Vertex>(); for (var x = 0; x <= xd; x++) { for (var y = 0; y <= yd; y++) { verts.Add(new Vertex(new Vector3((x - xd / 2f) / (xd / 2f), 0, (y - yd / 2f) / (yd / 2f)), new Vector4(0, 1, 0, 1), Vector3.UnitY)); } } BufferLibrary.CreateVertexBuffer(name + "_" + color.ToArgb() + ":v", verts.ToArray()); } if (!BufferLibrary.HasBuffer(name + ":i")) { var indices = new List <uint>(); for (var x = 0; x < xd; x++) { for (var y = 0; y < yd; y++) { indices.Add((uint)(x * (yd + 1) + y)); indices.Add((uint)(x * (yd + 1) + y + 1)); indices.Add((uint)((x + 1) * (yd + 1) + y + 1)); indices.Add((uint)((x + 1) * (yd + 1) + y)); } } BufferLibrary.CreateIndexBuffer(name + ":i", indices.ToArray(), PrimitiveType.Quads); } return(new VboEntity(position, rotation, scale, BufferLibrary.GetBuffer(name + "_" + color.ToArgb() + ":v"), BufferLibrary.GetBuffer(name + ":i"), BufferLibrary.GetBuffer(name + ":i#count"), (PrimitiveType)BufferLibrary.GetBuffer(name + ":i#mode"))); }