/* ---------------------------------------------- Computing Kaizen Studio Advanced Studio VI Spring 2010 Columbia University GSAPP Negotiating Bodies Code by Edwin Liu 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 Block{ //PROPERTIES float w; float l; float h; color clr; PVector center; int lateral; int maxSize = 30; boolean fixed; int state; int directionOfGrow; PVector [] corners; float[] sqMArray; PVector [] cornerPts; int function; String cellName; int xStatus; int yStatus; int zStatus; boolean[] growAxis; float speed; // CONSTRUCTOR Block(PVector _center, float _w, float _l, float _h, color _clr){ speed = .5; center = _center; growAxis = new boolean[3]; growAxis[0] = growAxis[1] = growAxis[2] = false; growAxis[ floor(random(3))] = true; w = _w; l = _l; h = _h; clr = _clr; lateral = floor(random(0,2)); fixed = false; state = 2; xStatus = 0; yStatus = 0; zStatus = 0; function = floor(random(0,3)); corners = new PVector [8]; cornerPts = new PVector[0]; sqMArray = new float [0]; for(int i=0; i 200){ if(this.state == 3){ for (int j = 0; j maxGravityOffset){ this.center.z = this.center.z = maxGravityOffset; } } //METHOD 4 void seperate(){ if(state > 0){ for (int i = 0; i < blockArrays.length; i++){ if (this != blockArrays[i]){ Block theOther = blockArrays[i]; if(abs(theOther.center.x - this.center.x) < (this.w + theOther.w)){ if(abs(theOther.center.y - this.center.y) < (this.l + theOther.l)){ if(abs(theOther.center.z - this.center.z) < (this.h + theOther.h)){ PVector dir = PVector.sub(this.center, blockArrays[i].center); dir.normalize(); dir.mult(1); this.center.add(dir); } } } } } } for (int i = 0; i < siteBlockArrays.length; i++){ if (this != siteBlockArrays[i]){ Block theOther = siteBlockArrays[i]; if(abs(theOther.center.x - this.center.x) < (this.w + theOther.w)){ if(abs(theOther.center.y - this.center.y) < (this.l + theOther.l)){ if(abs(theOther.center.z - this.center.z) < (this.h + theOther.h)){ PVector dir = PVector.sub(this.center, siteBlockArrays[i].center); dir.normalize(); dir.mult(1); this.center.add(dir); } } } } } } //METHOD 5 void grow(){ if(state > 0){ float xResidualFinal = 10000; float yResidualFinal = 10000; float zResidualFinal = 10000; int counterX=0; int counterY=0; int counterZ=0; for( int i=0; i 1 && growAxis[0] == true){ w+=1; xStatus = 1; if (w > maxSize){ w = maxSize; xStatus = 0; } } if(yResidualFinal > 1&& growAxis[1] == true){ l+=1; yStatus = 1; if (l > maxSize){ l = maxSize; yStatus = 0; } } if(zResidualFinal > 1&& growAxis[2] == true){ h+=1; zStatus = 1; if (h > maxSize){ h = maxSize; zStatus = 0; } } } } //METHOD 6 void display(){ if (state != 2){ if (state == 1){ fill(clr); noStroke(); pushMatrix(); translate(center.x, center.y, center.z); box(w*2, l*2, h*2); popMatrix(); } if (state == 0){ fill(100); pushMatrix(); translate(center.x, center.y, center.z); noStroke(); box(w*2, l*2, h*2); popMatrix(); } if(blockAttractDisplay){ if (state == 3){ fill(clr, 25); strokeWeight(1); pushMatrix(); translate(center.x, center.y, center.z); if (function == 0){ stroke(0,255,0); } if (function == 1){ stroke(0,255,255); } if (function == 2){ stroke(255,0,255); } box(w*2, l*2, h*2); popMatrix(); } } } } //METHOD 7 void ptDisplay(){ this.cornerFinder(); if((this.state == 1) && (this.function == 0)){ strokeWeight(6); stroke(255); point(corners[0].x, corners[0].y, corners[0].z); point(corners[1].x, corners[1].y, corners[1].z); point(corners[2].x, corners[2].y, corners[2].z); point(corners[3].x, corners[3].y, corners[3].z); point(corners[4].x, corners[4].y, corners[4].z); point(corners[5].x, corners[5].y, corners[5].z); point(corners[6].x, corners[6].y, corners[6].z); point(corners[7].x, corners[7].y, corners[7].z); } } //METHOD 8 void graph(){ if (state == 2){ this.cornerFinder(); stroke(255,255,0); strokeWeight(1); int graphRadius=55; if (fixed){ graphRadius = 155; } int count=0; for( int i=0; i