// lowpoly-flowers v.006 elout de kok 2003 // http://www.xs4all.nl/~elout/ // p 65 float zpos=0.0f; int midx,midy; //int stepper=0; //int step2=0; //------mouse & stuff int mx,my,sx=140,sy=120, middenx,middeny; float zangle; //particle bob[] = new particle[20]; flower bobf = new flower(); void setup() { size(600, 400); midx=width/2; midy=height/2; noStroke(); cursor(CROSS); } void loop() { //clear screen background(100,100,100); // set the position to the middle of your screen translate(midx, midy, zpos); //check mouse for rotation mx=mouseX; my=mouseY; if ( mx > middenx){sx=0-((midx-mx)/2);} else{sx=((mx-midx)/2);} if ( my > middeny){sy=0-((midy-my)/2);} else{sy=((my-midy)/2);} zangle= zangle+(sx/4000.0f); rotateX(0.6+(sy/40.0)); rotateY(0.6+(sx/40.0)); rotateZ(zangle); //if (mousepressed) if(keyPressed) { if (key == LEFT){ bobf = new flower(); } if (key == RIGHT){ bobf = new flower(); } if (key == UP){ zpos=zpos+20.0f;} if (key == DOWN){ zpos=zpos-20.0f;} } if (mousePressed==true) { bobf = new flower(); } //draw the flower bobf.calc(); //just add a little delay so the system can handle other tasks as well delay(15); } class flower { //howmany flower leafs int flowerrad=((int)random(12)+2)*2; float [] flower_points = new float[(flowerrad*6*3)+6]; int [] flower_colors = new int[(flowerrad*6*3)+6]; int [] flower_faces = new int[(flowerrad*8*3)+3]; int maxd=flowerrad*8; float [] cosd = new float[maxd]; float [] sind = new float[maxd]; //init flower() { // precalculate a circle for(int i=0; i