@Override public void commitEvent(Event event) { if (event instanceof KeyEvent3D) { KeyEvent3D e = (KeyEvent3D) event; if (e.getKeyCode() == KeyEvent.VK_ALT && e.isPressed() && !isInMoveMode()) { enterMoveMode(); } else if (e.getKeyCode() == KeyEvent.VK_ALT && e.isReleased() && isInMoveMode()) { exitMoveMode(); } } }
@Override public void commitEvent(Event event) { LOGGER.warning("Received event: " + event.toString()); if (event instanceof MouseButtonEvent3D) { MouseButtonEvent3D me = ((MouseButtonEvent3D) event); if (me.isPressed()) { MouseEvent awtMouseEvent = (MouseEvent) me.getAwtEvent(); startDragMouse = awtMouseEvent.getPoint(); startDragWorld = me.getIntersectionPointWorld(); startDrag(); } else if (me.isReleased()) { endDrag(); } } else if (event instanceof MouseDraggedEvent3D) { MouseDraggedEvent3D dragEvent = (MouseDraggedEvent3D) event; MouseEvent awtMouseEvent = (MouseEvent) dragEvent.getAwtEvent(); Vector3f endDragWorld = dragEvent.getDragVectorWorld(startDragWorld, startDragMouse, null); if (SwingUtilities.isLeftMouseButton(awtMouseEvent)) { handleMove(startDragWorld, endDragWorld); } else if (SwingUtilities.isRightMouseButton(awtMouseEvent)) { float direction = 1f; if (awtMouseEvent.getX() < startDragMouse.getX()) { direction = -1f; } handleRotate(startDragWorld, endDragWorld, direction); } } else if (event instanceof MouseWheelEvent3D) { MouseWheelEvent3D wheelEvent = (MouseWheelEvent3D) event; int clicks = wheelEvent.getWheelRotation(); // create vector based on unit z and scaled clicks from wheel event. Vector3f delta = new Vector3f(0, 0, clicks * -MOVE_INCREMENT); moveObject(delta); // grab the current camera's rotation. // Quaternion rotation = // ClientContextJME.getViewManager().getCameraTransform().getRotation(null); // apply the rotation to our initial vector // delta = rotation.mult(delta); // apply the delta to any and all selected cells // applyDelta(delta, new Quaternion()); } else if (event instanceof KeyEvent3D) { KeyEvent3D keyEvent = (KeyEvent3D) event; switch (keyEvent.getKeyCode()) { case KeyEvent.VK_MINUS: moveObject(new Vector3f(0, 0, -ZOOM_INCREMENT)); break; case KeyEvent.VK_PLUS: case KeyEvent.VK_EQUALS: moveObject(new Vector3f(0, 0, ZOOM_INCREMENT)); break; case KeyEvent.VK_UP: moveObject(new Vector3f(0, MOVE_INCREMENT, 0)); break; case KeyEvent.VK_DOWN: moveObject(new Vector3f(0, -MOVE_INCREMENT, 0)); break; case KeyEvent.VK_LEFT: moveObject(new Vector3f(MOVE_INCREMENT, 0, 0)); break; case KeyEvent.VK_RIGHT: moveObject(new Vector3f(-MOVE_INCREMENT, 0, 0)); break; } } }