X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FViewer.java;h=1464020b08838da614323dfe697849dd46ca38e0;hp=89ba7b323c76b2b511875c655a216597c53b75e4;hb=0c83217e7d2c100185cca08f5fcd310f2a5347a1;hpb=2a2e64829786ee415fd0c0f16957c55e174b793b diff --git a/src/edu/berkeley/qfat/Viewer.java b/src/edu/berkeley/qfat/Viewer.java index 89ba7b3..1464020 100644 --- a/src/edu/berkeley/qfat/Viewer.java +++ b/src/edu/berkeley/qfat/Viewer.java @@ -18,17 +18,16 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot public Mesh tile = new Mesh(false); public Mesh goal = new Mesh(false); + private int mousex; + private int mousey; private Matrix projection = null; JFrame f; GLCanvas glcanvas; - Point clickPoint = null; + + private Point clickPoint = null; Point clickClosest = null; - int mousex; - int mousey; - float tx = 0; - float ty = 0; float tz = 0; float anglex = 0; float angley = 0; @@ -119,12 +118,16 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot gl.glDrawBuffer(GL.GL_FRONT); } - /** return the position of the mouse as a point in window-space */ public Point getMouse() { return new Point(mousex, glcanvas.getHeight()-mousey, 0); } + /** return the position where the mouse button was pressed, or null if it is not currently pressed */ + public Point getMouseClick() { + return clickPoint; + } + public void mouseWheelMoved(MouseWheelEvent e) { tz -= e.getWheelRotation(); } @@ -166,17 +169,11 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot public void mouseDragged(MouseEvent e) { if (shift) { - /* - tx += (mousex - e.getX())/(float)20; - ty += (mousey - e.getY())/(float)20; - */ if (closest != null && projection != null && clickClosest != null) { synchronized(this) { Vec d1 = projection.inverse().times(getMouse()).minus(projection.inverse().times(clickPoint)); Vec delta = d1.plus(clickClosest).minus(closest.getPoint()); - //System.out.println(delta + " " + closest.getPoint()); - System.out.println(getMouse().minus(clickPoint)); - closest.move(Matrix.translate(delta), false); + closest.move(delta, false); } } } else {