private void AddPlane(Vector3D p1, Vector3D p2, Vector3D p3, Vector3D p4, Material mat) { Vertex[] v = new Vertex[4]; v[0] = new Vertex(p1, 0, 0); v[1] = new Vertex(p2, 0, 0); v[2] = new Vertex(p3, 0, 0); v[3] = new Vertex(p4, 0, 0); Primitive p = new Primitive(PrimitiveType.Vertex, v[0], v[1], v[3]); p.Material = mat; Primitives.Add(p); p = new Primitive(PrimitiveType.Vertex, v[1], v[2], v[3]); p.Material = mat; Primitives.Add(p); }
private void AddBox(Vector3D position, Vector3D size) { Vertex[] v = new Vertex[8]; v[0] = new Vertex(new Vector3D(position.X, position.Y, position.Z), 0, 0); v[1] = new Vertex(new Vector3D(position.X + size.X, position.Y, position.Y), 0, 0); v[2] = new Vertex(new Vector3D(position.X + size.X, position.Y + size.Y, position.Z), 0, 0); v[3] = new Vertex(new Vector3D(position.X, position.Y + size.Y, position.Z), 0, 0); v[4] = new Vertex(new Vector3D(position.X, position.Y, position.Z + size.Z), 0, 0); v[5] = new Vertex(new Vector3D(position.X + size.X, position.Y, position.Z + size.Z), 0, 0); v[6] = new Vertex(new Vector3D(position.X + size.X, position.Y + size.Y, position.Z + size.Z), 0, 0); v[7] = new Vertex(new Vector3D(position.X, position.Y + size.Y, position.Z + size.Z), 0, 0); // front plane Primitives.Add(new Primitive(PrimitiveType.Vertex, v[0], v[1], v[3])); Primitives.Add(new Primitive(PrimitiveType.Vertex, v[1], v[2], v[3])); // back plane Primitives.Add(new Primitive(PrimitiveType.Vertex, v[5], v[4], v[7])); Primitives.Add(new Primitive(PrimitiveType.Vertex, v[5], v[7], v[6])); // left plane Primitives.Add(new Primitive(PrimitiveType.Vertex, v[4], v[0], v[3])); Primitives.Add(new Primitive(PrimitiveType.Vertex, v[4], v[3], v[7])); // right plane Primitives.Add(new Primitive(PrimitiveType.Vertex, v[1], v[5], v[2])); Primitives.Add(new Primitive(PrimitiveType.Vertex, v[5], v[6], v[2])); // top plane Primitives.Add(new Primitive(PrimitiveType.Vertex, v[4], v[5], v[1])); Primitives.Add(new Primitive(PrimitiveType.Vertex, v[4], v[1], v[0])); // bottom plane Primitives.Add(new Primitive(PrimitiveType.Vertex, v[6], v[7], v[2])); Primitives.Add(new Primitive(PrimitiveType.Vertex, v[7], v[3], v[2])); }