• fullscreen
  • harmony_axial_3d.pde
  • 
    ArrayList<ArrayList<PVector>>Lines; 
    ArrayList<PVector> currentLine = new ArrayList();
    float rotation = 0;
    boolean spin = true;
    boolean guides = true;
    float rot_increment = 0.01; // rotation speed
    int jointhresh = 100;
    
    void setup(){
      size(600,600,P3D);
      Lines = new ArrayList();
      background(255);
      //smooth();
      frameRate(25);
      noCursor();
    }
    
    void draw(){
      background(255);
      noFill();
      translate(width/2,0,-100);
      // drawing reference lines
      if (guides){
      stroke(255,100,100,100);
      line(mouseX-width/2,0,0,0,0,0);
      line(mouseX-width/2,width,0,0,width,0); 
      line(mouseX-width/2,mouseY-10,0,mouseX-width/2,mouseY+10,0);
      line((mouseX-width/2)-10,mouseY,0,(mouseX-width/2)+10,mouseY,0);
      if (mousePressed) ellipse(mouseX-width/2,mouseY,5,5);
      }
       
      rotateY(rotation);
      // world reference lines
      if (guides){
      stroke(0,200,200,80);
      line(0,0,0,0,width,0); // ref lines
      line(-width/2,width,0,width/2,width,0);
      line(0,width,-width/2,0,width,width/2);
      line(-width/2,0,0,width/2,0,0);
      line(0,0,-width/2,0,0,width/2);
      }
    
      for (ArrayList<PVector> ln : Lines){
        // draw the main line for each polyline
        stroke(0,200);
        beginShape();
        for (PVector p : ln){
          vertex(p.x,p.y,p.z);
        }
        endShape();
        stroke(0,50);
        // draw the webbed lines
        for (PVector v : ln){
          for (PVector v2 : ln){
            float d = v.dist(v2);
            if ( jointhresh < d && d < jointhresh + 10 ) line(v.x,v.y,v.z,v2.x,v2.y,v2.z); 
          } 
        } 
      }
      
      stroke(255,0,0,150);
      beginShape();
      for (PVector c : currentLine){
        vertex(c.x,c.y,c.z);
      }
      endShape();
      
      if (spin) rotation += rot_increment;
      
      if (mousePressed) currentLine.add(new PVector(cos(rotation)*(mouseX-width/2),mouseY,sin(rotation)*(mouseX-width/2))); // add a point
    }
    
    
    void mousePressed(){
      currentLine = new ArrayList<PVector>(); // start a new line
    }
    
    void mouseReleased(){
       Lines.add(new ArrayList(currentLine)); // stash the current line in the main arraylist
       currentLine.clear(); // then clear it
    }
    
    void keyPressed(){
      if (key == 'c') Lines.clear();
      if (key == ' ') spin = !spin;
      if (keyCode == RIGHT && !spin) rotation += 0.05;
      if (keyCode == LEFT && !spin) rotation -= 0.05;
      if (keyCode == UP) jointhresh += 1;
      if (keyCode == DOWN) jointhresh -= 1;
      if (key == 'g') guides = !guides;
    }
    
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement

    mitchell whitelaw

    axial web 3d

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

    A 3D drawing toy inspired by Mr Doob's Harmony (web mode) and Amit Pitaru's Rhonda. Draw lines into a rotating 3d space; points in those lines are connected according to their distance from each other.

    Controls:
    - drag to draw
    - space to toggle rotation (you can keep drawing)
    - up / down arrow to adjust web connection threshhold
    - left / right arrow while paused to manually rotate
    - c to clear
    - g to toggle guides

    Ben Mandeberg
    4 Feb 2011
    This is really great. Really nice forms.
    Wesley Bitomski
    19 May 2011
    Works better than what I wrote a while back... based on something you did.
    Nick Venden
    26 Jul 2012
    I wanna blow it up with a 20k lumens projector on a 50' wall and have a dancer draw (Kinect?) Beautiful Sir.
    You need to login/register to comment.