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();
}
}
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);
}
}
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();
}
}
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);
}
}
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");
}
}
}
}
Aggregations