PhD Research on Architectural Facades

edited November 2014 in General Discussion

I am doing research on automatic computer generated building facades. I am using ANAR library as of now. I have searched various libraries and I found that iGeo can be a useful library too. Does anyone have any experience in using processing for 'Architecture' field? Please share your views on thoughts about using processing for 'architecture' and challenges occurred during your journey. Or may be another useful source for 3D modelling.

Answers

  • Answer ✓

    on openprocessing.org is a lot - see collections there

    there are special software for architects such as 3d-cad afaik. they do have ready made parts like doors and walls, have the pricing and necessary parts and offer 3D walk thru

    i don't think it is wise to try to do the same in processing

    it depens from what you're aiming at...

    for 3D modelling see sketchUp and thingiverse of course

    i made a camera program once runner which let's you run thru a level - you can use that for a house I guess

    chrisir

  • Yup thnx ,,,, Actually I was in search of a tool where I will be able to have luxury to play with user interference too, so I chose processing. I tried google sketchup and autocad, revit but I am not able to design UI. I am studying the scripts from openprocessing.org related to architecture. Thanks a lot for the reference. :)

  • don't accept an answer too soon.... thread looks closed then

    see also openprocessing.org | collections | raytracing

    there is one sketch with walls....

  • ohk... i will check it ... thnx :)

  • what do you want to achieve exactly?

    a facade with random?

  • edited December 2014

    I am an architect with a master's degree in sustainable architecture(2013). During master's I got introduced to processing. I wish to develop an algorithm as a part of my PhD research where I can create multiple facade design solutions randomly via single script. Where user inputs should be minimum in order to keep it as simple as possible. But I do not want to prefer traditional method. i.e. developing facades first and then select randomly within those. I am looking forward to develop something that will be able to generate it at an instant.

  • search architecture on openprocessing

    do you mean facade with colors and ornaments or more 3D like structures (bay/oriel/alcoves)?

  • By facade I mean exterior overall elevation. That includes ACP cladding, glazing, brickwall, bays, windows, doors, louvres, voids, colours, etc. It means whole elevation of buildings ranging from residential apartments to commercial offices.

    As you are more experienced in coding than me, may be you can suggest some algorithms or a conceptual approach, that would very appreciable as well as helpful.

    yah .. I am searching for the same on openprocessing.org . Till now haven't found anything solid where I can discuss about it. lets see :) ..

  • also here, sometimes you have a roof structure or a curved wall.... just an inspiration....

    http://www.openprocessing.org/sketch/775

  • Thanx a lot for the examples. This will definitely speed up my process. I will study them and lets see what I can benefit from them. :) thnx again

  • last night I made a quick facade... you need to insert a ground around the house and a door.

    // list 
    ArrayList<Ball> balls;
    // list 
    ArrayList<Cube> cubes;
    // plate
    Plate[] plates = new Plate[1];
    
    // cam stuff
    float camX=0, camY=445.0, camZ=0;  // its position 
    float camAngle=10;   // rotation angle in degree 
    float camRadius = 700;    // 400 radius (dist to scene) 
    
    void setup() {
      size(600, 600, OPENGL);
      background(20);
    
      // -------------------------  
      // Create an empty ArrayList (the red sinus curve)
      balls = new  ArrayList();
      // we define a circle   
      for (int i = 0 ; i<362; i++) {
        float r = 20; 
        float x = i+(-362/2)+width/2; // r * cos ( radians(i-0) ) + width / 2 ;
        float y = r * sin ( radians(i-0) ) + height / 2 -180;
        float z = 30;
        // and put it into our ArrayList balls 
        balls.add (new Ball(  x, y, z, 
        3, 
        color (255, 2, 2) ) );
      } // for
    
      // -------------------------  
      // Create an empty ArrayList (cubes on the facade)
      cubes = new  ArrayList();
      // we define a cube   
      for (int i = 0 ; i<362; i++) {
        float r = 20; 
    
        float x = random(width/2-150, width/2+160); 
        float y = random(150, 450);
        float z = random(3, 39);
    
        // and put it into our ArrayList balls 
        cubes.add (new Cube(  x, y, z, 
        random(5, 54), random(5, 69), random(2, 14), 
        3, 
        color (210) ) );
      } // for
    
      // -----------------------------
      // plate in front - way to house 
      PVector[] arrPV = new PVector[1];
      arrPV = new PVector[1];
      int y1 = 480;
      arrPV[0] =                         new PVector(320, y1, -90+60+60);
      arrPV = (PVector[]) append (arrPV, new PVector(320, y1, -90+60+60));
      arrPV = (PVector[]) append (arrPV, new PVector(390, y1, -90+60+60));
      arrPV = (PVector[]) append (arrPV, new PVector(390, y1, -10+60+60+211));
      arrPV = (PVector[]) append (arrPV, new PVector(320, y1, -10+60+60+211));
      plates[0] = new Plate(arrPV, color(183, 143, 11));
    } // func 
    
    void draw() {
      background(20);
      cameraManagement();
      lights();
      noStroke();
    
      drawHouse();
    } // func
    
    // ----------------------------------------------------
    // Misc 
    
    void drawHouse() {
      fill(170);
      sphereDetail(29);
      sphereParams (width/2, height/2, -350, 40);
    
      // main house 
      fill(210);
      boxParams (width/2, height/2, -150, 360);
    
      Ball ball;
      sphereDetail(4);
      for (int i=0; i < balls.size(); i++) {
        ball = balls.get(i);
        ball.display();
      }
    
      Cube cube;
      for (int i=0; i < cubes.size(); i++) {
        cube = cubes.get(i);
        cube.display();
      }
    
      for (Plate p1 : plates) { 
        if (p1==null) {
          // println ("null");
        }  
        else 
          p1.display();
      } //for
    } // 
    
    void cameraManagement() {
    
      camX= camRadius * cos ( radians(camAngle) ) +330 ;
      camZ= camRadius * sin ( radians(camAngle) ) +0 ;
      camera(camX, camY, camZ, 
      330.0, 331.0, 0.0, 
      0.0, 1.0, 0.0);
    
      // cam
      if (!keyPressed) {
        camAngle+=.6;
        if (camAngle>360) 
          camAngle=0;
      } // if
    }
    
    void boxParams(float x, float y, float z, 
    float size1) {
      pushMatrix();
      translate(x, y, z);
      box(size1);
      popMatrix();
    }
    
    void sphereParams(float x, float y, float z, 
    float size1) {
      pushMatrix();
      translate(x, y, z);
      sphere(size1);
      popMatrix();
    }
    
    // ==============================================
    
    class Plate {
    
      PVector[] a1;
      color fillColor ; 
    
      Plate (PVector[] a1_, color fillColor_) {
        int i=0;
        a1 = new PVector[a1_.length];
        for (PVector pv : a1_) {
          a1[i]=pv;
          i++;
        } // for
        fillColor=fillColor_;
      } // constr 
    
    
      void display () {
        fill(fillColor);
        noStroke();
        beginShape();
        for (PVector pv : a1) 
          vertex(pv.x, pv.y, pv.z);
        vertex(a1[0].x, a1[0].y, a1[0].z);
        endShape(CLOSE);
      } // method
    } // class
    
    // =======================================================
    
    // ball class
    class Ball {
    
      // this ball class can store a xyz pos  
      float posx;
      float posy;
      float posz;
    
      // now other properties: 
      color myColor; 
      float widthOfBall;
    
      // constr
      Ball(float tempposX, float tempposY, float tempposZ, 
      float tempwidthOfBall, 
      color tempmyColor1 ) {
        // constr
        posx = tempposX;
        posy = tempposY;
        posz = tempposZ;
        myColor=tempmyColor1;
        // myColor = color(random(255), random(255), random(255));
        widthOfBall = tempwidthOfBall;
      } // constr
    
      void display() {
        // set color 
        fill(myColor); 
        noStroke();
    
        // paint the ball at this pos 
        pushMatrix();
        translate(posx, posy, posz);
        sphere (widthOfBall);
        popMatrix();
      } // method
      //
    } // class   
    
    // =====================================================================
    
    // class
    class Cube {
    
      // this class can store a xyz pos  
      float posx;
      float posy;
      float posz;
      // now other properties: 
      color myColor; 
      float widthX, widthY, widthZ;
    
      // constr
      Cube (float tempposX, float tempposY, float tempposZ, 
      float widthX_, float widthY_, float widthZ_, 
      float tempwidthOfBall, 
      color tempmyColor1 ) {
        // constr
        posx = tempposX;
        posy = tempposY;
        posz = tempposZ;
    
        widthX = widthX_;
        widthY = widthY_;
        widthZ = widthZ_;
    
        myColor=tempmyColor1;
        // myColor = color(random(255), random(255), random(255));
      } // constr
    
      void display() {
        // set color 
        fill(myColor); 
        noStroke();
    
        // paint the ball at this pos 
        pushMatrix();
        translate(posx, posy, posz);
        box (widthX, widthY, widthZ);
        popMatrix();
      } // method
      //
    } // class   
    
    // ===================================================================
    
  • Hey I saw tht ... its awesome... :) .. thanks a lot.. I will study your script and will try to make something out of it.. and doors and windows are not required as of now :) ... thnx again:)

  • I am beginner in this you can say. .. And so far I feel that processing is the right place to proceed in my research quest. I will try my best to cope up with this as soon as possible.

    here is link to my profile : http://archinect.com/kartik I have uploaded my portfolio there. I hope you might like it :) .

  • i was having more plans with the house but I didn't have time.

    Did you notice the sphere at the back of the house?

    I was planning to have that as a reading room, diameter 3 meter maybe, made out of glass. use glow() here.

    i was planning to have the house getting smaller towards the back, so that the back has the size of the sphere and goes right into it.

    I was also planning not to have the sinus curve as a mere decoration but to have it form the house (roof and facade) so that the roof has a sinus form. And the facade at the top has a sinus finishig and not a straight finishing.

    of course the facade could be sinoid as well.

    also the floor plan could be a light curve as well.

    Best, Chrisir ;-)

  • new version.

    final int GROUND_LEVEL = 480;
    
    // list for red sinus curve 
    ArrayList<Ball> balls = new  ArrayList();
    // list cubes on the facade 
    ArrayList<Cube> cubes = new  ArrayList();
    // list plates (way to the house)
    ArrayList<Plate> plates = new  ArrayList();
    // list clouds  
    ArrayList<Cloud> clouds = new  ArrayList();
    
    // cam stuff
    float camX=0, camY=445.0, camZ=0;  // its position 
    float camAngle=10;   // rotation angle in degree 
    float camRadius = 700;    // 400 radius (dist to scene) 
    
    void setup() {
      size(600, 600, OPENGL);
      background(20, 22, 254);
    
      // -------------------------  
      // the red sinus curve
      for (int i = 0 ; i<362; i++) {
        // we define a circle
        float r = 20; 
        float x = i+(-362/2)+width/2; // r * cos ( radians(i-0) ) + width / 2 ;
        float y = r * sin ( radians(i-0) ) + height / 2 -180;
        float z = 30;
        // and put it into our ArrayList balls 
        balls.add (new Ball(  x, y, z, 
        3, 
        color (255, 2, 2) ) );
      } // for
    
      // -------------------------  
      // clouds
      for (int i = 0 ; i<1362; i++) {
        // we define a cloud
        Cloud currentCloud =
          new Cloud( int ( random(-1000, 1000 )), int (random(-4000, 1000 )), 
        color (random (210, 255))  ); 
        clouds.add (currentCloud);
      }
    
      // -------------------------  
      // cubes on the facade
      for (int i = 0 ; i<362; i++) {
        // we define a cube   
        float r = 20; 
    
        float x = random(width/2-150, width/2+160); 
        float y = random(150, 450);
        float z = random(3, 39);
    
        // and put it into our ArrayList balls 
        cubes.add (new Cube(  x, y, z, 
        random(5, 54), random(5, 69), random(2, 14), 
        3, 
        color (210) ) );
      } // for
    
      // -----------------------------
      // plate : ground / grass 
      PVector[] arrPV = new PVector[1];
      arrPV = new PVector[1];
      int y1 = GROUND_LEVEL;
      arrPV[0] =                         new PVector(-1000, y1, -1000);
      arrPV = (PVector[]) append (arrPV, new PVector(-1000, y1, -1000));
      arrPV = (PVector[]) append (arrPV, new PVector(1000, y1, -1000));
      arrPV = (PVector[]) append (arrPV, new PVector(1000, y1, 1000));
      arrPV = (PVector[]) append (arrPV, new PVector(-1000, y1, 1000));
      plates.add (new Plate(arrPV, color(51, 255, 41)));
    
    
      // -----------------------------
      // plate in front - way to house 
      arrPV = new PVector[1];
      arrPV = new PVector[1];
      y1 = GROUND_LEVEL-1;
      arrPV[0] =                         new PVector(320, y1, -90+60+60);
      arrPV = (PVector[]) append (arrPV, new PVector(320, y1, -90+60+60));
      arrPV = (PVector[]) append (arrPV, new PVector(390, y1, -90+60+60));
      arrPV = (PVector[]) append (arrPV, new PVector(390, y1, -10+60+60+211));
      arrPV = (PVector[]) append (arrPV, new PVector(320, y1, -10+60+60+211));
      plates.add(new Plate(arrPV, color(183, 143, 11)));
    
      //
    } // func 
    
    void draw() {
      //  background(20);
      background(20, 22, 170);
    
      cameraManagement();
    
      drawHouse();
    } // func
    
    // ----------------------------------------------------
    // Misc 
    
    void drawHouse() {
      lights();
    
      // Sphere at the back of the house
      fill(170);
      sphereDetail(29);
      sphereParams (width/2, height/2, -350, 40);
    
      // main house 
      fill(210);
      stroke(40);
      boxParams (width/2, height/2, -150, 360);
    
      sphereDetail(4);
      for (Ball ball : balls) {
        ball.display();
      }
    
      // facade
      fill(210);
      for (Cube cube : cubes) {
        cube.display();
      }
    
      // ground and way to the house
      for (Plate p1 : plates) { 
        p1.display();
      } //for
    
      sphereDetail(14);
      for (Cloud cloud : clouds) {
        cloud.display();
      }
      //
    } // 
    
    void cameraManagement() {
    
      camX= camRadius * cos ( radians(camAngle) ) +330 ;
      camZ= camRadius * sin ( radians(camAngle) ) +0 ;
      camera(camX, camY, camZ, 
      330.0, 331.0, 0.0, 
      0.0, 1.0, 0.0);
    
      // camera
      if (!keyPressed) {
        // rotate
        camAngle+=.6;
        if (camAngle>360) 
          camAngle=0;
      } // if
    }
    
    // ---------------------------------------------
    
    void boxParams(float x, float y, float z, 
    float size1) {
      // a box with parameters
      pushMatrix();
      translate(x, y, z);
      box(size1);
      popMatrix();
    }
    
    void sphereParams(float x, float y, float z, 
    float size1) {
      // a sphere with parameters
      pushMatrix();
      noStroke(); 
      translate(x, y, z);
      sphere(size1);
      popMatrix();
    }
    
    // ==============================================
    
    class Plate {
    
      PShape plateShape;
    
      // constr
      Plate (PVector[] a1_, color fillColor_) {
        plateShape = createShape(); 
        plateShape.beginShape();
        plateShape.fill(fillColor_);
        plateShape.noStroke();
        for (PVector pv : a1_) 
          plateShape.vertex(pv.x, pv.y, pv.z);
        plateShape.vertex(a1_[0].x, a1_[0].y, a1_[0].z);
        plateShape.endShape(CLOSE);
      } // constr 
    
      void display () {
        shape(plateShape);
      } // method
    } // class
    
    // =======================================================
    
    class Cloud {
    
      PShape cloudShape;
      int x, z;
    
      // constr
      Cloud (int tempx, int tempz, color fillColor_) {
        x=tempx;
        z=tempz;
    
        // temp: the parts 
        PShape cloudBody = createShape(SPHERE, 90); 
        cloudBody.setStroke(false); 
        cloudBody.setFill(fillColor_);
        cloudBody.scale(1.0, .4, 1.0);
    
        PShape cloudHead1 = createShape(SPHERE, 50);
        cloudHead1.setStroke(false); 
        cloudHead1.setFill(fillColor_);
        cloudHead1.translate(-40, -20, 0);
    
        PShape cloudHead2 = createShape(SPHERE, 40); 
        cloudHead2.setStroke(false); 
        cloudHead2.setFill(fillColor_);
        cloudHead2.translate(30, -28, 0);
    
        // permanent: the group
        // (consisting of the parts before)
        cloudShape = createShape(GROUP); 
        cloudShape.addChild(cloudBody);
        cloudShape.addChild(cloudHead1);
        cloudShape.addChild(cloudHead2);
        cloudShape.setFill(fillColor_);
      } // constr 
    
      void display () {
        translate (x, -120, z);
        shape(cloudShape);
      } // method
    } // class
    
    // =======================================================
    
    // ball class
    class Ball {
    
      // this ball class can store a xyz pos  
      float posx;
      float posy;
      float posz;
    
      // now other properties: 
      color myColor; 
      float widthOfBall;
    
      // constr
      Ball(float tempposX, float tempposY, float tempposZ, 
      float tempwidthOfBall, 
      color tempmyColor1 ) {
        // constr
        posx = tempposX;
        posy = tempposY;
        posz = tempposZ;
        myColor=tempmyColor1;
        widthOfBall = tempwidthOfBall;
      } // constr
    
      void display() {
        // set color 
        fill(myColor); 
        noStroke();
    
        // paint the ball at this pos 
        pushMatrix();
        translate(posx, posy, posz);
        sphere (widthOfBall);
        popMatrix();
      } // method
      //
    } // class   
    
    // ========================================
    
    // class
    class Cube {
    
      // this class can store a xyz pos  
      float posx;
      float posy;
      float posz;
    
      // now other properties: 
      color myColor; 
      float widthX, widthY, widthZ;
    
      // constr
      Cube (float tempposX, float tempposY, float tempposZ, 
      float tempwidthX, float tempwidthY, float tempwidthZ, 
      float tempwidthOfBall, 
      color tempmyColor1 ) {
        // constr
        posx = tempposX;
        posy = tempposY;
        posz = tempposZ;
    
        widthX = tempwidthX;
        widthY = tempwidthY;
        widthZ = tempwidthZ;
    
        myColor=tempmyColor1;
      } // constr
    
      void display() {
        // set color 
        fill(myColor); 
        noStroke();
    
        // paint the cube at this pos 
        pushMatrix();
        translate(posx, posy, posz);
        box (widthX, widthY, widthZ);
        popMatrix();
      } // method
      //
    } // class   
    
    // ==============================================
    
  • Yah totally agree about your concerns regarding the plans :) .. Floor plans can be curved as well ..But the randomization you did is appreciable and as you said u made it quick that means you can enhance it till optimal level :) .. It will take some more time for me to generate something quickly ... thnx always

  • One more thought cam in my mind that ... as you did it without using any 3d LIBRARY like Anar or iGeo, there is a noticeable potential to develop this part of research on processing alone... i mean without any help of other libraries.

  • yah .. this is so close to that... well I tried to understand your script ... and also studied the script that you mentioned regarding the city scape (http://openprocessing.org/sketch/12878) ... its outstanding and I wanted to do kind of similar like this ... but more practical ... and more detailed .... only related to façades.... You can imagine your script combined with this one .. and instead of whole city just a building façade will get altered on the mouse click .... i hope you got exactly what I am trying to achieve... . . .The scripts are quite lengthy at the moment ... I believe I will be able to comment on them may be after a month or so .... right now I am just studying the scripts ...

  • edited December 2014

    hello,

    you can easily make it so that when mouse is clicked, entire facade changes.

    now there are only rects, but you can have circles, ellipses and even 3D-spheres easily on the facade.

    also different colors.

    of course the rects could move on the facade all by themself (without mouse clicking), bouncing from the walls (e.g.). Or draw near the sun (and wander with it) or get higher and lower from the temperature. Or react to the the frequency of certain words on twitter....

    ;-)

    of course you can reduce the awesome sketch by Luca Sassone as I just posted below. (3 posts, it was too long.)

    But - and that is a big one - be aware that using his code without asking his permission or stating it is your code is plagiarism. You'll be found out, punished and fail. Same goes with my code btw.; feel free to use my code but don't say it's from you.

    be warned.

  •     /* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/12878*@* */
        /* !do not delete the line above, required for linking your tweak if you upload again */
        // search for !!!! for nice parts
        // by Luca Sassone 
    
        int penx = 0;
        int peny = 0;
        int de = 2;
        cLista lista = new cLista();
        int el0 = 0;
    
        int by;
    
        // ------------------------------------------------------------
    
        void setup() { 
          size(800, 600);
          //  size(1024, 768);
          //  size(screen.width, screen.height);
          smooth();
          // frameRate(30);
          colorMode(HSB, 1);
          ellipseMode(CENTER);
          stroke(0, 0, 0, 0.7);
          background(0, 0, 1);
          //  strokeWeight(0.3 * de + 1);
          strokeWeight(2);
    
          city();
        }
    
        // ------------------------------------------------------------
    
        void draw() {
          int t = 0;
          // println (lista.nr);
          while ( (t < 50) && (el0 < lista.nr)  ) {
            lista._draw(el0);
            t++;
            el0++;
          }
          if (el0 == lista.nr) {
            fill(255, 0, 0);  // !!!!!!!!!!!!!!!!!!!!!!
            text ("click mouse to restart", 15, 15);
            noLoop();
          } // if
        }
    
        // ------------------------------------------------------------
    
        void mouseClicked() {
          lista.nr = 0;
          el0 = 0;
          city();
          background(0, 0, 1);
          loop();
        }
    
        // ------------------------------------------------------------
    
        void keyPressed()
        {
          if ( key == 's') {
            save("city.tif");
          }
        }
    
        // ------------------------------------------------------------
    
        void city() {
    
          // cielo nero
          //  rettf(0, 0, width, int(0.95*height));
    
    
          // luna / MOON !!!!!!!!!!!!!
          // int rag = height / 10;
          //  lista.agg(0, (int)random(rag, width-rag), (int)random(0.3*height, 0.5*height-rag));
          //  lista.agg(6, rag, 0);
    
          // strade // STREET   !!!!!!!!!!!!!!!!
          PVector p1;
          PVector p2;
          //  p1 = proietta(new PVector(-10, 0, 240));
          //  p2 = proietta(new PVector(-10, 0, -60));
          //  linea(p1, p2);
          //  p1 = proietta(new PVector(-20, 0, 240));
          //  p2 = proietta(new PVector(-20, 0, -60));
          //  linea(p1, p2);
          //  p1 = proietta(new PVector(-40, 0, -5));
          //  p2 = proietta(new PVector(240, 0, -5));
          //  linea(p1, p2);
          //  p1 = proietta(new PVector(-40, 0, -15));
          //  p2 = proietta(new PVector(240, 0, -15));
          //  linea(p1, p2);
    
    
          // in the back 
          //  palazzo(new PVector(40, 0, 80));
          //  
          //  palazzo(new PVector(40, 0, 40));
          //  for (int z=9; z>0; z--) {
          //    palazzo(new PVector(0, 0, z*40));
          //  }
          //  for (int x=6; x>=0; x--) {
          //    palazzo(new PVector(x*40, 0, 0));
          //  }
    
          //  palazzo(new PVector(width / 2, 0, 730));
    
          palazzo(new PVector(-1, 0, -0));
    
          // alberi  // trees   !!!!!!!!!!!!!!!!!!!!!!!!!
          for (int x=220; x>=40; x-=40) {
            albero(new PVector(x, 0, -2));
            albero(new PVector(-2, 0, x));
          }
    
          // semafori
          //  semaforox(new PVector( 0, 0, 162));
          //  semaforox(new PVector( 0, 0, 82));
          //  semaforox(new PVector( 0, 0, 2));
          //  semaforoz(new PVector(82, 0, 0));
          //  semaforoz(new PVector( 2, 0, 0));
        }
    
        // ------------------------------------------------------------
    
        PVector proietta(PVector pt) {
          float d = 60.00;
          float h = 1.50;  
          float alfa = radians(30);
    
          float a = pt.x * sin(alfa) - pt.z * cos(alfa);
          float b = pt.x * cos(alfa) + pt.z * sin(alfa);
          float x = d * a / (b + d);
          float y = d * (pt.y - h) / (b + d);
    
          float sc = height / 90;
          return new PVector(0.63*width + sc*x, 0.95*height - sc*y);
        }
    
        // ------------------------------------------------------------
    
        void palazzo(PVector pt) {  
          int tipo = int(random(10));  // type of building !!!!!!!!!!!!!!!!
          String nameBuilding = "unknown";
    
          int h = int(random(50, 100));
          boolean insegne = false;
    
          switch (tipo) {
    
          case 0:
            box3d(new PVector(pt.x+20, h, pt.z+10), new PVector(pt.x+21, h+random(20, 40), pt.z+11));
            box3d(new PVector(pt.x+10, h, pt.z+10), new PVector(pt.x+11, h+random(20, 40), pt.z+11));
            rettangolo_bianco(new PVector(pt.x, h, pt.z), new PVector(pt.x+30, h, pt.z), new PVector(pt.x+30, h, pt.z+30), new PVector(pt.x, h, pt.z+30));
            box3d(new PVector(pt.x, 20, pt.z), new PVector(pt.x+30, h-4, pt.z+30));
            for (int fi=30-3; fi>0; fi-=3) {
              linea(proietta(new PVector(pt.x, 20, pt.z+fi)), proietta(new PVector(pt.x, h-4, pt.z+fi)));
              linea(proietta(new PVector(pt.x+fi, 20, pt.z)), proietta(new PVector(pt.x+fi, h-4, pt.z)));
            }
            box3d(pt, new PVector(pt.x+30, 19, pt.z+30));
            insegne = true;
            break;
    
          case 1:
            int nr = int(random(5, 20));
            for (int i=nr-1; i>=0; i--) {
              box3d(new PVector(pt.x, i*4+4, pt.z), new PVector(pt.x+30, i*4+6, pt.z+30));
            }
            pilotis(pt, 30, 30, 4);
            insegne = true;
            break;
    
          case 2:
            box3d(new PVector(pt.x+1, h-10, pt.z+1), new PVector(pt.x+29, h, pt.z+29));
            box3d(new PVector(pt.x+ 2, 10, pt.z+22), new PVector(pt.x+ 4, h-10, pt.z+28));
            box3d(new PVector(pt.x+22, 10, pt.z+ 2), new PVector(pt.x+28, h-10, pt.z+ 4));
            box3d(new PVector(pt.x+ 4, 10, pt.z+ 4), new PVector(pt.x+22, h-10, pt.z+22));
            box3d(new PVector(pt.x+ 2, 10, pt.z+ 2), new PVector(pt.x+ 8, h-10, pt.z+ 8));
            basamento(pt, 10);
            insegne = true;
            break;
    
          case 3:
            box3d(new PVector(pt.x+14.5, h, pt.z+14.5), new PVector(pt.x+15.5, h+40, pt.z+15.5));
            if (h > 50) box3d(new PVector(pt.x+2, 50, pt.z+2), new PVector(pt.x+28, h, pt.z+28));
            if (h > 50) box3d(new PVector(pt.x+4, 42, pt.z+4), new PVector(pt.x+26, 50, pt.z+26));
            if (h > 42) box3d(new PVector(pt.x+2, 16, pt.z+2), new PVector(pt.x+28, 42, pt.z+28));
            if (h > 16) box3d(new PVector(pt.x+4, 12, pt.z+4), new PVector(pt.x+26, 16, pt.z+26));
            if (h > 12) basamento(pt, 12);
            insegne = true;
            break;
    
          case 4:
            cilindro3d(new PVector(pt.x, 31, pt.z), h-16, 32, 13, true);
            cilindro3d(new PVector(pt.x, 26, pt.z), 4, 32, 13, true);
            cilindro3d(new PVector(pt.x, 21, pt.z), 4, 32, 13, true);
            cilindro3d(new PVector(pt.x, 16, pt.z), 4, 32, 13, true);
            cilindro3d(new PVector(pt.x, 12, pt.z), 4, 32, 11, true);
            cilindro3d(new PVector(pt.x, 0, pt.z), 12, 32, 15, false);
            break;
    
          case 5:
            cilindro3d(new PVector(pt.x, h-2, pt.z), 2, 8, 13, true);
            cilindro3d(new PVector(pt.x, h-6, pt.z), 4, 8, 9, true);
            cilindro3d(new PVector(pt.x, 8, pt.z), h-14, 8, 13, true);
            basamento(pt, 8);
            insegne = true;
            break;
    
          case 6: // giardino
            box3d(pt, new PVector(pt.x+30, pt.y+1, pt.z+30));
            for (int i=0; i<10; i++) {
              float pz = map(i, 0, 10, 0, 22);
              float px = random(0, pz);
              PVector pt0 = new PVector(pt.x+26-px, pt.y+1, pt.z+26-pz+px);
              albero(pt0);
            }
            nameBuilding="garden";
            break;
    
          case 7:
            box3d(new PVector(pt.x+5, 32, pt.z+5), new PVector(pt.x+25, h, pt.z+25));
            box3d(new PVector(pt.x+10, 26, pt.z+10), new PVector(pt.x+20, 32, pt.z+20));
            box3d(new PVector(pt.x+5, 26, pt.z+24), new PVector(pt.x+5, 32, pt.z+25));
            box3d(new PVector(pt.x+5, 26, pt.z+18), new PVector(pt.x+5, 32, pt.z+19));
            box3d(new PVector(pt.x+5, 26, pt.z+11), new PVector(pt.x+5, 32, pt.z+12));
            box3d(new PVector(pt.x+24, 26, pt.z+5), new PVector(pt.x+25, 32, pt.z+6));
            box3d(new PVector(pt.x+18, 26, pt.z+5), new PVector(pt.x+19, 32, pt.z+6));
            box3d(new PVector(pt.x+11, 26, pt.z+5), new PVector(pt.x+12, 32, pt.z+6));
            box3d(new PVector(pt.x+ 5, 26, pt.z+5), new PVector(pt.x+ 6, 32, pt.z+6));
            cilindro3d(new PVector(pt.x, 6, pt.z), 20, 25, 15, false);
            box3d(new PVector(pt.x+10, 0, pt.z+10), new PVector(pt.x+20, 6, pt.z+20));
            box3d(new PVector(pt.x+5, 0, pt.z+24), new PVector(pt.x+5, 6, pt.z+25));
            box3d(new PVector(pt.x+5, 0, pt.z+18), new PVector(pt.x+5, 6, pt.z+19));
            box3d(new PVector(pt.x+5, 0, pt.z+11), new PVector(pt.x+5, 6, pt.z+12));
            box3d(new PVector(pt.x+24, 0, pt.z+5), new PVector(pt.x+25, 6, pt.z+6));
            box3d(new PVector(pt.x+18, 0, pt.z+5), new PVector(pt.x+19, 6, pt.z+6));
            box3d(new PVector(pt.x+11, 0, pt.z+5), new PVector(pt.x+12, 6, pt.z+6));
            box3d(new PVector(pt.x+ 5, 0, pt.z+5), new PVector(pt.x+ 6, 6, pt.z+6));
            insegne = true;
            break;
    
          case 8:
            box3d(new PVector(pt.x+2, 6, pt.z+2), new PVector(pt.x+18, h-10, pt.z+18));
            box3d(new PVector(pt.x, 0, pt.z+23), new PVector(pt.x+2, h, pt.z+28));
            box3d(new PVector(pt.x, 0, pt.z+18), new PVector(pt.x+2, h-5, pt.z+23));
            box3d(new PVector(pt.x, 0, pt.z+ 7), new PVector(pt.x+2, h-5, pt.z+12));
            box3d(new PVector(pt.x, 0, pt.z+ 2), new PVector(pt.x+2, h, pt.z+ 7));
            box3d(new PVector(pt.x+23, 0, pt.z), new PVector(pt.x+28, h, pt.z+2));
            box3d(new PVector(pt.x+18, 0, pt.z), new PVector(pt.x+23, h-5, pt.z+2));
            box3d(new PVector(pt.x+ 7, 0, pt.z), new PVector(pt.x+12, h-5, pt.z+2));
            box3d(new PVector(pt.x+ 2, 0, pt.z), new PVector(pt.x+ 7, h, pt.z+2));
            insegne = true;
            break;
    
          case 9:
            cilindro3d(new PVector(pt.x, 0, pt.z), h, 32, 11, true);
            box3d(new PVector(pt.x, 0, pt.z+15), new PVector(pt.x+4, h, pt.z+30));
            box3d(new PVector(pt.x+15, 0, pt.z), new PVector(pt.x+30, h, pt.z+4));
            insegne = true;
            break;
          } // switch 
    
          // !!!!!!!!!! 
          println ("type of building is "
            + tipo 
            + " ("
            +nameBuilding
            +")."); 
    
          // what is this?  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
          insegne=false;
    
          if (insegne) {
            float iw = random(1, 1.5);
            float ih = random(2, 10);
            float ipos = random(2, 14);
            rettangolo_bianco(new PVector(pt.x+ipos, 4, pt.z-1), new PVector(pt.x+ipos, 4+ih, pt.z-1), new PVector(pt.x+ipos, 4+ih, pt.z-1-iw), new PVector(pt.x+ipos, 4, pt.z-1-iw));
            iw = random(1, 1.5);
            ih = random(2, 10);
            ipos = random(2, 14) + 15;
            rettangolo_bianco(new PVector(pt.x+ipos, 4, pt.z-1), new PVector(pt.x+ipos, 4+ih, pt.z-1), new PVector(pt.x+ipos, 4+ih, pt.z-1-iw), new PVector(pt.x+ipos, 4, pt.z-1-iw));
            iw = random(1, 1.5);
            ih = random(2, 10);
            ipos = random(2, 14);
            rettangolo_bianco(new PVector(pt.x-1, 4, pt.z+ipos), new PVector(pt.x-1, 4+ih, pt.z+ipos), new PVector(pt.x-1-iw, 4+ih, pt.z+ipos), new PVector(pt.x-1-iw, 4, pt.z+ipos));
            iw = random(1, 1.5);
            ih = random(2, 10);
            ipos = random(2, 14) + 15;
            rettangolo_bianco(new PVector(pt.x-1, 4, pt.z+ipos), new PVector(pt.x-1, 4+ih, pt.z+ipos), new PVector(pt.x-1-iw, 4+ih, pt.z+ipos), new PVector(pt.x-1-iw, 4, pt.z+ipos));
          }
        }
    
  • // ------------------------------------------------------------

    void basamento(PVector pt, float h) {
      int nr1 = int(random(1, 5));
      int nr2 = int(random(1, 5));
      float inter1 = 27.0 / nr1;
      float inter2 = 27.0 / nr2;
      box3d(pt, new PVector(pt.x+30, h, pt.z+30));
      rettangolo_rigato(new PVector(pt.x, 6, pt.z+2), new PVector(pt.x, h-2, pt.z+2), new PVector(pt.x, h-2, pt.z+28), new PVector(pt.x, 6, pt.z+28));
      for (int i=0; i<nr1; i++) {
        rettangolo_rigato(new PVector(pt.x, 0, pt.z+2+i*inter1), new PVector(pt.x, 4, pt.z+2+i*inter1), new PVector(pt.x, 4, pt.z+1+(i+1)*inter1), new PVector(pt.x, 0, pt.z+1+(i+1)*inter1));
      }
      rettangolo_nero(new PVector(pt.x+2, 6, pt.z), new PVector(pt.x+2, h-2, pt.z), new PVector(pt.x+28, h-2, pt.z), new PVector(pt.x+28, 6, pt.z));
      for (int i=0; i<nr2; i++) {
        rettangolo_nero(new PVector(pt.x+2+i*inter2, 0, pt.z), new PVector(pt.x+2+i*inter2, 4, pt.z), new PVector(pt.x+1+(i+1)*inter2, 4, pt.z), new PVector(pt.x+1+(i+1)*inter2, 0, pt.z));
      }
    }
    
    // ------------------------------------------------------------
    
    void albero(PVector pt0) {
      PVector pt1 = pt0.get();
      pt1.y += 4;
      PVector pt2 = pt1.get();
      pt2.x += 2;
      pt2.z -= 2;
      PVector pp0 = proietta(pt0);
      PVector pp1 = proietta(pt1);
      PVector pp2 = proietta(pt2);
      lista.agg(0, (int)pp1.x, (int)pp1.y);
      lista.agg(6, int(pp2.x-pp1.x), 0);
      dlinea(pp0, pp1);
    }
    
    // ------------------------------------------------------------
    
    void semaforox(PVector pt0) {
      linea(proietta(new PVector(pt0.x -2, 0, pt0.z)), proietta(new PVector(pt0.x -2, 5, pt0.z)));
      linea(proietta(new PVector(pt0.x-28, 0, pt0.z)), proietta(new PVector(pt0.x-28, 5, pt0.z)));
      linea(proietta(new PVector(pt0.x -2, 4, pt0.z)), proietta(new PVector(pt0.x-28, 4, pt0.z)));
      linea(proietta(new PVector(pt0.x -2, 5, pt0.z)), proietta(new PVector(pt0.x-28, 5, pt0.z)));
      rettangolo_bianco(new PVector(pt0.x -4, 4, pt0.z), new PVector(pt0.x -4, 5, pt0.z), new PVector(pt0.x -9, 5, pt0.z), new PVector(pt0.x -9, 4, pt0.z));
      rettangolo_bianco(new PVector(pt0.x-11, 4, pt0.z), new PVector(pt0.x-11, 5, pt0.z), new PVector(pt0.x-19, 5, pt0.z), new PVector(pt0.x-19, 4, pt0.z));
      rettangolo_bianco(new PVector(pt0.x-21, 4, pt0.z), new PVector(pt0.x-21, 5, pt0.z), new PVector(pt0.x-26, 5, pt0.z), new PVector(pt0.x-26, 4, pt0.z));
    }
    
    // ------------------------------------------------------------
    
    void semaforoz(PVector pt0) {
      linea(proietta(new PVector(pt0.x, 0, pt0.z -2)), proietta(new PVector(pt0.x, 5, pt0.z -2)));
      linea(proietta(new PVector(pt0.x, 0, pt0.z-18)), proietta(new PVector(pt0.x, 5, pt0.z-18)));
      linea(proietta(new PVector(pt0.x, 4, pt0.z -2)), proietta(new PVector(pt0.x, 4, pt0.z-18)));
      linea(proietta(new PVector(pt0.x, 5, pt0.z -2)), proietta(new PVector(pt0.x, 5, pt0.z-18)));
      rettangolo_bianco(new PVector(pt0.x, 4, pt0.z -4), new PVector(pt0.x, 5, pt0.z -4), new PVector(pt0.x, 5, pt0.z -9), new PVector(pt0.x, 4, pt0.z -9));
      rettangolo_bianco(new PVector(pt0.x, 4, pt0.z-11), new PVector(pt0.x, 5, pt0.z-11), new PVector(pt0.x, 5, pt0.z-16), new PVector(pt0.x, 4, pt0.z-16));
    }
    
    // ------------------------------------------------------------
    
    void box3d(PVector pt1, PVector pt2) {
      PVector p1 = proietta(new PVector(pt1.x, pt1.y, pt2.z));
      PVector p2 = proietta(new PVector(pt1.x, pt2.y, pt2.z));
      PVector p3 = proietta(new PVector(pt1.x, pt1.y, pt1.z));
      PVector p4 = proietta(new PVector(pt1.x, pt2.y, pt1.z));
      PVector p5 = proietta(new PVector(pt2.x, pt1.y, pt1.z));
      PVector p6 = proietta(new PVector(pt2.x, pt2.y, pt1.z));
      PVector p7 = proietta(new PVector(pt2.x, pt1.y, pt2.z));
    
      lista.agg(3, (int)p1.x, (int)p1.y);
      lista.agg(3, (int)p2.x, (int)p2.y);
      lista.agg(3, (int)p4.x, (int)p4.y);
      lista.agg(3, (int)p6.x, (int)p6.y);
      lista.agg(3, (int)p5.x, (int)p5.y);
      lista.agg(4, (int)p7.x, (int)p7.y);
    
      if (p7.y > p1.y) {
        lista.agg(3, (int)p1.x, (int)p1.y);
        lista.agg(3, (int)p3.x, (int)p3.y);
        lista.agg(3, (int)p5.x, (int)p5.y);
        lista.agg(5, (int)p7.x, (int)p7.y);
      }
    
      dlinea((int)p1.x, (int)p1.y, (int)p3.x, (int)p3.y);
      dlinea((int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y);
      dlinea((int)p2.x, (int)p2.y, (int)p4.x, (int)p4.y);
      dlinea((int)p3.x, (int)p3.y, (int)p4.x, (int)p4.y);
      dlinea((int)p3.x, (int)p3.y, (int)p5.x, (int)p5.y);
      dlinea((int)p5.x, (int)p5.y, (int)p6.x, (int)p6.y);
      dlinea((int)p4.x, (int)p4.y, (int)p6.x, (int)p6.y);
      if (p7.y > p1.y) {
        dlinea((int)p1.x, (int)p1.y, (int)p7.x, (int)p7.y);
        dlinea((int)p5.x, (int)p5.y, (int)p7.x, (int)p7.y);
      }
    
      striscia(pt2.y - pt1.y, p3, p4, p5, p6);
    }
    
    // ------------------------------------------------------------
    
    void cilindro3d(PVector pt, float h, int nrseg, float rad, boolean contorno) {
      PVector [][] pv = new PVector[nrseg][2];
      for (int i=0; i<nrseg; i++) {
        float alfa = map(i, 0, nrseg, 0, TWO_PI);
        pv[i][0] = proietta(new PVector(pt.x+15+rad*cos(alfa), pt.y, pt.z+15-rad*sin(alfa)));
        pv[i][1] = proietta(new PVector(pt.x+15+rad*cos(alfa), pt.y+h, pt.z+15-rad*sin(alfa)));
      }
      for (int i=0; i<nrseg; i++) {
        int j = (i + nrseg - 1) % nrseg;
        if (pv[i][0].x <= pv[j][0].x) {
          if (i > 0) {
            lista.agg(3, (int)pv[j][0].x, (int)pv[j][0].y);
            lista.agg(3, (int)pv[i][0].x, (int)pv[i][0].y);
            lista.agg(3, (int)pv[i][1].x, (int)pv[i][1].y);
            lista.agg(4, (int)pv[j][1].x, (int)pv[j][1].y);
          }
        }
      }
      for (int i=0; i<nrseg; i++) {
        lista.agg(3, (int)pv[i][0].x, (int)pv[i][0].y);
      }
      lista.agg(5, (int)pv[0][0].x, (int)pv[0][0].y);
      for (int i=0; i<nrseg; i++) {
        int j = (i + nrseg - 1) % nrseg;
        float alfa = map(i, 0, nrseg, 0, TWO_PI) + 1;
        if (pv[i][0].x <= pv[j][0].x) {
          if (pv[(i+1)%nrseg][0].x >= pv[i][0].x) {
            linea(pv[i][0], pv[i][1]);
          }
          if (contorno) linea(pv[i][0], pv[i][1]);
          if (i > 0) {
            dlinea(pv[j][0], pv[i][0]);
            dlinea(pv[j][1], pv[i][1]);
            if (sin(alfa) > 0) striscia(h, pv[i][0], pv[i][1], pv[j][0], pv[j][1]);
          }
        }
        else {
          if (pv[(i+1)%nrseg][0].x <= pv[i][0].x) {
            linea(pv[i][0], pv[i][1]);
          }
        }
      }
    }
    
    // ------------------------------------------------------------
    
    void pilotis(PVector pt0, float dex, float dez, float h) {
      int nrx = int((dex - 1) / 6);
      int nrz = int((dez - 1) / 6);
      float delx = (dex-1) / nrx;
      float delz = (dez-1) / nrz;
      for (int i=nrz; i>0; i--) {
        box3d(new PVector(pt0.x, 0, pt0.z+i*delz), new PVector(pt0.x+1, h, pt0.z+i*delz+1));
      }
      for (int i=nrx; i>=0; i--) {
        box3d(new PVector(pt0.x+i*delx, 0, pt0.z), new PVector(pt0.x+i*delx+1, h, pt0.z+1));
      }
    }
    
    // ------------------------------------------------------------
    // striscia tratteggiata in orizzontale
    
    void striscia(float del, PVector p1, PVector p2, PVector p3, PVector p4) {
      float r1 = (p1.y - p2.y) / del;
      float r2 = (p3.y - p4.y) / del;
      float pp = 0;
      while (pp < del) {
        linea(int(p1.x), int(p2.y + pp * r1), int(p3.x), int(p4.y + pp * r2));
        pp += 0.5;
      }
    }
    
    // ------------------------------------------------------------
    
    void rettangolo_bianco(PVector pt1, PVector pt2, PVector pt3, PVector pt4) {
      PVector p1 = proietta(pt1);
      PVector p2 = proietta(pt2);
      PVector p3 = proietta(pt3);
      PVector p4 = proietta(pt4);
      lista.agg(3, (int)p1.x, (int)p1.y);
      lista.agg(3, (int)p2.x, (int)p2.y);
      lista.agg(3, (int)p3.x, (int)p3.y);
      lista.agg(4, (int)p4.x, (int)p4.y);
      linea(p1, p2);
      linea(p2, p3);
      linea(p3, p4);
      linea(p4, p1);
    }
    
    void rettangolo_rigato(PVector pt1, PVector pt2, PVector pt3, PVector pt4) {
      rettangolo_bianco(pt1, pt2, pt3, pt4);
      striscia(pt2.y - pt1.y, proietta(pt1), proietta(pt2), proietta(pt4), proietta(pt3));
    }
    
    void rettangolo_nero(PVector pt1, PVector pt2, PVector pt3, PVector pt4) {
      PVector p1 = proietta(pt1);
      PVector p2 = proietta(pt2);
      PVector p3 = proietta(pt3);
      PVector p4 = proietta(pt4);
      lista.agg(3, (int)p1.x, (int)p1.y);
      lista.agg(3, (int)p2.x, (int)p2.y);
      lista.agg(3, (int)p3.x, (int)p3.y);
      lista.agg(5, (int)p4.x, (int)p4.y);
    }
    
    // ------------------------------------------------------------
    
    // rettangolo pieno
    void rettf(int sx, int sy, int ex, int ey) {
    
      int dex = ex - sx;
      int dey = ey - sy;
      lista.agg(0, sx, sy);
      for (int i=0; i<min(dex, dey); i+=6) {
        lista.agg(1, sx, sy + i);
        lista.agg(1, sx + i, sy);
      }
      if (dex > dey) {
        for (int i=0; i<dex-dey; i+=6) {
          lista.agg(1, sx + i, ey);
          lista.agg(1, sx + dey + i, sy);
        }
      }
      else {
        for (int i=0; i<dey-dex; i+=6) {
          lista.agg(1, sx, sy + dex + i);
          lista.agg(1, ex, sy + i);
        }
      }
      for (int i=min(dex, dey); i>=0; i-=6) {
        lista.agg(1, ex - i, ey);
        lista.agg(1, ex, ey - i);
      }
    }
    
    // ------------------------------------------------------------
    
    void linea(int sx, int sy, int ex, int ey) {
      lista.agg(0, sx, sy);
      lista.agg(1, ex, ey);
    }
    
    void linea(PVector p1, PVector p2) {
      linea((int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y);
    }
    
    // ------------------------------------------------------------
    
    void dlinea(int sx, int sy, int ex, int ey) {
      linea(sx, sy, ex, ey);
      linea(sx, sy, ex, ey);
    }
    
    void dlinea(PVector p1, PVector p2) {
      dlinea((int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y);
    }
    
  • edited December 2014
    // ------------------------------------------------------------
    
    class cLista {
      // by Luca Sassone
      int mat[][] = new int [100000][3];
      int nr = 0;
      PVector [] pv = new PVector[100];
      int nrv = 0;
    
      cLista() {
        for (int i=0; i<pv.length; i++) {
          pv[i] = new PVector(0, 0);
        }
      }
    
      void agg(int tipo, int px, int py) {
        mat[nr][0] = tipo;
        // this would make for the random of the lines which makes it like hand drawn!!!!
        mat[nr][1] = px + 0; // int(random(-de, de)); 
        mat[nr][2] = py + 0; // int(random(-de, de));
        nr++;
      }
    
      void _draw(int el) {
        switch(mat[el][0]) {
        case 0: // move to
          penx = mat[el][1];
          peny = mat[el][2];
          break;
        case 1: // line to
          stroke(0, 0, 0, 0.5);
          noFill();
          line(penx, peny, mat[el][1], mat[el][2]);
          penx = mat[el][1];
          peny = mat[el][2];
          break;
        case 2: // rettangolo pieno
          noStroke();
          fill(0, 0, 1);
          rect(penx, peny, mat[el][1] - penx, mat[el][2] - peny);
          break;
        case 3: // vertice poligono pieno
          pv[nrv].x = mat[el][1];
          pv[nrv].y = mat[el][2];
          nrv++;
          break;
        case 4: // chiusura poligono pieno bianco
          pv[nrv].x = mat[el][1];
          pv[nrv].y = mat[el][2];
          nrv++;
          noStroke();
          fill(0, 0, 1);
          beginShape();
          for (int i=0; i<nrv; i++) {
            vertex(pv[i].x, pv[i].y);
          }
          endShape(CLOSE);
          nrv = 0;
          break;
        case 5: // chiusura poligono pieno nero
          pv[nrv].x = mat[el][1];
          pv[nrv].y = mat[el][2];
          nrv++;
          noStroke();
          fill(0, 0, 0);
          beginShape();
          for (int i=0; i<nrv; i++) {
            vertex(pv[i].x, pv[i].y);
          }
          endShape(CLOSE);
          nrv = 0;
          break;
        case 6: // sfera
          int px0;
          int py0;      
          int px1 = 0;
          int py1 = 0;
          int nrs = height / 6;
          float ra = random(2.1, 2.4);
          noStroke();
          fill(0, 0, 1);
          ellipse(penx, peny, 2*mat[el][1], 2*mat[el][1]);   
          stroke(0, 0, 0, 0.5);
          noFill();
          for (int i=0; i<nrs; i++) {
            float alfa = map(i, 0, nrs, 0, 2 * TWO_PI);
            px0 = px1;
            py0 = py1;
            float rad = mat[el][1] + 2 * de * sin(ra*alfa);
            px1 = penx + int(rad * cos(alfa));
            py1 = peny + int(rad * sin(alfa));
            if (i > 0) {
              line(px0, py0, px1, py1);
            }
          }
          break;
        }
      }
    }
    
    // by Luca Sassone
    // --------------------------------------------------------
    
  • hey thnx a lot mate !! ... its a really great step .....:) ....I will learn your sketch... and yes I never copy .... after some own efforts i prepared a sketch i feel you would love to see tht.. but you will have to install anar library for that ... you can copy paste in ur library folder from this link : https://web.archive.org/web/20140516215519/anar.ch/

    its a first try...

    and here is my script:

    /* Tree house concept by Kartik Jadhav */

    import processing.opengl.*;

    import anar.*;

    void setup() { size(800, 400, OPENGL); Anar.init(this); Anar.drawAxis(true); initForm();

    } Obj form; void initForm() { form = new Obj(); Param div = new Param(2, 2, 10);

    Pts myList = new Pts();

    myList.add(Anar.Pt(-4.5, 0, 0)); myList.add(Anar.Pt(-5, 0, 2)); myList.add(Anar.Pt(-5.5, 0, 4)); myList.add(Anar.Pt(-6, 0, 6)); myList.add(Anar.Pt(-5.2, 0, 8)); myList.add(Anar.Pt(-4, 0, 9)); myList.add(Anar.Pt(-2, 0, 9.5)); myList.add(Anar.Pt(0, 0, 9.5)); myList.add(Anar.Pt(2, 0, 9.5)); myList.add(Anar.Pt(4, 0, 9)); myList.add(Anar.Pt(5.2, 0, 8)); myList.add(Anar.Pt(6, 0, 6)); myList.add(Anar.Pt(5.5, 0, 4)); myList.add(Anar.Pt(5, 0, 2)); myList.add(Anar.Pt(4.5, 0)); myList.add(Anar.Pt(-4.5, 0, 0)); //form.add(myList); myList.scale(10, 10, 10);

    for (int i=0; i<10; i++) { Pts copy1 = new Pts(myList); Pts copy2 = new Pts(copy1); copy1.translate(0, 25, (-sin((i/2.5)-(0.1PI)))10);

    myList = copy1;
    // form.add(copy1);
    for (int j=0; j<copy1.numOfPts()-1;j++) {
    
      Face myFace = new Face();
      myFace.add(copy1.pt(j));
      myFace.add(copy1.pt(j+1));
      myFace.add(copy2.pt(j+1));
      myFace.add(copy2.pt(j));
      myFace.fill(0, random(50, 200), 0);
     // form.add(myFace);
      //myFace.fill(0,random(50,200),0);
      Extrude me = new Extrude(myFace,sin(i/10f)*50);
      //form.add(me);
    
      for (int k=0; k<myFace.numOfPts();k++) {
        Pt a, b, c, d;
        a = myFace.pt(0);
        b = myFace.pt(1);
        c = myFace.pt(2);
        d = myFace.pt(3);
    
        Pts ff = new PtsMid(a, b, div);
        Pts gg = new PtsMid(b, c, div);
        Pts hh = new PtsMid(c, d, div);
        Pts ii = new PtsMid(a, d, div);
        Pts jj = new PtsMid(a, c, div);
    
        Pt f1 = ff.pt(1);
        Pt g1 = gg.pt(1);
        Pt h1 = hh.pt(1);
        Pt i1 = ii.pt(1);
        Pt j1 = jj.pt(1);
        j1.translate(0,0,sin(j/3)*10);
    
        Face kr = new Face(b,j1,a);
        Extrude krr = new Extrude(kr,1);
        form.add(krr);
        krr.fill(100);
    
        Face kr2 = new Face(c,j1,d);
        Extrude krr2 = new Extrude(kr2,1);
        form.add(krr2);
       krr2.fill(170);
    
        Face ks = new Face(f1,g1,h1,i1);
        ks.fill(random(124),109,79);
        form.add(ks);
      }
    }
    

    }

    form.translateZ(100); Anar.camTarget(form); }

    void draw() { background(255); form.draw(); }

  • edited December 2014

    .

  • How to post code

    when you post your code:

    • in the editor hit ctrl-t to auto format

    • copy it

    • paste it in the browser

    • leave 2 empty lines before it

    • mark the code (without the 2 empty lines)

    • press C in the small command bar.

  • edited December 2014

    /* treehouse design by Kartik Jadhav */

    import processing.opengl.*;
    import anar.*;
    void setup() {
      size(800, 400, OPENGL);
      Anar.init(this);
      Anar.drawAxis(true);
      initForm();
    }
    Obj form;
    void initForm() {
      form = new Obj();
      Param div = new Param(2, 2, 10);
      Pts myList = new Pts();
      myList.add(Anar.Pt(-4.5, 0, 0));
      myList.add(Anar.Pt(-5, 0, 2));
      myList.add(Anar.Pt(-5.5, 0, 4));
      myList.add(Anar.Pt(-6, 0, 6));
      myList.add(Anar.Pt(-5.2, 0, 8));
      myList.add(Anar.Pt(-4, 0, 9));
      myList.add(Anar.Pt(-2, 0, 9.5));
      myList.add(Anar.Pt(0, 0, 9.5));
      myList.add(Anar.Pt(2, 0, 9.5));
      myList.add(Anar.Pt(4, 0, 9));
      myList.add(Anar.Pt(5.2, 0, 8));
      myList.add(Anar.Pt(6, 0, 6));
      myList.add(Anar.Pt(5.5, 0, 4));
      myList.add(Anar.Pt(5, 0, 2));
      myList.add(Anar.Pt(4.5, 0));
      myList.add(Anar.Pt(-4.5, 0, 0));
      //form.add(myList);
      myList.scale(10, 10, 10);
     for (int i=0; i<10; i++) {
        Pts copy1 = new Pts(myList);
        Pts copy2 = new Pts(copy1);
        copy1.translate(0, 25, (-sin((i/2.5)-(0.1*PI)))*10);
        myList = copy1;
        // form.add(copy1);
        for (int j=0; j<copy1.numOfPts()-1;j++) {
          Face myFace = new Face();
          myFace.add(copy1.pt(j));
          myFace.add(copy1.pt(j+1));
          myFace.add(copy2.pt(j+1));
          myFace.add(copy2.pt(j));
          myFace.fill(0, random(50, 200), 0);
          // form.add(myFace);
          //myFace.fill(0,random(50,200),0);
          Extrude me = new Extrude(myFace, sin(i/10f)*50);
          // form.add(me);
          for (int k=0; k<myFace.numOfPts();k++) {
            Pt a, b, c, d;
            a = myFace.pt(0);
            b = myFace.pt(1);
            c = myFace.pt(2);
            d = myFace.pt(3);
            Pts ff = new PtsMid(a, b, div);
            Pts gg = new PtsMid(b, c, div);
            Pts hh = new PtsMid(c, d, div);
            Pts ii = new PtsMid(a, d, div);
            Pts jj = new PtsMid(a, c, div);
            Pt f1 = ff.pt(1);
            Pt g1 = gg.pt(1);
            Pt h1 = hh.pt(1);
            Pt i1 = ii.pt(1);
            Pt j1 = jj.pt(1);
            j1.translate(0, 0, sin(j/3)*10);
            Face kr = new Face(b, j1, a);
            Extrude krr = new Extrude(kr, 1);
            form.add(krr);
            krr.fill(100);
            Face kr2 = new Face(c, j1, d);
            Extrude krr2 = new Extrude(kr2, 1);
            form.add(krr2);
            krr2.fill(170);
            Face ks = new Face(f1, g1, h1, i1);
            ks.fill(random(124), 109, 79);
            form.add(ks);
          }
        }
      }
      form.translateZ(100);
      Anar.camTarget(form);
    }
    void draw() {
      background(255);
      form.draw();
    }
    
  • edited December 2014

    .

  • And yes... you will need Processing 1.5.1 to run script... anar library doesn't work on processing 2.

  • This is what I have achieved in 10-15 days.Picture2

  • very impressive!

  • Thanx ... you showed me something that you did in a single day ... that really inspired me a lot.. may be someday I will be able to do that .. thnx for inspiration..

  • you're welcome!

    ;-)

Sign In or Register to comment.