import traer.physics.*; class Graph { // PROPERTIES Node[] nodes; ParticleSystem physics; String name; //CONSTRUCTOR Graph(ParticleSystem _physics){ physics = _physics; nodes = new Node[0]; } // METHODS Node addNode(String name, float mass, float _x, float _y, float _z, color _clr, float _crossover, int _type){ name = name.trim(); for(int i=0; i= maxDiffPhysRatio) && (fx_Dist(_node, checkNode) <= 1000000) && (checkNode.type <= 3) ){ otherNode = checkNode; maxDiffPhysRatio = diffRatio; } } } if( (otherNode == null) && (_node.getProgConnections().length > 0) ){ otherNode = _node.getProgConnections()[floor(random(_node.getProgConnections().length))]; } // if node has external connections if( (_node.sqft >= otherNode.sqft) && (_node.sqft >= _node.sqftMin*2) ){ // determine properties for new nodes float sqftSmall = max( (otherNode.sqft / fx_TotalSqft(connectionsProg) ) * _node.sqft, _node.sqftMin); float sqftBig = _node.sqft - sqftSmall; float newCrossover = (_node.crossover + otherNode.crossover)/2; color newClr = color((hue(_node.clr)+hue(otherNode.clr))/2, 100, 100, 50); // make baby nodes for(int i=0; i<2; i++){ String newName; if(_node.total == 1){ newName = _node.name + "_" + c; } else { newName = _node.name.substring(0,_node.strOrigL)+ "_" + c; } c++; if(i == 0){ float x = (_node.x + otherNode.x)/2; float y = (_node.y + otherNode.y)/2; float z = (_node.z + otherNode.z)/2; smallNode = this.addNode(newName, 1.0, x,y,z, _node.clr, newCrossover, _node.type); // define new properties smallNode.sqft = sqftSmall; smallNode.sqftMin = _node.sqftMin; smallNode.noiseAllow = (_node.noiseAllow + otherNode.noiseAllow) / 2; smallNode.trafficRate = (_node.trafficRate + otherNode.trafficRate) / 2; smallNode.transparency = _node.transparency; smallNode.numSplit = _node.numSplit + 1; smallNode.strOrigL = _node.strOrigL; nodes = (Node[]) append(nodes, smallNode); newNodes = (Node[]) append(newNodes, smallNode); } else { float x = (_node.x); float y = (_node.y); float z = (_node.z); bigNode = this.addNode(newName, 1.0, x,y,z, _node.clr, _node.crossover, _node.type); // define new properties bigNode.sqft = sqftBig; bigNode.sqftMin = _node.sqftMin; bigNode.noiseAllow = _node.noiseAllow; bigNode.trafficRate = _node.trafficRate; bigNode.transparency = _node.transparency; bigNode.numSplit = _node.numSplit + 1; bigNode.strOrigL = _node.strOrigL; if( _node.p.isFixed() ) bigNode.p.makeFixed(); nodes = (Node[]) append(nodes, bigNode); newNodes = (Node[]) append(newNodes, bigNode); } } if( (smallNode != null) && (bigNode != null) ){ // connect smallNode and bigNode this.connectNodes(smallNode, bigNode, _strength, _restLength); // connect smallNodes to originals for(int i=0; i<_node.getProgConnections().length; i++){ Node origNode = _node.getProgConnections()[i]; if(origNode.type == newNodes[i%2].type){ this.connectNodes(newNodes[i%2], origNode, _strength, _restLength); } } // connect new nodes to external connections this.connectNodes(smallNode, otherNode, _strength, _restLength); this.connectNodes(bigNode, otherNode, _strength, _restLength); boolean blnSiteConnect = false; for(int i=0; i 0){ nodes[i].plot3D_Connections(_scale); } } } void plot3D_Nodes(float _scale){ for(int i=0; i