public void mouseDragged( ViewPanel v, int mod, int buttonNumber, int jpx, int jpy, MouseEvent e) { if (buttonNumber == 3 || ((mod == META_MOD || mod == META_SHIFT_MOD) && buttonNumber == 1)) { Camera c = application.vsm.getActiveCamera(); double a = (c.focal + Math.abs(c.altitude)) / c.focal; if (mod == META_SHIFT_MOD) { application.cam.setXspeed(0); application.cam.setYspeed(0); application.cam.setZspeed( (c.altitude > 0) ? (long) ((lastJPY - jpy) * (a / 50.0f)) : (long) ((lastJPY - jpy) / (a * 50))); // 50 is just a speed factor (too fast otherwise) } else { application.cam.setXspeed( (c.altitude > 0) ? (long) ((jpx - lastJPX) * (a / 50.0f)) : (long) ((jpx - lastJPX) / (a * 50))); application.cam.setYspeed( (c.altitude > 0) ? (long) ((lastJPY - jpy) * (a / 50.0f)) : (long) ((lastJPY - jpy) / (a * 50))); application.cam.setZspeed(0); } } }
public void mouseWheelMoved( ViewPanel v, short wheelDirection, int jpx, int jpy, MouseWheelEvent e) { Camera c = application.vsm.getActiveCamera(); double a = (c.focal + Math.abs(c.altitude)) / c.focal; if (wheelDirection == WHEEL_UP) { c.altitudeOffset(-a * 5); application.vsm.repaint(); } else { // wheelDirection == WHEEL_DOWN c.altitudeOffset(a * 5); application.vsm.repaint(); } }