Search in sources :

Example 1 with SurfaceMeshCollider

use of maspack.collision.SurfaceMeshCollider in project artisynth_core by artisynth.

the class Test method test1.

void test1() {
    GLViewerFrame frame = new GLViewerFrame("collide", 1000, 800);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    GLViewer vw = frame.getViewer();
    frame.setVisible(true);
    KeyHandler keyHandler = new KeyHandler(vw);
    vw.addKeyListener(keyHandler);
    vw.addRenderable(new RenderableAxes());
    case2(frame);
    vw.autoFit();
    mesh1.setRenderBuffered(false);
    // Make sure all faces are included in the hierarchies.
    /*
       * AjlBvTree bvh = mesh0.getBvHierarchy(); for (Face f: mesh0.getFaces())
       * if (!bvh.getRoot().includesFace(f)) throw new RuntimeException("missing
       * face"); bvh = mesh1.getBvHierarchy(); for (Face f: mesh1.getFaces()) if
       * (!bvh.getRoot().includesFace(f)) throw new RuntimeException("missing
       * face");
       */
    // Make sure intersections are consistent.
    /*
       * MeshIntersectionConsistencyTest.testConsistency(mesh0, mesh1);
       * MeshIntersectionConsistencyTest.testConsistency(mesh1, mesh0);
       */
    SurfaceMeshCollider collider = new SurfaceMeshCollider();
    vw.rerender();
    info = collider.getContacts(mesh1, mesh2);
    // if (info != null) vw.addRenderable(info);
    // vw.rerender();
    Vector3d pert = new Vector3d(0.00003, 0, 0);
    for (int i = 0; i < 4e5; i++) {
        // if (info != null) vw.removeRenderable(info);
        if (mesh1.isFixed()) {
            mesh1.getMeshToWorld().p.add(pert);
        } else {
            for (Vertex3d v : mesh1.getVertices()) v.pnt.add(pert);
        }
        mesh1.notifyVertexPositionsModified();
        // mesh1.invalidateWorldCoords();
        // mesh1.invalidateFaceNormals();
        mesh1.updateFaceNormals();
        info = collider.getContacts(mesh1, mesh2);
        // if (info != null) vw.addRenderable(info);
        vw.rerender();
    }
    System.out.println("test done");
    // if (info != null) vw.addRenderable(info);
    vw.rerender();
}
Also used : GLViewer(maspack.render.GL.GLViewer) SurfaceMeshCollider(maspack.collision.SurfaceMeshCollider) Vector3d(maspack.matrix.Vector3d) GLViewerFrame(maspack.render.GL.GLViewerFrame)

Aggregations

SurfaceMeshCollider (maspack.collision.SurfaceMeshCollider)1 Vector3d (maspack.matrix.Vector3d)1 GLViewer (maspack.render.GL.GLViewer)1 GLViewerFrame (maspack.render.GL.GLViewerFrame)1