//W:Mute 2004 - Abstract //www.wmute.org int siz=40; int hsiz=siz/2; int w=360; int h=360; int hw=w/2; int hh=h/2; float sscale = w/siz; int cores=10; int sitelimit = 500; int pointlimit = 100; int nump = pointlimit; int totalpoints=0; int[][][] sites = new int[siz][siz][siz]; Island[] islands = new Island[cores]; int trialCounter = 0; int trialLimit=1000; int t =0; int trails=10; float zoomfactor=5.0; Particle[] ps= new Particle[nump]; float aX=0.0f; float aY=0.0f; float daX=0.002f; float daY=0.002f; float fov = 60; // at least for now float eyeX = w / 2.0f; float eyeY = h / 2.0f; float eyeDist = eyeY / ((float) tan(PI * fov / 360f)); float nearDist = eyeDist / 10.0f; float farDist = eyeDist * 10.0f; float aspect = (float)w / (float)h; float spike=1.0; int output[]=new int[w*h]; BFont meta; color bc; color sc; color ac; color blc; color[][] cs = new color[6][4]; int cc = 0; boolean bBlur=true; boolean bInterlace=false; int SelFX=0; boolean bNoise=false; void setup() { size(w,h); colorMode(RGB); setColors(); bc=cs[cc][0]; sc=cs[cc][1]; ac=cs[cc][2]; blc=cs[cc][3]; background(bc); reset(); meta = loadFont("meta.vlw.gz"); textFont(meta, 28); } void setColors() { cs[0][0]=color(255,255,255); cs[0][1]=color(0,0,0); cs[0][2]=color(255,0,0); cs[0][3]=color(255,255,255); cs[1][0]=color(40,40,40); cs[1][1]=color(0,0,0); cs[1][2]=color(0,0,0); cs[1][3]=color(255,255,255); cs[2][0]=color(140,129,108); cs[2][1]=color(29,48,56); cs[2][2]=color(196,158,82); cs[2][3]=color(122,215,255); cs[3][0]=color(0,0,0); cs[3][1]=color(73,133,105); cs[3][2]=color(54,123,156); cs[3][3]=color(255,255,255); cs[4][0]=color(201,240,175); cs[4][1]=color(0,0,0); cs[4][2]=color(27,166,101); cs[4][3]=color(0,0,0); cs[5][0]=color(255,255,255); cs[5][1]=color(226,99,137); cs[5][2]=color(215,151,90); cs[5][3]=color(255,255,255); } void loop() { background(bc); beginCamera(); perspective(fov, aspect, nearDist, farDist); translate(0,0,-zoomfactor*w); rotateX(aX+=getRotX()); rotateY(aY+=getRotY()); endCamera(); if (trialCounter>trialLimit) { trialCounter=0; reset(); } if (t<1400) { step(); fill(sc); text(nf(t,6), 300, 380); } else { fill(ac); text(nf(t,6), 300, 380); implode(); } t++; drawCanvas(); if (totalpoints==0) { reset(); } } void keyPressed() { if( key == '+') { zoomfactor=max(1.0, zoomfactor-0.05); } if( key == '-') { zoomfactor=min(10.0, zoomfactor+0.05); } if(( key == 'r')||( key == 'R')) { reset(); } if(( key == 'b')||( key == 'B')) { bBlur=!bBlur; } if(( key == 's')||( key == 'S')) { SelFX=(SelFX+1)%3; } if(( key == 'i')||(key == 'I')) { bInterlace=!bInterlace; } if(( key == 'n')||(key == 'N')) { bNoise=!bNoise; } if((key =='d') || (key =='D')) { spike=(random(1.0)<0.75)?random(1.0,10.0):1.0/random(1.0,10.0); aX+=random(PI); aY+=random(2*PI); } if((key =='c') || (key =='C')) { cc=(cc+1)%6; bc=cs[cc][0]; sc=cs[cc][1]; ac=cs[cc][2]; blc=cs[cc][3]; } } void reset() { totalpoints=0; t=0; nump=pointlimit; for (int i=0; i-1) { mobile=false; trialCounter++; } while (mobile) { int movement = int(random(6)); if (movement==0) { x++; if (x==siz) {x=0;}; } if (movement==1) { x--; if (x==-1) {x=siz-1;}; } if (movement==2) { y++; if (y==siz) {y=0;}; } if (movement==3) { y--; if (y==-1) {y=siz-1;}; } if (movement==4) { z++; if (z==siz) {z=0;}; } if (movement==5) { z--; if (z==-1) {z=siz-1;}; } int ux = x+1; if (ux==siz) {ux=0;}; int uy = y+1; if (uy==siz) {uy=0;}; int uz = z+1; if (uz==siz) {uz=0;}; int lx = x -1; if (lx==-1){lx=siz-1;}; int ly = y-1; if (ly==-1) {ly=siz-1;}; int lz = z-1; if (lz==-1) {lz=siz-1;}; if ((sites[ux][y][z]>0)||(sites[lx][y][z]>0)||(sites[x][uy][z]>0)||(sites[x][ly][z]>0)||(sites[x][y][lz]>0)||(sites[x][y][uz]>0)) { mobile=false; int[] indices = {sites[ux][y][z],sites[lx][y][z],sites[x][uy][z],sites[x][ly][z],sites[x][y][lz],sites[x][y][uz]}; sort(indices); int ID=indices[5]; sites[x][y][z]=ID; islands[ID].add(x,y,z); totalpoints++; } } for (int i=0; isitelimit)?sitelimit:islands[i].numpoints; for(int j=0; j>8); } int blend(int a, int b, int f) { return mix(a>>16,b>>16,f)<<16 | mix(a>>8&0xff,b>>8&0xff,f)<<8 | mix(a&0xff,b&0xff,f); } class Island { int x, y, z; int ID; int numpoints; float survival; Point[] sites=new Point[sitelimit]; Island(int xx, int yy, int zz, int ii) { x = xx; y = yy; z = zz; ID = ii; numpoints=0; sites[0] = new Point(x,y,z); survival=0.25+random(0.5); } void draw(float s, float d){ stroke(sc); int maxindex=(numpoints>sitelimit)?sitelimit:numpoints; for(int index=0; indexsitelimit) { numpoints=sitelimit; } for(int index=0; index0)&&(random(1.0)>survival)) { numpoints--; totalpoints--; } } } class Point { float x, y,z; // Contructor (required) Point(float xx, float yy, float zz) { x = xx; y = yy; z = zz; } float size() { return dist(0,0,0,x,y,z); } void draw(float s, float d, boolean n){ float d3 = 3*d; float d5 = 5*d; float ss= s*spike; if (n){ vertex(ss*x-d,ss*y-d,ss*z-d); float r=sf(ss*y+d,d,d5)*(0.75+random(0.5)); vertex(r*(ss*x-d),ss*y+d,r*(ss*z-d)); r=sf(ss*y+d3,d,d5)*(0.75+random(0.5)); vertex(r*(ss*x-d),ss*y+d3,r*(ss*z-d)); r=sf(ss*y-d3,-d,-d5)*(0.75+random(0.5)); vertex(r*(ss*x-d),ss*y-d3,r*(ss*z-d)); r=sf(ss*y-d5,-d,-d5)*(0.75+random(0.5)); vertex(r*(ss*x-d),ss*y-d5,r*(ss*z-d)); r=sf(ss*x+d,d,d5)*(0.75+random(0.5)); vertex(ss*x+d,r*(ss*y-d),r*(ss*z-d)); r=sf(ss*x+d3,d,d5)*(0.75+random(0.5)); vertex(ss*x+d3,r*(ss*y-d),r*(ss*z-d)); r=sf(ss*x-d3,-d,-d5)*(0.75+random(0.5)); vertex(ss*x-d3,r*(ss*y-d),r*(ss*z-d)); r=sf(ss*x-d5,-d,-d5)*(0.75+random(0.5)); vertex(ss*x-d5,r*(ss*y-d),r*(ss*z-d)); r=sf(ss*z+d,d,d5)*(0.75+random(0.5)); vertex(r*(ss*x-d),r*(ss*y-d),ss*z+d); r=sf(ss*z+d3,d,d5)*(0.75+random(0.5)); vertex(r*(ss*x-d),r*(ss*y-d),ss*z+d3); r=sf(ss*z-d3,-d,-d5)*(0.75+random(0.5)); vertex(r*(ss*x-d),r*(ss*y-d),ss*z-d3); r=sf(ss*z-d5,-d,-d5)*(0.75+random(0.5)); vertex(r*(ss*x-d),r*(ss*y-d),ss*z-d5); } else { vertex(ss*x-d,ss*y-d,ss*z-d); float r=sf(ss*y+d,d,d5); vertex(r*(ss*x-d),ss*y+d,r*(ss*z-d)); r=sf(ss*y+d3,d,d5); vertex(r*(ss*x-d),ss*y+d3,r*(ss*z-d)); r=sf(ss*y-d3,-d,-d5); vertex(r*(ss*x-d),ss*y-d3,r*(ss*z-d)); r=sf(ss*y-d5,-d,-d5); vertex(r*(ss*x-d),ss*y-d5,r*(ss*z-d)); r=sf(ss*x+d,d,d5); vertex(ss*x+d,r*(ss*y-d),r*(ss*z-d)); r=sf(ss*x+d3,d,d5); vertex(ss*x+d3,r*(ss*y-d),r*(ss*z-d)); r=sf(ss*x-d3,-d,-d5); vertex(ss*x-d3,r*(ss*y-d),r*(ss*z-d)); r=sf(ss*x-d5,-d,-d5); vertex(ss*x-d5,r*(ss*y-d),r*(ss*z-d)); r=sf(ss*z+d,d,d5); vertex(r*(ss*x-d),r*(ss*y-d),ss*z+d); r=sf(ss*z+d3,d,d5); vertex(r*(ss*x-d),r*(ss*y-d),ss*z+d3); r=sf(ss*z-d3,-d,-d5); vertex(r*(ss*x-d),r*(ss*y-d),ss*z-d3); r=sf(ss*z-d5,-d,-d5); vertex(r*(ss*x-d),r*(ss*y-d),ss*z-d5); } } float sf(float x,float ll, float ul) { return 1.0-sqrt((x-ll)/(ul-ll)); } } class Particle { float x,y,z,vx,vy,vz, ax, ay, az; float[] tx=new float[trails]; float[] ty=new float[trails]; float[] tz=new float[trails]; Particle(float xx, float yy, float zz, float vxx, float vyy, float vzz) { x=xx; y=yy; z=zz; vx=vxx; vy=vyy; vz=vzz; for(int i=0; isiz){ x=2*siz-x; } if(y<0){ y=-y; } if(y>siz){ y=2*siz-y; } if(z<0){ z=-z; } if(z>siz){ z=2*siz-z; } tx[index]=x; ty[index]=y; tz[index]=z; } void draw(float s, float d){ beginShape(LINES); float cx, cy, cz, px, py, pz; int index=t%trails; float ss=spike*s; cx=ss*tx[index]-d; cy=ss*ty[index]-d; cz=ss*tz[index]-d; for(int i=1; i