SDK Scenecomposer : now right clicking will cancel current transformation for the Scale, Rotate and Move Tool, looks like the selectTools shortcut

- improved these tool feedback, its easier to begin the tranformation as its start on the first click instead of the first dragg
experimental
Maselbas 10 years ago
parent 986950fb1d
commit a913d8e0c2
  1. 81
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/MoveTool.java
  2. 69
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/RotateTool.java
  3. 74
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/ScaleTool.java

@ -60,38 +60,7 @@ public class MoveTool extends SceneEditTool {
wasDragging = false; wasDragging = false;
} }
pickManager.reset(); pickManager.reset();
}
}
@Override
public void actionSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject dataObject) {
}
@Override
public void mouseMoved(Vector2f screenCoord, JmeNode rootNode, DataObject currentDataObject, JmeSpatial selectedSpatial) {
if (pickedMarker == null) {
highlightAxisMarker(camera, screenCoord, axisPickType);
} else { } else {
pickedMarker = null;
pickManager.reset();
}
}
@Override
public void draggedPrimary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) {
if (!pressed) {
setDefaultAxisMarkerColors();
pickedMarker = null; // mouse released, reset selection
constraintAxis = Vector3f.UNIT_XYZ; // no constraint
if (wasDragging) {
actionPerformed(new MoveUndo(toolController.getSelectedSpatial(), startPosition, lastPosition));
wasDragging = false;
}
pickManager.reset();
return;
}
if (toolController.getSelectedSpatial() == null) { if (toolController.getSelectedSpatial() == null) {
return; return;
} }
@ -119,8 +88,41 @@ public class MoveTool extends SceneEditTool {
constraintAxis = Vector3f.UNIT_Z; // move only Z constraintAxis = Vector3f.UNIT_Z; // move only Z
} }
startPosition = toolController.getSelectedSpatial().getLocalTranslation().clone(); startPosition = toolController.getSelectedSpatial().getLocalTranslation().clone();
wasDragging = true;
}
}
}
@Override
public void actionSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject dataObject) {
if (pressed) {
cancel();
}
}
@Override
public void mouseMoved(Vector2f screenCoord, JmeNode rootNode, DataObject currentDataObject, JmeSpatial selectedSpatial) {
if (pickedMarker == null) {
highlightAxisMarker(camera, screenCoord, axisPickType);
} else {
pickedMarker = null;
pickManager.reset();
}
} }
@Override
public void draggedPrimary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) {
if (!pressed) {
setDefaultAxisMarkerColors();
pickedMarker = null; // mouse released, reset selection
constraintAxis = Vector3f.UNIT_XYZ; // no constraint
if (wasDragging) {
actionPerformed(new MoveUndo(toolController.getSelectedSpatial(), startPosition, lastPosition));
wasDragging = false;
}
pickManager.reset();
} else if (wasDragging == true) {
if (!pickManager.updatePick(camera, screenCoord)) { if (!pickManager.updatePick(camera, screenCoord)) {
return; return;
} }
@ -135,12 +137,25 @@ public class MoveTool extends SceneEditTool {
lastPosition = position; lastPosition = position;
toolController.getSelectedSpatial().setLocalTranslation(position); toolController.getSelectedSpatial().setLocalTranslation(position);
updateToolsTransformation(); updateToolsTransformation();
}
wasDragging = true;
} }
@Override @Override
public void draggedSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) { public void draggedSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) {
if (pressed) {
cancel();
}
}
private void cancel() {
if (wasDragging) {
wasDragging = false;
toolController.getSelectedSpatial().setLocalTranslation(startPosition);
setDefaultAxisMarkerColors();
pickedMarker = null; // mouse released, reset selection
constraintAxis = Vector3f.UNIT_XYZ; // no constraint
pickManager.reset();
}
} }
protected class MoveUndo extends AbstractUndoableSceneEdit { protected class MoveUndo extends AbstractUndoableSceneEdit {

@ -53,12 +53,36 @@ public class RotateTool extends SceneEditTool {
actionPerformed(new ScaleUndo(toolController.getSelectedSpatial(), startRotate, lastRotate)); actionPerformed(new ScaleUndo(toolController.getSelectedSpatial(), startRotate, lastRotate));
wasDragging = false; wasDragging = false;
} }
pickManager.reset();
} else {
if (toolController.getSelectedSpatial() == null) {
return;
}
if (pickedMarker == null) {
pickedMarker = pickAxisMarker(camera, screenCoord, axisPickType);
if (pickedMarker == null) {
return;
}
if (pickedMarker.equals(QUAD_XY)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY, getTransformType(), camera, screenCoord);
} else if (pickedMarker.equals(QUAD_XZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ, getTransformType(), camera, screenCoord);
} else if (pickedMarker.equals(QUAD_YZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
}
startRotate = toolController.getSelectedSpatial().getLocalRotation().clone();
wasDragging = true;
}
} }
} }
@Override @Override
public void actionSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject dataObject) { public void actionSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject dataObject) {
if (pressed) {
cancel();
}
} }
@Override @Override
@ -67,12 +91,12 @@ public class RotateTool extends SceneEditTool {
highlightAxisMarker(camera, screenCoord, axisPickType); highlightAxisMarker(camera, screenCoord, axisPickType);
} else { } else {
pickedMarker = null; pickedMarker = null;
pickManager.reset();
} }
} }
@Override @Override
public void draggedPrimary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) { public void draggedPrimary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) {
if (!pressed) { if (!pressed) {
setDefaultAxisMarkerColors(); setDefaultAxisMarkerColors();
pickedMarker = null; // mouse released, reset selection pickedMarker = null; // mouse released, reset selection
@ -82,28 +106,8 @@ public class RotateTool extends SceneEditTool {
actionPerformed(new ScaleUndo(toolController.getSelectedSpatial(), startRotate, lastRotate)); actionPerformed(new ScaleUndo(toolController.getSelectedSpatial(), startRotate, lastRotate));
wasDragging = false; wasDragging = false;
} }
return; pickManager.reset();
} } else if (wasDragging) {
if (toolController.getSelectedSpatial() == null) {
return;
}
if (pickedMarker == null) {
pickedMarker = pickAxisMarker(camera, screenCoord, axisPickType);
if (pickedMarker == null) {
return;
}
if (pickedMarker.equals(QUAD_XY)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY, getTransformType(), camera, screenCoord);
} else if (pickedMarker.equals(QUAD_XZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ, getTransformType(), camera, screenCoord);
} else if (pickedMarker.equals(QUAD_YZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
}
startRotate = toolController.getSelectedSpatial().getLocalRotation().clone();
}
if (!pickManager.updatePick(camera, screenCoord)) { if (!pickManager.updatePick(camera, screenCoord)) {
return; return;
} }
@ -114,13 +118,24 @@ public class RotateTool extends SceneEditTool {
lastRotate = rotation; lastRotate = rotation;
} }
updateToolsTransformation(); updateToolsTransformation();
wasDragging = true; }
} }
@Override @Override
public public void draggedSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) {
void draggedSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) { if (pressed) {
cancel();
}
}
private void cancel() {
if (wasDragging) {
wasDragging = false;
toolController.getSelectedSpatial().setLocalRotation(startRotate);
setDefaultAxisMarkerColors();
pickedMarker = null; // mouse released, reset selection
pickManager.reset();
}
} }
private class ScaleUndo extends AbstractUndoableSceneEdit { private class ScaleUndo extends AbstractUndoableSceneEdit {

@ -54,12 +54,40 @@ public class ScaleTool extends SceneEditTool {
wasDragging = false; wasDragging = false;
} }
pickManager.reset(); pickManager.reset();
} else {
if (toolController.getSelectedSpatial() == null) {
return;
}
if (pickedMarker == null) {
pickedMarker = pickAxisMarker(camera, screenCoord, axisPickType);
if (pickedMarker == null) {
return;
}
if (pickedMarker.equals(QUAD_XY) || pickedMarker.equals(QUAD_XZ) || pickedMarker.equals(QUAD_YZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), camera.getRotation(),
SceneComposerToolController.TransformationType.camera, camera, screenCoord);
} else if (pickedMarker.equals(ARROW_X)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_X; // scale only X
} else if (pickedMarker.equals(ARROW_Y)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_Y; // scale only Y
} else if (pickedMarker.equals(ARROW_Z)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_Z; // scale only Z
}
startScale = toolController.getSelectedSpatial().getLocalScale().clone();
wasDragging = true;
}
} }
} }
@Override @Override
public void actionSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject dataObject) { public void actionSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject dataObject) {
if (pressed) {
cancel();
}
} }
@Override @Override
@ -83,34 +111,7 @@ public class ScaleTool extends SceneEditTool {
wasDragging = false; wasDragging = false;
} }
pickManager.reset(); pickManager.reset();
return; } else if (wasDragging) {
}
if (toolController.getSelectedSpatial() == null) {
return;
}
if (pickedMarker == null) {
pickedMarker = pickAxisMarker(camera, screenCoord, axisPickType);
if (pickedMarker == null) {
return;
}
if (pickedMarker.equals(QUAD_XY) || pickedMarker.equals(QUAD_XZ) || pickedMarker.equals(QUAD_YZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), camera.getRotation(),
SceneComposerToolController.TransformationType.camera, camera, screenCoord);
} else if (pickedMarker.equals(ARROW_X)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_X; // scale only X
} else if (pickedMarker.equals(ARROW_Y)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_Y; // scale only Y
} else if (pickedMarker.equals(ARROW_Z)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_Z; // scale only Z
}
startScale = toolController.getSelectedSpatial().getLocalScale().clone();
}
if (!pickManager.updatePick(camera, screenCoord)) { if (!pickManager.updatePick(camera, screenCoord)) {
return; return;
} }
@ -131,13 +132,24 @@ public class ScaleTool extends SceneEditTool {
toolController.getSelectedSpatial().setLocalScale(scale); toolController.getSelectedSpatial().setLocalScale(scale);
} }
updateToolsTransformation(); updateToolsTransformation();
}
wasDragging = true;
} }
@Override @Override
public void draggedSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) { public void draggedSecondary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) {
if (pressed) {
cancel();
}
}
private void cancel() {
if (wasDragging) {
wasDragging = false;
toolController.getSelectedSpatial().setLocalScale(startScale);
setDefaultAxisMarkerColors();
pickedMarker = null; // mouse released, reset selection
pickManager.reset();
}
} }
private class ScaleUndo extends AbstractUndoableSceneEdit { private class ScaleUndo extends AbstractUndoableSceneEdit {

Loading…
Cancel
Save