en @medialabprado en el Taller de modelado 3D con Processing ow.ly/7yVEv con @oblomobka y @elsatch#parametric #fablab #masterdiwo

a ver que saleeeeeee!uououo

import processing.opengl.*;

import unlekker.util.*;

import unlekker.modelbuilder.*;

MouseNav3D nav;

UGeometry model;

void setup() {

  size(600, 600, OPENGL);

  // add MouseNav3D navigation

  nav=new MouseNav3D(this);

  nav.trans.set(width/2, height/2, 0);

  smooth();

  model = new UGeometry();

  build();

}

void build () {

 float h=15; //Altura de cada cilindro

  float w=200; //ancho

  int numCilindros= 10; //

  int radioBase=100;

  int numPisos=30;

  //llenamos el model con un primer cilindro, este esta en el centro pordefecto:

model.add(Primitive.cylinder (w, h, 10, true ));

  //UGeometry cx=Primitive.cylinder(30, h, 10, true); 

  //cx.translate(100, 0, 0); 

  //model.add (cx); 

  int num=20; //numero de cilindros en cada planta

  for (int n=0; n < num; n++) {

    float r=150;//radio de la circunferencia

    float a=TWO_PI/num * n; //angulo de rotacion

   // h= h+ random(-5,5);

      //Nuevo cilindro de la circunferencia

    for (int i=0; i<numPisos; i++) {

      float alturadeplanta=i*h;

      UGeometry cx2;

      if ( random (1)>0.6)  cx2 = Primitive.cylinder(40, h, 10, true);

      else {

        cx2 = Primitive.cylinder(20, h, 10, true); 

      }

      cx2.translate(r, 15+alturadeplanta, 0); 

      cx2.rotateY(a);

      model.add (cx2);

    }

  }

  //voy a meter otro aro desplazado 30 del eje de x y de las y

  int num2=20; //numero de cilindros en cada planta

  for (int n=0; n < num2; n++) {

    float rr=100;//radio de la circunferencia

    float a=TWO_PI/num2 * n; //angulo de rotacion

      //Nuevo cilindro de la circunferencia

    /*UGeometry cx3=Primitive.cylinder(30, h, 10, true); 

     cx3.translate(rr, 0, 0); 

     cx3.rotateY(a);

     model.add (cx3);*/

  }

    model.center();

}

void draw() {

  background(240, 240, 255);

  lights();

  // call MouseNav3D transforms

  nav.doTransforms();

  model.draw(this);

}

void mouseDragged() {

  nav.mouseDragged();

}

public void keyPressed() {

  nav.keyPressed();

  if (key==’s’) {

    model.writeSTL(this, “Test.stl”);

  }

}