int[] imgbuf; int maxpix; int nr_twigs; int maxLevel, maxId; float bBend, shrink1, shrink2; TwigType[] tree; boolean newTree; float rotY; void setup() { size(600,450,P3D); background(244,240,255); //stroke(30,205,0,32);//smooth(); maxpix=width*height; imgbuf=new int[maxpix]; maxLevel=7; maxId=5; bBend=55*PI/180; shrink1=0.7; shrink2=0.88; tree=new TwigType[100000]; // rotY=0; newTree=true; } void mousePressed() { newTree=true; } void draw() { if (newTree) { nr_twigs=0;twig(0,0,0,70,0,random(0.5,2),10*PI/180.0,random(TWO_PI),true); newTree=false; } background(244,240,255); lights(); translate(300,380); rotateY(rotY); rotY+=0.002; nr_twigs=0; twig(0,0,0,0,0,0,0,0,false); } void twig(int id, float dir1, float dir2, float len, int lev, float frq, float amp, float pha, boolean create) { int children=0; if (create) { children=(int)random(2,maxId); tree[nr_twigs]=new TwigType(dir1,dir2,len,children,frq,amp,pha); } else { children=tree[nr_twigs].children; dir1=tree[nr_twigs].dir1; dir2=tree[nr_twigs].dir2; len=tree[nr_twigs].len; frq=tree[nr_twigs].frq; amp=tree[nr_twigs].amp; pha=tree[nr_twigs].pha; } nr_twigs++; pushMatrix(); float zrot=dir1+amp*sin(frq*millis()/1000.0+pha); rotateZ(zrot); rotateY(dir2); float p=lev/(float)maxLevel; stroke(50-p*20,20+p*185,0,255);//stroke(30,205,0); line(0,0,0,0,-len,0); translate(0,-len,0); if (lev