/* ---------------------------------------------- Computing Kaizen Studio Advanced Studio VI Spring 2010 Columbia University GSAPP Digesting Bodies Code by Shunsuke Nanako http://www.arch.columbia.edu/ http://proxyarch.com/kaizen This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License -----------------------------------------------*/ class Agent{ PVector location; PVector direction; float x,y,z; float radius; float speed; int increaseFactor; int num; int numSprings; PVector goal; boolean isFixed; float tension; float nx, ny, nz; Agent(float _x, float _y, float _z){ x = _x; y = _y; z = _z; nx = random(-300,300); ny = random(-300,300); nz = 0; tension = random(-attAgentRate,repelAgentRate); if(tension < 0){ tension = -1; } else{ tension = 1; } location = new PVector(x, y, z); radius = 10; speed = .05; goal = null; num = mySystem.numberOfParticles(); numSprings = mySystem.numberOfSprings(); isFixed = true; } void update(){ separation(); moveTo(); plot(); } void plot(){ noStroke(); sphereDetail(10); if(tension<0){ fill(255,120,250,80); ellipse(location.x, location.y,radius,radius); fill(255,120,250,40); ellipse(location.x, location.y,attractionArea,attractionArea); } else{ fill(175,250,250,80); ellipse(location.x, location.y,radius,radius); fill(255,120,250,40); ellipse(location.x, location.y,attractionArea,attractionArea); } } void moveTo(){ //initial float x = 900 * noise( nx + frameCount*.01); float y = 900 * noise( ny + frameCount*.01); location.set(x,y,z); for(int i=0; i maxRestLength){ newRestLength = maxRestLength; } if(newRestLength < minRestLength){ newRestLength = minRestLength; } theSpring.setRestLength( newRestLength+.01 ); } } } void separation(){ for (int i=0; i