/* ---------------------------------------------- Computing Kaizen Studio Advanced Studio VI Spring 2010 Columbia University GSAPP Subdividing Bodies Code by Nikolas Stutzin 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 Node { //STATEMENTS float x,y,z,mass,sm,r,d; String name; Node[] connections; int tree; Node[] nodeTrace; boolean checked; String program; int type; float offsetZ; int connect; ParticleSystem physics; Particle p; Spring[] springs; Attraction[] attractions; //CONSTRUCTOR 1 Node(){ } //CONSTRUCTOR 2 Node(String _name, float _mass, float _x, float _y, float _z, ParticleSystem _physics, Node[] _others, float _sm, int _tree, float _offsetZ){ x = _x; y = _y; z = _z; r=0; program = null; type = 0; offsetZ = _offsetZ; connect = 0; mass = _mass; name = _name; connections = new Node[0]; nodeTrace = new Node[0]; checked = false; sm = _sm; tree = _tree; physics = _physics; connections = new Node[0]; springs = new Spring[0]; attractions = new Attraction[0]; p = physics.makeParticle(mass, x, y, z); //makeParticle(float mass, float x, float y, float z) for(int i=0; i<_others.length; i++){ if( p != _others[i].p){ Attraction a = physics.makeAttraction( p,_others[i].p, -200, 50 ); Attraction b = physics.makeAttraction( _others[i].p, p, -200, 50 ); //70 attractions = (Attraction[]) append(attractions, a); _others[i].attractions = (Attraction[]) append(_others[i].attractions, b); } } } //METHOD 2 void fix(){ p.makeFixed(); } //METHOD 3 void connect(Node a, float _strength, float _restLength, boolean _on){ connections = (Node[]) append(connections, a); Spring theSpring = physics.makeSpring(this.p, a.p, _strength, 1, _restLength ); springs = (Spring[]) append( springs, theSpring ); if(!_on){ theSpring.turnOff(); } } //METHOD 4 Node[] getConnections(){ return connections; } //METHOD 5 void branch(int number){ int passTree = tree; float passsm = (sm*0.8)/number; for(int i=0; i