• fullscreen
  • bubblegum.pde
  • particle.pde
  • //testing ToxiclibsSupport(:))
    //echoechonoisenoise 2010
    
    import toxi.processing.*;
    import toxi.geom.mesh.*;
    import peasy.org.apache.commons.math.*;
    import peasy.*;
    import peasy.org.apache.commons.math.geometry.*;
    import toxi.geom.*;
    import toxi.volume.*;
    
    int DIM=100;//dimensions of the voxel space: 100x100x100 voxels
    float ISO_THRESHOLD = 3;//higher values smoothen the result, lower uncover spherical characteristics of volumebrush
    Vec3D SCALE=new Vec3D(1,1,1).scaleSelf(1000);//proportions and scale of voxel space
    
    VolumetricSpace volume;
    IsoSurface surface;
    VolumetricBrush brush;
    TriangleMesh mesh;
    ToxiclibsSupport gfx;
    
    PeasyCam cam;
    
    ArrayList ptc;//particles list
    
    float i=random(100);//position in noise space, randomized, so each time different form comes out
    float sc=0.007;//step size while moving thru noise space
    float brushDensity=1;
    PVector l[];
    float str;
    int fCount=0;
    int pAmount=500;
    
    void setup() {
      size(700,700,P3D);
      cam = new PeasyCam(this,1300);
      gfx=new ToxiclibsSupport(this);
      volume=new VolumetricSpace(SCALE,DIM,DIM,DIM);
      surface=new IsoSurface(volume);
      brush=new RoundBrush(volume,10);
      initLight();
    
      ptc=new ArrayList();
      for(int i=0;i<pAmount;i++) {
        ptc.add(new Particle());
      }
      noStroke();
      fill(200,50,100);
    }
    
    void draw() {
      fCount++;
      background(35);
      for(int i=0; i<l.length; i++) {
        directionalLight(str,str,str, l[i].x,l[i].y,l[i].z);//all the lights
      }
      if(fCount<50) {//record 50 steps as a shape, each time updating the isosurface
        mesh=new TriangleMesh();
        volume.closeSides();  
        surface.reset();
        surface.computeSurfaceMesh(mesh,ISO_THRESHOLD);
    
        for(int i=0;i<ptc.size();i++) {
          Particle c=(Particle)ptc.get(i);
          c.behave();
          c.display();
        }
      }
      gfx.mesh(mesh,true);//draw nice, shaded mesh
    }
    
    void keyPressed() {//reset all the stuff, and create a new shape
      fCount=0;
      i=random(10);
      volume=new VolumetricSpace(SCALE,DIM,DIM,DIM);  
      surface=new IsoSurface(volume); 
      brush=new RoundBrush(volume,10);
    
      ptc=new ArrayList();
      for(int i=0;i<pAmount;i++) {
        ptc.add(new Particle());
      }
    }
    
    void initLight() {//by Marius Watz
      randomSeed(11);
      l=new PVector[7];
      for(int i=0; i<l.length; i++) {
        str=random(TWO_PI);
        l[i]=new PVector(cos(str)*10,0.3,sin(str)*10);
      }
      str=random(120,180);
    }
    
    
    
    
    
    class Particle{
      PVector pos;
      float speed;
      int spread=150;
      Particle(){
        pos=new PVector(random(-spread,spread),random(-spread,spread),0);
        speed=60;
      }
      void behave(){    
        pos.x+=(noise(i,pos.x*sc,pos.y*sc)-.5)*speed;
        pos.y+=(noise(i+1,pos.x*sc,pos.z*sc)-.5)*speed;
        pos.z+=(noise(i+2,pos.x*sc,pos.y*sc)-.5)*speed; 
      }
    
      void display(){
      Vec3D Pos=new Vec3D(pos.x,pos.y,pos.z);
      brush.drawAtAbsolutePos(Pos,brushDensity);//drawing particle paths with volumetric brush
      }
    }
    
    
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement

    echoechonoisenoise

    ginger

    Add to Faves Me Likey@! 7
    You must login/register to add this sketch to your favorites.

    similar to http://www.vimeo.com/7594282
    sometimes quite scary.
    keyPressed() for a new shape

    hey, I get a java heap space error right away. My computer's java don't handle this sketch, but I really wonder how it looks like..
    that's interesting. is it only this or my other 3d stuff as well? ii don't know much about how to handle that problem... maybe i can update it to new volumeutils...
    Stieke
    13 May 2011
    Hey! I get this error: 'the package 'toxi' does not exist. You might be missing a library'. I'm very new at this. How can I make it work? Thanks =) !
    hey. that means you are missing a library. here is a list of some available libs: http://www.processing.org/reference/libraries/
    more specificaly, you are missing toxiclibs: http://toxiclibs.org/2011/01/toxiclibs-0020/
    you might want to check Jose's tutorial on that matter: http://vimeo.com/17242182 as well.
    unfortunately that is not all :) this sketch uses an old version of toxiclibs, so if you will have the new one (0020) installed, it will not run...
    but there is http://www.openprocessing.org/visuals/?visualID=16833 working on very similar principles, so maybe you can find your way...
    Stieke
    13 May 2011
    okay, I'll try that =) . Thanks for the help!
    just found great animation and renderings of these structures: http://nonstandardstudio.wordpress.com/2011/10/03/noisy-agents-003-nss/
    made by daniel bolojan!
    You need to login/register to comment.