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