예제 #1
0
  public void draw() {
    background(0);

    /*    pushMatrix();
        translate(width/2,height/2);
    //    nav.doTransforms();

        translate(-vl.bb().centroid().x,-vl.bb().centroid().y);
        scale(5);
        strokeWeight(0.2f);
        noFill();

        UVertex last=null;
        for(UVertex v:vl) {
          stroke(0);
          v.pellipse(v,0.1f, 0.1f);
          if(last!=null) {
            if(v.dist(last)>15) stroke(200);
            v.pline(v,last);
          }

          last=v;
        }
        popMatrix();
    */
    //    noLights();
    noTint();
    stroke(255, 0, 0);
    //    strokeWeight(2);
    noFill();
    //    translate(100,100);
    translate(width / 2, height / 2);
    nav.doTransforms();
    translate(-img.width / 2, -img.height / 2, -5);

    fill(img.get(300, 300));
    rect(-img.width, -img.height, img.width * 3, img.height * 3);
    translate(0, 0, 5);
    image(img, 0, 0);

    UVertex last = null;
    for (UVertex v : vl) {
      UVertex res = UMapping.mercatorMapping(v, geobb, img.width, img.height);
      fill(255, 100, 0);
      noStroke();
      UMB.pellipse(res, 4);
      stroke(255, 100, 0);
      noFill();
      res.z = 20;
      UMB.pellipse(res, 12);
      //      strokeWeight(0.6f);
      point(res.x, res.y);

      if (last != null) v.pline(res, new UVertex(res.x, res.y, 0));
      last = res;
    }
  }
  public void init() {
    if (main.nav == null) main.nav = new UNav3D();
    UVertex v = new UVertex(1000, 0, 0);
    f = new UFace().set(v.copy(), v.copy().rotY(120 * DEG_TO_RAD), v.copy().rotY(240 * DEG_TO_RAD));
    f.reverse();
    UVertex.rotX(f.getV(), PI / 6);
    UVertex.rotZ(f.getV(), PI * 0.33f);

    UMB.log(f.getV());
    f.rotX(f.rnd(TWO_PI)).rotZ(f.rnd(TWO_PI));
    fv = UIntersections.faceYPlane(f, 0);
    lines = null;
    UMB.log(UMB.str(fv, ' ', null));

    plane = UGeoGenerator.meshPlane(2000, 2000, 20).rotX(HALF_PI);
  }
예제 #3
0
 private void newMap() {
   String prefix = UMB.rnd(mapNames);
   img = loadImage(path + prefix + ".png");
   String[] bb = loadStrings(path + prefix + ".dat");
   geobb[0].set(Float.parseFloat(bb[0]), Float.parseFloat(bb[1]));
   geobb[1].set(Float.parseFloat(bb[2]), Float.parseFloat(bb[3]));
 }
예제 #4
0
  public void setup() {
    size(600, 600);

    build();
    export();
    UMB.setPApplet(this);
  }
예제 #5
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();
  }
예제 #6
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");
  }
  public void draw() {

    p.translate(p.width / 2, p.height / 2);
    p.lights();
    main.nav.doTransforms();

    p.stroke(255);
    //    UMB.ppush().protX(HALF_PI).prect(1000,1000).ppop();
    p.noFill();

    if (f != null) {
      UMB.ppush();
      f.draw().drawNormal(100);
      //      f.pline(f.getV()[0], f.centroid());
      //      f.pline(f.getV()[1], f.centroid());
      //      f.pline(f.getV()[2], f.centroid());
      UMB.ppop();
    }

    if (fv != null) {
      int cnt = 0;
      for (UVertex vv : fv)
        if (vv != null) {
          UMB.pstroke(p.color(255, (cnt++) % 2 * 255, 0));
          UMB.pline(vv, new UVertex());

          UMB.ppush().pstroke(0xffffffff).pfill(0xffff000).pellipse(vv, R, R).ppop();
        }
    }

    plane.draw();
    if (lines != null) drawLines();
    else {

    }
  }
예제 #8
0
  public void export() {
    String filename = sketchPath("test.pdf");

    // create PGraphicsPDF canvas
    PGraphicsPDF pdf = (PGraphicsPDF) createGraphics(500, 500, PDF, filename);

    // get pdf ready to draw
    pdf.beginDraw();
    pdf.translate(pdf.width / 2, pdf.height / 2);

    // tell Modelbuilder to draw to our PDF
    UMB.setGraphics(pdf);
    vl.draw();

    // end draw, close and flush the PDF file
    pdf.endDraw();
    pdf.flush();
    pdf.dispose();
  }
예제 #9
0
  public void setup() {
    size(1000, 1000, OPENGL);
    smooth();

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

    mapNames = new ArrayList<String>();
    String[] s = new File(path).list();
    for (String ss : s)
      if (ss.endsWith(".png")) {
        ss = ss.substring(0, ss.indexOf('.'));
        if (new File(path + ss + ".dat").exists()) {
          mapNames.add(ss);
        }
      }

    img = loadImage(path + "europe.png");
    geobb =
        new UVertex[] {
          new UVertex(56.54f, -12.56f),
          new UVertex(39.88f, 32.34f),
          new UVertex(52.5f, 13.34f),
          new UVertex(51.5f, -0.1f),
          new UVertex(45.44f, 12.34f),
          new UVertex(41.01f, 28.98f)
          //        berlin = mercatorMap.getScreenLocation(new PVector(52.5, 13.34));
          //        london = mercatorMap.getScreenLocation(new PVector(51.5f, -0.1f));
          //        venice = mercatorMap.getScreenLocation(new PVector(45.44, 12.34));
          //        istanbul = mercatorMap.getScreenLocation(new PVector(41.01, 28.98));

        };

    newMap();

    //    geodata=UGeoData.parseOpenPathsCSV(path+"20140123-openpaths-mariuswatz.csv");
    geodata = UMapping.parseFoursquare(path + "20140122 foursquare_historyMW.xml");

    vl = geodata.getPointList();
    smooth();
  }
  private void drawLines() {

    for (int i = 0; i < inter.size(); i++) {
      ii = inter.get(i);
      a = lines.get(i * 2);
      b = lines.get(i * 2 + 1);

      if (ii != null) {
        UMB.pnoFill().pstroke(p.color(255, 255, 0)).pline(a, ii);
        UMB.pstroke(p.color(255, 0, 128)).pline(b, ii);
        p.text(ii.str(), ii.x, 20);
        UMB.ppush().ptranslate(ii);
        p.box(10);
        p.box(1);
        UMB.ppop();

        UMB.ppush().ptranslate(b);
        p.box(5);
        UMB.ppop();

      } else UMB.pstroke(0xffff0000).pline(a, b);
    }
  }