import controlP5.*; import com.processinghacks.arcball.*; import processing.opengl.*; ControlP5 controlP5; ControlWindow controlWindow; int sliderY = 40; /** * simplifies adding sliders **/ void addSlider(String parameter, float start, float end, float init){ Controller mySlider = controlP5.addSlider(parameter,start,end,init,10,sliderY,100,10); mySlider.setWindow(controlWindow); sliderY += 30; } void setup(){ size(400,400,P3D); /* initialize control */ controlP5 = new ControlP5(this); controlP5.hide(); controlWindow = controlP5.addControlWindow("My Sketch Parameters",200,200); /* add sliders */ addSlider("slider1",0,100,20); addSlider("slider2",0,PI,0); addSlider("slider3",0,30,0); addSlider("slider4",0.7,1.3,1); /* init arcball */ 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); rotate(PI/2); translate(-60,0,0); 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(); }