Incresed box size in CubicGrid examples

This commit is contained in:
codeanticode
2012-05-07 22:21:01 +00:00
parent 8143cf37e4
commit 8b507280d0
2 changed files with 7 additions and 57 deletions
@@ -6,7 +6,7 @@
* and popMatrix() functions.
*/
float boxSize = 40;
float boxSize = 50;
float margin = boxSize*2;
float depth = 400;
color boxFill;
@@ -19,6 +19,7 @@ void setup() {
size(640, 360, P3D);
orientation(LANDSCAPE);
frameRate(60);
noSmooth();
noStroke();
}
@@ -1,4 +1,4 @@
float boxSize = 40;
float boxSize = 50;
float margin = boxSize*2;
float depth = 400;
color boxFill;
@@ -13,6 +13,7 @@ void setup() {
size(640, 360, P3D);
orientation(LANDSCAPE);
frameRate(60);
noSmooth();
noStroke();
grid = createShape(PShape.GROUP);
@@ -23,62 +24,10 @@ void setup() {
for (float k =- width+margin; k <= width-margin; k += boxSize){
// Base fill color on counter values, abs function
// ensures values stay within legal range
boxFill = color(abs(i), abs(j), abs(k), 50);
PShape cube = createShape(QUADS);
cube.noStroke();
boxFill = color(abs(i), abs(j), abs(k), 50);
PShape cube = createShape(BOX, boxSize, boxSize, boxSize);
cube.fill(boxFill);
float w = boxSize;
float h = boxSize;
float d = boxSize;
float shiftX = k;
float shiftY = j;
float shiftZ = i;
// Front face
cube.normal(0, 0, 1);
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
// Back face
cube.normal(0, 0, -1);
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
// Left face
cube.normal(1, 0, 0);
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
// Right face
cube.normal(-1, 0, 0);
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
// Top face
cube.normal(0, 1, 0);
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
// Bottom face
cube.normal(0, -1, 0);
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
cube.end();
cube.translate(k, j, i);
grid.addChild(cube);
}
}