/** * Constructs a color cube with unit scale. The corners of the * color cube are [-1,-1,-1] and [1,1,1]. */ public ColorCube() { QuadArray cube = new QuadArray(24, QuadArray.COORDINATES | QuadArray.COLOR_3); cube.setCoordinates(0, verts); cube.setColors(0, colors); this.setGeometry(cube); scale = 1.0; }
/** * Constructs a color cube with the specified scale. The corners of the * color cube are [-scale,-scale,-scale] and [scale,scale,scale]. * @param scale the scale of the cube */ public ColorCube(double scale) { QuadArray cube = new QuadArray(24, QuadArray.COORDINATES | QuadArray.COLOR_3); float scaledVerts[] = new float[verts.length]; for (int i = 0; i < verts.length; i++) scaledVerts[i] = verts[i] * (float)scale; cube.setCoordinates(0, scaledVerts); cube.setColors(0, colors); this.setGeometry(cube); this.scale = scale; }
public GeometryArray createGeometry() { QuadArray quadArray = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3); Point3f[] coords = new Point3f[4]; coords[0] = new Point3f(0, 0, 0); coords[1] = new Point3f(w, 0, 0); coords[2] = new Point3f(w, h, 0); coords[3] = new Point3f(0, h, 0); Color3f[] colors = new Color3f[4]; colors[0] = new Color3f(100, 100, 100); colors[1] = new Color3f(100, 100, 100); colors[2] = new Color3f(100, 100, 100); colors[3] = new Color3f(100, 100, 100); quadArray.setCoordinates(0, coords); quadArray.setColors(0, colors); return quadArray; }
public GeometryArray createGeometry() { QuadArray quadArray = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3); Point3f[] coords = new Point3f[4]; coords[0] = new Point3f(0, 0, 0); coords[1] = new Point3f(w, 0, 0); coords[2] = new Point3f(w, h, 0); coords[3] = new Point3f(0, h, 0); Color3f[] colors = new Color3f[4]; colors[0] = new Color3f(100, 100, 100); colors[1] = new Color3f(100, 100, 100); colors[2] = new Color3f(100, 100, 100); colors[3] = new Color3f(100, 100, 100); quadArray.setCoordinates(0, coords); quadArray.setColors(0, colors); return quadArray; }