import traer.physics.*; class Node { // PROPERTIES String name; float x, y, z, mass, sqft, sqftMin, crossover; float stories = 1.0; float side, transparency; PVector pv; PVector[] bBox; float physIdealI, physIdealO, physIdealP; float physRatioI, physRatioO, physRatioP; int type; // 1 = I, 2 = O, 3 = P, 4 = site, 5 = rail, 6 = kink int level; // for site nodes int reach, strOrigL, numSplit, total; int noiseAllow, trafficRate; color clr, clrPhys; Node[] connections; int numConnI, numConnO, numConnP, numConnTotal; boolean textOn = false; boolean titleOn = true; boolean blnExplodable = true; boolean activeHull = false; // particle system stuff ParticleSystem physics; Particle p; Spring[] springs; Attraction[] attractions; // CONSTRUCTOR Node(String _name, float _mass, float _x, float _y, float _z, ParticleSystem _physics, Node[] _others, color _clr, float _crossover, int _type){ name = _name; mass = _mass; x = _x; y = _y; z = _z; pv = new PVector(x,y,z); clr = _clr; reach = 0; crossover = _crossover; type = _type; numSplit = 0; total = 1; bBox = new PVector[8]; 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, attrStr, attrLength); Attraction b = physics.makeAttraction( _others[i].p, p, attrStr, attrLength); attractions = (Attraction[]) append(attractions, a); _others[i].attractions = (Attraction[]) append(_others[i].attractions, b); } } } // METHODS void fix(){ p.makeFixed(); } void connect(Node a, float _strength, float _restLength, boolean _on){ connections = (Node[]) append(connections, a); Spring theSpring = physics.makeSpring(this.p, a.p, _strength, _strength, _restLength); springs = (Spring[]) append(springs, theSpring); if(!_on){ theSpring.turnOff(); } } Node[] getProgConnections(){ Node[] progConnections = new Node[0]; for(int i=0; i= 0 ) allPaths.remove(index); } rtrnPaths = theNode.recursiveReach( currentGeneration + 1, _root, this, newPath, allPaths ); } } } } } return allPaths; } void plot3D_Connections(float sc){ for(int i=0; i pvCentreToBrep.mag()){ PVector pvMove = PVector.sub(pvCentreToBrep, pvCentreToThis); pvMove.normalize(); pvMove.mult(4); this.p.position().add(pvMove.x, pvMove.y, 0); } } void avoidTrain(){ PVector pvCentre = new PVector(); for(int i=0; i 75 ){ //PUSH DOWN this.p.position().add(0, 0, -2); } if( this.p.position().z() > 0 ){ //SQUISH ALL this.p.position().add(0, 0, squashPVect); } if( this.p.position().z() < siteCentre.z ){ //PUSH ABOVE GROUND this.p.position().set(this.p.position().x(), this.p.position().y(), siteCentre.z); } // CONSTRAINTS if( (frameCount>60) && (this.p.isFree()) ){ //this.constrainToSite(); //this.avoidTrain(); this.avoid(); } if( this.name.equals("Lobby(I)") || this.name.equals("Lobby(O)") || this.name.equals("Lobby(P)") ){ this.p.position().set(this.p.position().x(), this.p.position().y(), siteCentre.z); } // UPDATE PVECT this.pv.x = p.position().x(); this.pv.y = p.position().y(); this.pv.z = p.position().z(); x = this.p.position().x(); y = this.p.position().y(); z = this.p.position().z(); // MAKE BBOX AND STRUCTURE this.updateBBox(); } // update physRatios for(int i=0; i