//Untitled1 /** Fábio Carvalho 2014 (Os cubos estão sempre em rotação, é possivel modificar a orientação da rotação e a perspectiva dos cubos com o clique e o arraste do rato) */ float rotx = PI; float roty = PI; PShape cube; float cubeSize = 40; void setup() { size(1010, 620, P3D); // createCube (); fill(150); stroke(color(44, 48, 32)); noCursor(); } void draw() { //ortho(0, width, 0, height, 10, 20000); background(0); noStroke(); rotx += 0.004; //primeira linha pushMatrix(); translate(55, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); fill(random(255),0,random(255)); pushMatrix(); translate(145, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(235, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(325, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(415, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(505, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(595, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(685, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(775, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(865, 60); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(955, 60); rotateX(rotx); rotateY(roty); // box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); //segunda linha pushMatrix(); translate(55, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(145, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(235, 160); rotateX(rotx); rotateY(roty); // box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(325, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(415, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(505, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(595, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(685, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(775, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(865, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(955, 160); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); //terceira linha pushMatrix(); translate(55, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(145, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(235, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(325, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(415, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(505, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(595, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(685, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(775, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(865, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(955, 260); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); //quarta linha pushMatrix(); translate(55, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(145, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(235, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(325, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(415, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(505, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(595, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(685, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(775, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(865, 360); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(955, 360); rotateX(rotx); rotateY(roty); // box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); //quinta linha pushMatrix(); translate(55, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(145, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(235, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(325, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(415, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(505, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(595, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(685, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(775, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(865, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(955, 460); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); //sexta linha pushMatrix(); translate(55, 560); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(145, 560); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(235, 560); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(325, 560); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(415, 560); rotateX(rotx); rotateY(roty); //box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(505, 560); rotateX(rotx); rotateY(roty); // box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(595, 560); rotateX(rotx); rotateY(roty); // box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(685, 560); rotateX(rotx); rotateY(roty); // box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(775, 560); rotateX(rotx); rotateY(roty); // box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(865, 560); rotateX(rotx); rotateY(roty); // box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); pushMatrix(); translate(955, 560); rotateX(rotx); rotateY(roty); // box(cubeSize); face1(); face2(); face3(); face4(); face5(); face6(); popMatrix(); //cursor pushMatrix(); translate(mouseX, mouseY, 100); rotateX(rotx); rotateY(roty); // box(cubeSize); face11(); face21(); face31(); face41(); face51(); face61(); popMatrix(); } void face1(){ fill(random(255),0,0); beginShape(); vertex(-cubeSize, -cubeSize, +cubeSize); vertex(+cubeSize, -cubeSize, +cubeSize); vertex(+cubeSize, +cubeSize, +cubeSize); vertex(-cubeSize, +cubeSize, +cubeSize); endShape(CLOSE); } void face2(){ fill(random(12), random(42), random(203)); beginShape(); vertex(+cubeSize, -cubeSize, -cubeSize); vertex(-cubeSize, -cubeSize, -cubeSize); vertex(-cubeSize, +cubeSize, -cubeSize); vertex(+cubeSize, +cubeSize, -cubeSize); endShape(CLOSE); } void face3(){ fill(random(240), random(29), random(10)); beginShape(); vertex(+cubeSize, -cubeSize, +cubeSize); vertex(+cubeSize, -cubeSize, -cubeSize); vertex(+cubeSize, +cubeSize, -cubeSize); vertex(+cubeSize, +cubeSize, +cubeSize); endShape(CLOSE); } void face4(){ fill(random(231), random(240), random(10)); beginShape(); vertex(-cubeSize, -cubeSize, -cubeSize); vertex(-cubeSize, -cubeSize, +cubeSize); vertex(-cubeSize, +cubeSize, +cubeSize); vertex(-cubeSize, +cubeSize, -cubeSize); endShape(CLOSE); } void face5(){ fill(random(136), random(227), random(18)); beginShape(); vertex(-cubeSize, +cubeSize, +cubeSize); vertex(+cubeSize, +cubeSize, +cubeSize); vertex(+cubeSize, +cubeSize, -cubeSize); vertex(-cubeSize, +cubeSize, -cubeSize); endShape(CLOSE); } void face6(){ fill(random(224), random(16), random(58)); beginShape(); vertex(+cubeSize, -cubeSize, +cubeSize); vertex(-cubeSize, -cubeSize, +cubeSize); vertex(-cubeSize, -cubeSize, -cubeSize); vertex(+cubeSize, -cubeSize, -cubeSize); endShape(CLOSE); } void face11(){ fill(random(255),0,0); beginShape(); vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2); vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2); vertex(+cubeSize/2, +cubeSize/2, +cubeSize/2); vertex(-cubeSize/2, +cubeSize/2, +cubeSize/2); endShape(CLOSE); } void face21(){ fill(random(12), random(42), random(203)); beginShape(); vertex(+cubeSize/2, -cubeSize/2, -cubeSize/2); vertex(-cubeSize/2, -cubeSize/2, -cubeSize/2); vertex(-cubeSize/2, +cubeSize/2, -cubeSize/2); vertex(+cubeSize/2, +cubeSize/2, -cubeSize/2); endShape(CLOSE); } void face31(){ fill(random(240), random(29), random(10)); beginShape(); vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2); vertex(+cubeSize/2, -cubeSize/2, -cubeSize/2); vertex(+cubeSize/2, +cubeSize/2, -cubeSize/2); vertex(+cubeSize/2, +cubeSize/2, +cubeSize/2); endShape(CLOSE); } void face41(){ fill(random(231), random(240), random(10)); beginShape(); vertex(-cubeSize/2, -cubeSize/2, -cubeSize/2); vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2); vertex(-cubeSize/2, +cubeSize/2, +cubeSize/2); vertex(-cubeSize/2, +cubeSize/2, -cubeSize/2); endShape(CLOSE); } void face51(){ fill(random(136), random(227), random(18)); beginShape(); vertex(-cubeSize/2, +cubeSize/2, +cubeSize/2); vertex(+cubeSize/2, +cubeSize/2, +cubeSize/2); vertex(+cubeSize/2, +cubeSize/2, -cubeSize/2); vertex(-cubeSize/2, +cubeSize/2, -cubeSize/2); endShape(CLOSE); } void face61(){ fill(random(224), random(16), random(58)); beginShape(); vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2); vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2); vertex(-cubeSize/2, -cubeSize/2, -cubeSize/2); vertex(+cubeSize/2, -cubeSize/2, -cubeSize/2); endShape(CLOSE); } void keyPressed() { if (key =='c') { fill(0, 255); rect(0, 0, width, height); } } void mouseDragged() { float rate = 0.01; rotx += (pmouseY-mouseY) * rate; roty += map(mouseX, mouseX, width, height, 25) * rate; }