@Test
  public void testAddAFewWindCoordinates() {
    Mesh3D mesh = reader.readGlobe(GlobeType.Full);
    Collection<Face> allFaces = mesh.getFaces();
    int oldCount = allFaces.size();

    TriangleMesh newMesh = new TriangleMesh();
    newMesh.addMesh(mesh);
    // TriangleMesh offers easier access to the faces,
    // unfortunately it is also significantly slower when adding faces

    for (int i = 0; i < 100; i++) {
      Face face = newMesh.faces.get(i);

      Vec3D cloudPoint = face.getCentroid();
      cloudPoint.x += 7;
      cloudPoint.y += 7;
      cloudPoint.z += 7;
      mesh.addFace(cloudPoint, face.a, face.b);
      mesh.addFace(cloudPoint, face.b, face.c);
      mesh.addFace(cloudPoint, face.c, face.a);
    }

    mesh.computeFaceNormals();
    int newCount = mesh.getNumFaces();
    assertFalse(oldCount == newCount);

    String path = getClass().getResource(".").getFile();
    File file = new File(path, "manipulated.stl");
    TriangleMesh meshforWriting = new TriangleMesh();
    meshforWriting.addMesh(mesh);
    writer.write(file, meshforWriting);
  }
Beispiel #2
0
  public void setup() {
    // size(1024, 768);
    /// size(1024, 768, P2D);
    size(1024, 768, OPENGL);
    // size(1440, 900, OPENGL);
    // size(screenWidth, screenHeight, OPENGL); /// have to hard code it if running a standalone

    smooth();

    // load earth texture image
    // earthTex = loadImage("../data/earth_4096.jpg");
    earthTex = loadImage("../data/earth_4096_blue.jpg"); // ../data/earth_outlines.jpg"); //
    // earthTex = loadImage("../data/earth_outlines.png");
    // bgImage = loadImage(bgPathImagePath);

    // build a sphere mesh with texture coordinates
    // sphere resolution set to 36 vertices
    globe = new SurfaceMeshBuilder(new SphereFunction()).createMesh(null, 36, EARTH_RADIUS);
    // compute surface orientation vectors for each mesh vertex
    // this is important for lighting calculations when rendering the mesh
    globe.computeVertexNormals();

    // setup helper class (assign to work with this applet)
    gfx = new ToxiclibsSupport(this);

    /// add the OSC listener object
    oscP5 = new OscP5(this, 8000);

    // initPoly();

    // init our instance of the data profile
    dataProfile = DataProfile.getInstance();
    // set the papplet so we can get to it from any class
    // instead of passing it back and forth like a potato
    dataProfile.pApp = this;

    /// init the popup object
    /// wait to parse the XML
    /// before initializing the video
    thePopUp = new PopupObject();

    //// LOAD XML ///////
    loadXML();
  }