Search in sources :

Example 1 with ViewerManager

use of artisynth.core.driver.ViewerManager in project artisynth_core by artisynth.

the class RigidBodyAgent method disposePreviewBody.

private void disposePreviewBody() {
    if (body != null) {
        ViewerManager viewerMan = myMain.getWorkspace().getViewerManager();
        viewerMan.removeRenderable(body);
        viewerMan.removeDragger(rotator);
        body = null;
        rotator = null;
        myGeometryPanel.setAttachedBody(null);
        myMain.rerender();
    }
}
Also used : ViewerManager(artisynth.core.driver.ViewerManager)

Example 2 with ViewerManager

use of artisynth.core.driver.ViewerManager in project artisynth_core by artisynth.

the class FemModel3dAgent method actionPerformed.

public void actionPerformed(ActionEvent evt) {
    String cmd = evt.getActionCommand();
    if (cmd.equals("Add")) {
        ViewerManager viewerMan = myMain.getWorkspace().getViewerManager();
        viewerMan.removeRenderable(fem.getSurfaceMesh());
        viewerMan.removeDragger(rotator);
        rotator = null;
        setProperties(fem, getPrototypeComponent(myComponentType));
        // basicPropTree.setTreeValuesInHost (
        // fem, getPrototypeComponent (myComponentType));
        // myPropTree.setTreeValuesInHost (
        // fem, getPrototypeComponent (myComponentType));
        setProperties(myPrototype, myPrototype);
        PolygonalMesh mesh = fem.getSurfaceMesh();
        mesh.setRenderProps(mesh.createRenderProps());
        mesh.setMeshToWorld(RigidTransform3d.IDENTITY);
        mesh.setFixed(false);
        mesh.setColorsFixed(false);
        RigidTransform3d rigidX = new RigidTransform3d();
        rigidX.p.set(positionField.getVectorValue());
        rigidX.R.setAxisAngle(orientationField.getAxisAngleValue());
        AffineTransform3d X = new AffineTransform3d();
        X.set(rigidX);
        Object scale = scaleField.getValue();
        resetScaling();
        double sx = 1, sy = 1, sz = 1;
        if (scale instanceof Double) {
            sx = sy = sz = (Double) scale;
        } else if (scale instanceof Vector3d) {
            sx = ((Vector3d) scale).x;
            sy = ((Vector3d) scale).y;
            sz = ((Vector3d) scale).z;
        }
        X.applyScaling(sx, sy, sz);
        fem.transformGeometry(X);
        addComponent(new AddComponentsCommand("add FemModel3d", fem, myContainer));
        myDisplay.setVisible(false);
        dispose();
    } else if (cmd.equals("Clear")) {
        maskAllValueChangeListeners(true);
        restoreDefaultValues();
        myHostList.restoreBackupValues();
        myPropertyPanel.updateWidgetValues();
        // basicHostList.restoreBackupValues();
        // moreHostList.restoreBackupValues();
        // basicPropsPanel.updateWidgetValues();
        // morePropsPanel.updateWidgetValues();
        disposePreviewModel();
        resetState();
        maskAllValueChangeListeners(false);
        updateMeshPanel();
        updateState();
    } else if (cmd.equals("Cancel")) {
        disposePreviewModel();
        myDisplay.setVisible(false);
        dispose();
    } else if (evt.getSource() == autoScaleBtn) {
        if (fem != null) {
            updateScale();
        }
    } else {
        super.actionPerformed(evt);
    }
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Vector3d(maspack.matrix.Vector3d) ViewerManager(artisynth.core.driver.ViewerManager) PolygonalMesh(maspack.geometry.PolygonalMesh) AffineTransform3d(maspack.matrix.AffineTransform3d)

Example 3 with ViewerManager

use of artisynth.core.driver.ViewerManager in project artisynth_core by artisynth.

the class FemModel3dAgent method disposePreviewModel.

private void disposePreviewModel() {
    if (fem != null) {
        ViewerManager viewerMan = myMain.getWorkspace().getViewerManager();
        viewerMan.removeRenderable(fem.getSurfaceMesh());
        viewerMan.removeDragger(rotator);
        fem.dispose();
        fem = null;
        rotator = null;
        myMain.rerender();
    }
}
Also used : ViewerManager(artisynth.core.driver.ViewerManager)

Example 4 with ViewerManager

use of artisynth.core.driver.ViewerManager in project artisynth_core by artisynth.

the class RigidBodyAgent method actionPerformed.

public void actionPerformed(ActionEvent evt) {
    String cmd = evt.getActionCommand();
    if (cmd.equals("Add")) {
        ViewerManager viewerMan = myMain.getWorkspace().getViewerManager();
        viewerMan.removeRenderable(body);
        viewerMan.removeDragger(rotator);
        rotator = null;
        setProperties(body, getPrototypeComponent(myComponentType));
        // basicPropTree.setTreeValuesInHost (
        // body, getPrototypeComponent (myComponentType));
        // myPropTree.setTreeValuesInHost (
        // body, getPrototypeComponent (myComponentType));
        setProperties(myPrototype, myPrototype);
        myGeometryPanel.setBodyInertia(body);
        body.setRenderProps(body.createRenderProps());
        addComponent(new AddComponentsCommand("add RigidBody", body, (MutableCompositeComponent<?>) myModel.rigidBodies()));
        myDisplay.setVisible(false);
        dispose();
    } else if (cmd.equals("Clear")) {
        maskAllValueChangeListeners(true);
        positionField.setVoidValueEnabled(true);
        positionField.setValue(Property.VoidValue);
        positionField.setVoidValueEnabled(false);
        resetScaling();
        myGeometryPanel.restoreDefaultValues();
        myHostList.restoreBackupValues();
        myPropertyPanel.updateWidgetValues();
        // boolean setDefaults = myPropTree.setSingleEditDefaultValues();
        // resetDefaultProperties();
        // if (setDefaults && myPropertyPanel != null) {
        // myPropertyPanel.updateWidgetValues(/* updateFromSource= */false);
        // }
        // moreHostList.restoreBackupValues();
        // basicHostList.restoreBackupValues ();
        // basicPropsPanel.updateWidgetValues();
        // morePropsPanel.updateWidgetValues();
        disposePreviewBody();
        if (geometrySelector.getValue() == GeometryType.Mesh) {
            fileCheck = false;
        }
        setState(State.SelectingLocation);
        maskAllValueChangeListeners(false);
    } else if (cmd.equals("Cancel")) {
        disposePreviewBody();
        myDisplay.setVisible(false);
        dispose();
    } else if (evt.getSource() == autoScaleBtn) {
        if (body != null) {
            updateScale();
        }
    } else {
        super.actionPerformed(evt);
    }
}
Also used : MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) ViewerManager(artisynth.core.driver.ViewerManager)

