import processing.opengl.*; import anar.*; import java.util.*; /* * Example for Anar library by Guillaume LaBelle + Julien Nembrini * http://anar.ch */ Sliders parameters; Pt a, b, c, d, e, f; Obj obj; int nIteration = 0; void setup(){ size(800,400,OPENGL); Anar.init(this); Scene.autoSeek = false; obj = new Obj(); a = Anar.Pt( -30,30); b = Anar.Pt( -25,0); c = Anar.Pt( -30, -30); d = Anar.Pt(30, -30); e = Anar.Pt(25,0); f = Anar.Pt(30,30); initForm(); initSpacePoints(); Pts.globalRender = new RenderPtsAll(); } void reset(){ obj.faces.clear(); obj.pts.ptList.clear(); initForm(); initSpacePoints(); nIteration = 0; } void initForm(){ Pts facePts = new Pts(); facePts.add(a); facePts.add(b); facePts.add(c); facePts.add(d); facePts.add(e); facePts.add(f); Face f = new Face(facePts); obj.add(f); parameters = new Sliders(a); // println(parameters); } void initSpacePoints(){ float maxX = 80; float maxY = 80; float maxZ = 400; for (int i = 0; i<200; i++){ // obj.add(Anar.Pt( (float)Math.random()*2*maxX - maxX, // (float)Math.random()*2*maxY - maxY, // (float)Math.random()*maxZ)); obj.add(Anar.Pt((float)Math.sin(i/(float)Math.PI)*maxX,(float)Math.cos(i/(float)Math.PI)*maxY,i/2)); } } void spaceColonyStep(){ float actionDist = 60; float deleteDist = 50; float coeff = 5; float zz = 5; // get last face Face f = obj.faces.get(obj.faces.size()-1); // make a translated copy Face newFace = new Face(); Iterator it = f.iterator(); while (it.hasNext()){ Pt pp = (Pt)it.next(); Pt ppp = Anar.Pt(pp.x(),pp.y(),pp.z()); ppp.translate(0,0,zz); newFace.add(ppp); } obj.add(newFace); // now perform spaceColony attraction on all the vertices in the object // for each space point select nearest and attract it. Pts newSpacePoints = new Pts(); ArrayList listT = new ArrayList(); it = obj.pts.iterator(); while (it.hasNext()){ Pt spaceP = (Pt)it.next(); boolean delete = false; int index = 0; ListIterator itF = obj.faces.listIterator(); while (itF.hasNext()){ f = (Face)itF.next(); Iterator itP = f.iterator(); while (itP.hasNext()){ Pt faceP = (Pt)itP.next(); // first round populate transform list if(listT.size()0) v.set(v.x()/v.length(),v.y()/v.length(),v.z()/v.length()); return new Translate(v); } } void weavingIteration(){ nIteration++; println(nIteration); float z = 2f; ArrayList newFaces = new ArrayList(); for (int k = 0; k