protected synchronized void enterMoveMode() { LOGGER.warning("Enter EZMove mode"); moveMode = true; selected.register(); InputManager inputManager = InputManager.inputManager(); inputManager.addGlobalEventListener(moveListener); // disable events to our avatar inputManager.removeKeyMouseFocus(inputManager.getGlobalFocusEntity()); }
protected synchronized void exitMoveMode() { LOGGER.warning("Leave EZMove mode"); moveMode = false; selected.unregister(); InputManager inputManager = InputManager.inputManager(); inputManager.removeGlobalEventListener(moveListener); // enable events to our avatar inputManager.addKeyMouseFocus(inputManager.getGlobalFocusEntity()); }
protected void applyDelta(Vector3f deltaTranslation, Quaternion deltaRotation) { LOGGER.warning("Applying delta: " + deltaTranslation + " " + deltaRotation); boolean startedDrag = false; if (!dragging) { // no drag in progress. Start one now and end it after the drag // operation startDrag(); startedDrag = true; } for (Cell cell : selected.getSelectedCells()) { CellTransform transform = cell.getLocalTransform(); Vector3f translate = transform.getTranslation(null); Quaternion rotation = transform.getRotation(null); // if the cell has a parent, make sure to take the parent's // rotation and scale into account when applying the delta Vector3f localDeltaTranslation = deltaTranslation.clone(); Cell parent = cell.getParent(); if (parent != null) { CellTransform parentWorld = parent.getWorldTransform(); Quaternion parentRotation = parentWorld.getRotation(null); float parentScale = parentWorld.getScaling(); LOGGER.warning("Parent transform: " + parentWorld); // invert the rotation to get the child rotation parentRotation.inverseLocal(); localDeltaTranslation = parentRotation.mult(deltaTranslation); localDeltaTranslation.multLocal(parentScale); LOGGER.warning("Local delta translation: " + localDeltaTranslation); } translate.addLocal(localDeltaTranslation); rotation.multLocal(deltaRotation); transform.setTranslation(translate); transform.setRotation(rotation); MovableComponent mc = getMovable(cell); if (mc != null) { mc.localMoveRequest(transform); } } lastTranslation.addLocal(deltaTranslation); lastRotation.multLocal(deltaRotation); // if we started a drag, remember to end it if (startedDrag) { endDrag(); } }