import controlP5.*; import com.processinghacks.arcball.*; import processing.opengl.*; //Objects to open the window with the sliders ControlP5 controlP5; ControlWindow controlWindow; // declare parameters to control the sketch float translateX = 300; float rotateZ = 1; float scale = 0.92; int numberOfBoxes = 30; void setup(){ size(400,400,P3D); //initialize controlP5 and window controlP5 = new ControlP5(this); controlP5.hide(); controlWindow = controlP5.addControlWindow("My Sketch Parameters",210,110); //create slider to control translation Controller mySlider = controlP5.addSlider("translateX",300,600,translateX,20,20,100,10); mySlider.setWindow(controlWindow); // create slider to control rotation Controller mySlider2 = controlP5.addSlider("rotateZ",0,PI,rotateZ,20,40,100,10); mySlider2.setWindow(controlWindow); // create slider to change number of boxes Controller mySlider3 = controlP5.addSlider("numberOfBoxes",0,60,numberOfBoxes,20,60,100,10); mySlider3.setWindow(controlWindow); //create slider to modify scale Controller mySlider4 = controlP5.addSlider("scale",0.7,1.3,scale,20,80,100,10); mySlider4.setWindow(controlWindow); new ArcBall(this); noStroke(); } float radius = 100; float resolution = 20; float depth = -100; void draw(){ lights(); background(200); translate(width/2, height/2, -height/2); translate(-100,200,-200); rotate(PI/-2); for(int a = 0; a < numberOfBoxes;a++){ fill(255); // Hier ist Die KONTUR beginShape(TRIANGLE_STRIP); fill(255); vertex(200,0); vertex(200,0,depth); vertex(200,60); vertex(200,60,depth); vertex(250,60); vertex(250,60,depth); vertex(250,0); vertex(250,0,depth); endShape(); beginShape(TRIANGLE_STRIP); vertex(-100,0); vertex(-100,0,depth); vertex(-100,-80); vertex(-100,-80,depth); vertex(-50,-80); vertex(-50,-80,depth); vertex(-50,0); vertex(-50,0,depth); endShape(); beginShape(TRIANGLE_STRIP); for(int i = 0; i <= resolution;i++){ float angle = i/resolution * PI; float x = radius * cos(angle); float y = radius * sin(angle); vertex(x,y); vertex(x,y,depth); //println(i+" : "+angle+" : "+" : "+x+" : "+y); } endShape(); beginShape(TRIANGLE_STRIP); for(int i = 0; i <= resolution;i++){ float angle = i/resolution * PI; float x = radius * cos(angle)/2; float y = radius * sin(angle)/2; vertex(x,y); vertex(x,y,depth); //println(i+" : "+angle+" : "+" : "+x+" : "+y); } endShape(); beginShape(TRIANGLE_STRIP); for(int i = 0; i <= resolution;i++){ float angle = -i/resolution * PI; float x = 150+ radius * cos(angle); float y = radius * sin(angle); vertex(x,y); vertex(x,y,depth); //println(i+" : "+angle+" : "+" : "+x+" : "+y); } endShape(); beginShape(TRIANGLE_STRIP); for(int i = 0; i <= resolution;i++){ float angle = -i/resolution * PI; float x = 150 + radius * cos(angle)/2; float y = radius * sin(angle)/2; vertex(x,y); vertex(x,y,depth); //println(i+" : "+angle+" : "+" : "+x+" : "+y); } endShape(); // Hier ist Die FLÄCHE beginShape(TRIANGLE_STRIP); for(int i = 0; i <= resolution;i++){ float angle = i/resolution * PI; float x = radius * cos(angle); float y = radius * sin(angle); float x2 = radius * cos(angle)/2; float y2 = radius * sin(angle)/2; vertex(x,y); vertex(x2,y2); } endShape(); beginShape(TRIANGLE_STRIP); for(int i = 0; i <= resolution;i++){ float angle = -i/resolution * PI; float x = 150 + radius * cos(angle); float y = radius * sin(angle); float x2 = 150 + radius * cos(angle)/2; float y2 = radius * sin(angle)/2; vertex(x,y); vertex(x2,y2); } endShape(); beginShape(TRIANGLE_STRIP); vertex(200,0); vertex(200,60); vertex(250,60); vertex(200,0); vertex(250,0); endShape(); beginShape(TRIANGLE_STRIP); vertex(-100,0); vertex(-100,-80); vertex(-50,0); vertex(-50,-80); vertex(-50,0); endShape(); // Hier ist Die FLÄCHE IN DER TIEFE beginShape(TRIANGLE_STRIP); for(int i = 0; i <= resolution;i++){ float angle = i/resolution * PI; float x = radius * cos(angle); float y = radius * sin(angle); float x2 = radius * cos(angle)/2; float y2 = radius * sin(angle)/2; vertex(x,y,depth); vertex(x2,y2,depth); } endShape(); beginShape(TRIANGLE_STRIP); for(int i = 0; i <= resolution;i++){ float angle = -i/resolution * PI; float x = 150 + radius * cos(angle); float y = radius * sin(angle); float x2 = 150 + radius * cos(angle)/2; float y2 = radius * sin(angle)/2; vertex(x,y,depth); vertex(x2,y2,depth); } endShape(); beginShape(TRIANGLE_STRIP); vertex(200,0,depth); vertex(200,60,depth); vertex(250,60,depth); vertex(200,0,depth); vertex(250,0,depth); endShape(); beginShape(TRIANGLE_STRIP); vertex(-100,0,depth); vertex(-100,-80,depth); vertex(-50,0,depth); vertex(-50,-80,depth); vertex(-50,0,depth); endShape(); translate(translateX,sin(a * 0.1)*translateX,-20); rotateZ(sin(a * 0.2)*rotateZ); scale(scale+random(10)/1000); } }