Example 5 with ViewerManager

use of artisynth.core.driver.ViewerManager in project artisynth_core by artisynth.

the class RenderProbe method apply.

public void apply(double t) {
    if (myMain != null) {
        myMain.rerender();
        MovieMaker movieMaker = myMain.getMovieMaker();
        if (movieMaker.isGrabbing()) {
            System.out.println("grab at t=" + t);
            ViewerManager vm = myMain.getViewerManager();
            if (vm != null) {
                // HACK. Do this to call prerender *before* the movie maker grab
                // method gets invoked. Otherwise, movie frames may not reflect
                // the most up-to-date state. This will slow down the movie
                // making (by requiring an extra prerender()), but otherwise
                // should work.
                vm.render();
            }
            try {
                movieMaker.grab();
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("ERROR grabbing movie frame");
            }
        }
    }
}
Also used : MovieMaker(artisynth.core.moviemaker.MovieMaker) ViewerManager(artisynth.core.driver.ViewerManager)

Aggregations

ViewerManager (artisynth.core.driver.ViewerManager)6 Scheduler (artisynth.core.driver.Scheduler)1 MutableCompositeComponent (artisynth.core.modelbase.MutableCompositeComponent)1 MovieMaker (artisynth.core.moviemaker.MovieMaker)1 PolygonalMesh (maspack.geometry.PolygonalMesh)1 AffineTransform3d (maspack.matrix.AffineTransform3d)1 RigidTransform3d (maspack.matrix.RigidTransform3d)1 Vector3d (maspack.matrix.Vector3d)1 InternalErrorException (maspack.util.InternalErrorException)1