• fullscreen
  • barocco.pde
  • particle.pde
  • //basic 3d particle system behavior: movement within the noise space
    //echoechonoisenoise
    
    //open architecture open design : use it for any purpose, just link the results of your work
    
    import peasy.org.apache.commons.math.*;
    import peasy.*;
    import peasy.org.apache.commons.math.geometry.*;
    
    PeasyCam cam;
    ArrayList ptc;
    int quantity=1000;
    float i=random(10),sc=random(0.1,0.001);
    
    void setup(){
      size(700,700,P3D);
      cam = new PeasyCam(this,1200);
      ptc=new ArrayList();
      for(int i=0;i<quantity;i++){
        ptc.add(new Particle());  
      }
    }
    
    void draw(){
      background(35);
      for(int i=0;i<ptc.size();i++){
        Particle c=(Particle)ptc.get(i);
        c.behave();
        c.display();
      }
    }
    
    void keyPressed(){
      i=random(10);
      sc=random(0.01,0.001);
      ptc.clear();
      for(int i=0;i<quantity;i++){
        ptc.add(new Particle());  
      }
    }
    
    
    
    
    
    
    class Particle{
      PVector pos;
      float speed;
      color c;
      ArrayList path;
      int t=0;
    
      Particle(){
        c=color(random(155),random(50,255),random(150,255),50);
        pos=new PVector(random(-400,400),random(-400,400),0);
        sc=0.007;
        speed=random(10,50);
        path=new ArrayList();
      }
    
      void behave(){
        if(t<100){
        pos.x+=(noise(i,pos.x*sc,pos.y*sc)-.5)*speed;
        pos.y+=(noise(i+2,pos.x*sc,pos.z*sc)-.5)*speed;
        pos.z+=(noise(i+3,pos.x*sc,pos.y*sc)-.5)*speed; 
        path.add(new PVector(pos.x,pos.y,pos.z));
        t++;
        }
      }
    
      void display(){
        stroke(c);
        for(int i=1;i<path.size();i++){
          PVector c=(PVector)path.get(i-1);
          PVector p=(PVector)path.get(i);
          line(p.x,p.y,p.z,c.x,c.y,c.z);
        } 
      }
    }
    
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    echoechonoisenoise
    frankie zafe
    2 Jan 2011
    nice!
    thx, but in the end it's just http://www.openprocessing.org/visuals/?visualID=6742 in 3d
    taj dhami
    3 May 2011
    slick
    just found a great set of pictures using these methods: http://nonstandardstudio.wordpress.com/2011/10/03/agent-based-design/
    by daniel bolojan
    You need to login/register to comment.