class Cube { Point3D[] vertices = new Point3D[24]; float w, h, d; Cube(){ } Cube(float w, float h, float d){ this.w = w; this.h = h; this.d = d; // Cube composed of 6 quads // Front vertices[0] = new Point3D(-w/2,-h/2,d/2); vertices[1] = new Point3D(w/2,-h/2,d/2); vertices[2] = new Point3D(w/2,h/2,d/2); vertices[3] = new Point3D(-w/2,h/2,d/2); // Left vertices[4] = new Point3D(-w/2,-h/2,d/2); vertices[5] = new Point3D(-w/2,-h/2,-d/2); vertices[6] = new Point3D(-w/2,h/2,-d/2); vertices[7] = new Point3D(-w/2,h/2,d/2); // Right vertices[8] = new Point3D(w/2,-h/2,d/2); vertices[9] = new Point3D(w/2,-h/2,-d/2); vertices[10] = new Point3D(w/2,h/2,-d/2); vertices[11] = new Point3D(w/2,h/2,d/2); // Back vertices[12] = new Point3D(-w/2,-h/2,-d/2); vertices[13] = new Point3D(w/2,-h/2,-d/2); vertices[14] = new Point3D(w/2,h/2,-d/2); vertices[15] = new Point3D(-w/2,h/2,-d/2); // Top vertices[16] = new Point3D(-w/2,-h/2,d/2); vertices[17] = new Point3D(-w/2,-h/2,-d/2); vertices[18] = new Point3D(w/2,-h/2,-d/2); vertices[19] = new Point3D(w/2,-h/2,d/2); // Bottom vertices[20] = new Point3D(-w/2,h/2,d/2); vertices[21] = new Point3D(-w/2,h/2,-d/2); vertices[22] = new Point3D(w/2,h/2,-d/2); vertices[23] = new Point3D(w/2,h/2,d/2); } void create(){ for (int i=0; i<6; i++){ beginShape(QUADS); for (int j = 0; j < 4; j++){ vertex(vertices[j+4*i].x, vertices[j+4*i].y, vertices[j+4*i].z); } endShape(); } } }