Created
May 7, 2010 04:47
-
-
Save taboularasa/393067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float cubeSize = 80; | |
color boxFill; | |
float rotYTarget = 0; | |
float rotXTarget = 0; | |
float rotationY = 0; | |
float rotationX = 0; | |
void setup() | |
{ | |
size(640,640, P3D); | |
//smooth(); | |
//ortho(-width/2, width/2, -height/2, height/2, -10, 10); | |
} | |
void draw() | |
{ | |
background(255); | |
translate(width/2,height/2,0); | |
rotationY = lerp(rotationY, rotYTarget, 0.09); | |
rotationX = lerp(rotationX, rotXTarget, 0.09); | |
rotateY(rotationY); | |
rotateX(rotationX); | |
float i,j,k; | |
for(i = -cubeSize; i <= (cubeSize*2)-cubeSize; i += cubeSize) | |
{ | |
pushMatrix(); | |
for(j = -cubeSize; j <= (cubeSize*2)-cubeSize; j+= cubeSize) | |
{ | |
pushMatrix(); | |
for (k = -cubeSize; k <= (cubeSize*2)-cubeSize; k += cubeSize) | |
{ | |
boxFill = color(0,0,0,30); | |
pushMatrix(); | |
translate(k,j,i); | |
fill(boxFill); | |
box(cubeSize, cubeSize, cubeSize); | |
popMatrix(); | |
} | |
popMatrix(); | |
} | |
popMatrix(); | |
} | |
} | |
void mousePressed() | |
{ | |
rotYTarget += PI/2; | |
} | |
void keyPressed() | |
{ | |
switch(keyCode) | |
{ | |
case 37: | |
println("left"); | |
rotYTarget -= PI/2; | |
break; | |
case 38: | |
println("up"); | |
rotXTarget += PI/2; | |
break; | |
case 39: | |
println("right"); | |
rotYTarget += PI/2; | |
break; | |
case 40: | |
println("down"); | |
rotXTarget -= PI/2; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment