Esempio n. 1
0
  void build() {
    filename = "my_tile2.svg";
    shp = RG.loadShape(path + filename);
    shp = RG.centerIn(shp, g, 100);
    UVertexList vl, vl2;
    vl = new UVertexList();
    for (int i = 0; i < 5; i++) vl.add(i, 0);

    vl.close();
    vl.insert(2, vl.get(1));
    println(UMB.str(vl.removeDuplID()));

    println(vl.str());

    // We decided the separation between the polygon points dependent of the mouseX
    float pointSeparation = map(constrain(mouseX, 100, width - 100), 100, width - 100, 4, 20);

    //     We create the polygonized version
    RG.setPolygonizer(RG.UNIFORMLENGTH);
    RG.setPolygonizerLength(pointSeparation);

    polyshp = RG.polygonize(shp);
    poly = polyshp.toPolygon();

    ArrayList<UVertexList> cont = UGeomerative.fromRContour(poly.contours);
    println("contours " + cont.size());

    //    for(UVertexList tmp:cont) {
    //      tmp.removeDupl(true);
    ////      println("isClockwise "+tmp.isClockwise());
    //    }

    //    PGraphicsPDF pdf=(PGraphicsPDF)createGraphics(1000,1000,PDF,path+"test1.pdf");
    //  UMB.setGraphics(pdf);
    //  pdf.beginDraw();
    //  pdf.translate(500,500);
    //  pdf.stroke(0);
    //  geo.draw();
    //  pdf.endDraw();
    //  pdf.flush();
    //  pdf.dispose();

    geo2 = UPoly2Tri.triangulate(cont);

    geo = geo2.copy();
    geo.extrudeSelf(50, true);

    //    geo.removeDuplV().regenerateFaceData();
    geo.writeSTL(path + "test1.stl");
  }
Esempio n. 2
0
  public void setup() {
    size(600, 600, OPENGL);
    smooth();

    UMB.setPApplet(this);
    nav = new UNav3D();

    // VERY IMPORTANT: Allways initialize the library before using it
    RG.init(this);

    if (geo == null) build();
  }
  // ----------------SETUP---------------------------------
  public void setup() {
    size(1200, 800);
    background(0);
    smooth();
    RG.init(this);
    font = new RFont("FreeSans.ttf", 200, CENTER);
    currentDigit = DIGIT_MAX - 1;
    String digit;

    for (int i = 0; i < DIGIT_MAX; i++) {
      digit = String.valueOf(i);
      if (i == 0) {
        digits.add(new AgentText(digit, font));
      } else if (i == 1) {
        digits.add(new MotionText(digit, font));
      } else if (i == 2) {
        digits.add(new JitterText(digit, font));
      } else if (i == 3) {
        digits.add(new SmoothJitterText(digit, font));
      }
    }
  }