//Kohonen Self-Organising-Map gone mad //adapted from // //import processing.opengl.*; SOM net; int state = 1; int animState = 0; int netSize = 10; int frames = 8; //PImage buffer; PFont font; int exportState = 0; boolean rotation; Vec3 [][] animTemp = new Vec3[2][]; int w,h,k; void setup(){ size(500,500,P3D);//OPENGL); //buffer = loadImage("rust.jpg"); ellipseMode(CENTER); w = width/2; h = height/2; k = 0; } void draw(){ if(!mousePressed) background(0); if(state == 2){ ambientLight(100,100,100); directionalLight(150,150,150,0,0,-1); directionalLight(150,150,150,0,0,1); } pushMatrix(); translate(w,h); if(rotation){ rotateY((TWO_PI / width) * mouseX); rotateX((TWO_PI / height) * mouseY); } translate(0,0,0); //make.draw(); switch(state){ case 0: break; case 1: net = new SOM(netSize); animTemp[1] = copyVec3(net.netImage()); state++; break; case 2: switch(animState){ case 0: animTemp[0] = copyVec3(animTemp[1]); net.run(); animTemp[1] = copyVec3(net.netImage()); drawNetImage(k++); animState = 1; if(net.stable){ state++; } break; case 1: drawNetImage(k++); if(k == frames){ k = 1; animState = 2; } break; case 2: net.draw(); animState = 0; break; } break; case 3: net.draw(); break; } popMatrix(); } void keyPressed(){ rotation = !rotation; }