Page 228

void lockpt() { int loCount=0; for(int i=0;i<lockNum.size();i++) { Integer j=(Integer)lockNum.get(i); VerletParticle tpt=(VerletParticle)stpt.get(j); tpt.x=tpt.x-0*loCount; tpt.y=tpt.y-30*loCount; tpt.z=tpt.z; tpt.lock(); loCount++; } }

class StrFromPts { ArrayList Conpts=new ArrayList(); VerletSpring spring; StrFromPts(ArrayList conArrpts) { Conpts=conArrpts; } void addStrFromPts() { for(int i=1;i< Conpts.size();i++) { VerletParticle p1=(VerletParticle)Conpts.get(i-1); VerletParticle p2=(VerletParticle)Conpts.get(i);

}

}

}

spring=new VerletSpring(p1,p2,1.5,1); physics.addSpring(spring);

void StrFromPtsdisplay() { for(int i=1;i< Conpts.size();i++) { VerletParticle p1=(VerletParticle)Conpts.get(i-1); VerletParticle p2=(VerletParticle)Conpts.get(i); stroke(155,155,155); strokeWeight(1); line(p1.x,p1.y,p1.z,p2.x,p2.y,p2.z); } }

class Str { VerletParticle OriPt,endPt; ArrayList stpt=new ArrayList(); ArrayList stspr=new ArrayList(); ArrayList lockNum=new ArrayList(); float restLength; int stepNum; float stepDist; float strength;

//lock the last point void lockept() { VerletParticle ept=(VerletParticle)stpt.get(stpt.size()-1); ept.x=endPt.x; ept.y=endPt.y; ept.z=endPt.z; ept.lock(); } void addspr() { for(int i=1;i<stpt.size();i++) { VerletParticle tspt1=(VerletParticle)stpt.get(i-1); VerletParticle tspt2=(VerletParticle)stpt.get(i); VerletSpring spring=new VerletSpring(tspt1,tspt2,restLe ngth,strength); physics.addSpring(spring); stspr.add(spring); } } void display() { float colorStep=255/stepNum; stroke(255); strokeWeight(1); fill(255); beginShape(); noFill(); curveVertex(OriPt.x,OriPt.y,OriPt.z); for(int i=0;i<stpt.size();i++) { VerletParticle ctpt=(VerletParticle)stpt.get(i); colorMode(HSB,255,255,255); stroke(200-colorStep*i*0.5,255,255); curveVertex(ctpt.x,ctpt.y,ctpt.z); } int n=stpt.size(); stroke(200-0.5*colorStep*(stpt.size()),255,255); VerletParticle ept=(VerletParticle)stpt.get(n-1); curveVertex(ept.x,ept.y,ept.z); endShape(); // Display the particles for(int i=0;i<stpt.size();i++) { pushMatrix(); VerletParticle dpt=(VerletParticle)stpt.get(i); translate(dpt.x,dpt.y,dpt.z); strokeWeight(2);

IX

CHAPTER 9_APPENDIX

Str(VerletParticle _OriPt,VerletParticle _endPt, float _restLength,int _stepNum,float _stepDist, float _strength, ArrayList _lockNum) { OriPt=_OriPt; endPt=_endPt; restLength=_restLength; stepNum=_stepNum; stepDist=_stepDist; strength=_strength; lockNum=_lockNum; }

228

void addpt() { for(int i=0;i<stepNum;i++) { float tx=OriPt.x; float ty=OriPt.y+stepDist*i; float tz=OriPt.z; VerletParticle tpt; tpt=new VerletParticle(tx,ty,tz); physics.addParticle(tpt); stpt.add(tpt); } }

}

}

}

point(0,0,0); popMatrix();

mycoFARMX_Living Architecture  

mycoFARMX IS A PROPOSAL FOR A PROTOTYPE OF A SEASONAL RECREATION AND MYCOPARK IN KUNMING, THE CAPITAL OF YUNNAN IN SOUTHERN CHINA. PRESENTLY...

mycoFARMX_Living Architecture  

mycoFARMX IS A PROPOSAL FOR A PROTOTYPE OF A SEASONAL RECREATION AND MYCOPARK IN KUNMING, THE CAPITAL OF YUNNAN IN SOUTHERN CHINA. PRESENTLY...

Advertisement