class TailBoid extends Boid { ArrayList history; TailBoid() { super(); history = new ArrayList(); } TailBoid(Vector3D l, float ms, float mf) { super(l, ms, mf); history = new ArrayList(); } Boid newBoid() { return new TailBoid(new Vector3D(width/2,height/2),4.0f,0.1f); } void drawTail() { Iterator iter = history.iterator(); Vector3D tvec, lvec; int scolor = 0; if(history.size() > 1) { lvec = (Vector3D)iter.next(); while(iter.hasNext()) { tvec = (Vector3D)iter.next(); scolor+=5; stroke(scolor); if(abs(dist(lvec.x(), lvec.y(), lvec.z(), tvec.x(), tvec.y(), tvec.z())) < 10.0) line(lvec.x(), lvec.y(), lvec.z(), tvec.x(), tvec.y(), tvec.z()); lvec = tvec; } } } void render() { float theta = vel.heading2D() - radians(90); push(); stroke(255, 0, 0); //line(loc.x(), loc.y(), loc.x() - 10*sin(theta), loc.y() + 10*cos(theta)); fill(255, 0, 0); stroke(100); push(); //println(loc.z()); translate(loc.x(), loc.y(), loc.z()); ellipse(0, 0, 8, 8); pop(); if(history.size() > 40) { history.remove(0); } history.add(new Vector3D(loc.x(), loc.y(), loc.z())); this.drawTail(); pop(); } }