Search in sources :

Example 31 with GLViewer

use of maspack.render.GL.GLViewer in project artisynth_core by artisynth.

the class FemModel3dEditor method rebuildSurfaceMesh.

private void rebuildSurfaceMesh(FemModel3d model) {
    GLViewer v = myMain.getViewer();
    model.createSurfaceMesh(new ClippedElementFilter(v.getClipPlanes()));
}
Also used : GLViewer(maspack.render.GL.GLViewer)

Example 32 with GLViewer

use of maspack.render.GL.GLViewer in project artisynth_core by artisynth.

the class GeometryInertiaPanel method restoreDefaultValues.

public void restoreDefaultValues() {
    myValueChangeHandlerMasked = true;
    GLViewer viewer = Main.getMain().getViewer();
    double width = viewer.distancePerPixel(viewer.getCenter()) * viewer.getScreenWidth() / 6;
    double scale = 1;
    if (width > scale) {
        for (int i = -1; width > scale; i++) {
            scale *= (i % 3 == 0) ? 2.5 : 2.0;
        }
    } else {
        for (int i = -1; width < scale; i++) {
            scale /= (i % 3 == 0) ? 2.5 : 2.0;
        }
    }
    myBoxWidthsField.setValue(new Vector3d(scale, scale, scale));
    myPointRadiusField.setValue(scale / 2);
    myPointSlicesField.setValue(12);
    myMesh = null;
    myMeshFileName = null;
    myMeshFileTransform = null;
    myMeshFileField.setValue(null);
    myMeshXformWidget.setValue(new RigidTransform3d());
    resetMesh();
    myValueChangeHandlerMasked = false;
}
Also used : GLViewer(maspack.render.GL.GLViewer)

Example 33 with GLViewer

use of maspack.render.GL.GLViewer in project artisynth_core by artisynth.

the class PullController method mouseDragged.

public synchronized void mouseDragged(MouseEvent e) {
    if (myDragEnabled) {
        GLViewer viewer = ViewerManager.getViewerFromComponent(e.getComponent());
        if (myComponent != null) {
            // find the world space point
            myPullPos = EditorUtils.intersectWithPlane(getPointPosition(), MouseRayEvent.create(e, viewer));
            if (!myMain.isSimulating()) {
                myMain.rerender();
            }
        }
        myDragOccurred = true;
    }
}
Also used : GLViewer(maspack.render.GL.GLViewer)

Example 34 with GLViewer

use of maspack.render.GL.GLViewer in project artisynth_core by artisynth.

the class PullController method mousePressed.

public synchronized void mousePressed(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1) {
        mySelectionManager.clearSelections();
        GLViewer viewer = ViewerManager.getViewerFromComponent(e.getComponent());
        if (myComponent == null) {
            myPullEvent = MouseRayEvent.create(e, viewer);
        }
        myDragOccurred = false;
        myDragEnabled = true;
    }
}
Also used : GLViewer(maspack.render.GL.GLViewer)

Example 35 with GLViewer

use of maspack.render.GL.GLViewer 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

GLViewer (maspack.render.GL.GLViewer)36 Vector3d (maspack.matrix.Vector3d)9 File (java.io.File)5 RigidTransform3d (maspack.matrix.RigidTransform3d)4 AxisAngle (maspack.matrix.AxisAngle)3 Point3d (maspack.matrix.Point3d)3 GLViewerFrame (maspack.render.GL.GLViewerFrame)3 RigidBody (artisynth.core.mechmodels.RigidBody)2 ExtensionFileFilter (artisynth.core.util.ExtensionFileFilter)2 JFileChooser (javax.swing.JFileChooser)2 FileFilter (javax.swing.filechooser.FileFilter)2 PolygonalMesh (maspack.geometry.PolygonalMesh)2 RotationMatrix3d (maspack.matrix.RotationMatrix3d)2 GLGridPlane (maspack.render.GL.GLGridPlane)2 RenderProps (maspack.render.RenderProps)2 Transrotator3d (maspack.render.Transrotator3d)2 GenericFileFilter (maspack.util.GenericFileFilter)2 InternalErrorException (maspack.util.InternalErrorException)2 ArgParser (argparser.ArgParser)1 IntHolder (argparser.IntHolder)1