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
This commit is contained in:
parent
986950fb1d
commit
a913d8e0c2
@ -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,38 +53,8 @@ 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();
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draggedPrimary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) {
|
|
||||||
|
|
||||||
if (!pressed) {
|
|
||||||
setDefaultAxisMarkerColors();
|
|
||||||
pickedMarker = null; // mouse released, reset selection
|
|
||||||
lastScreenCoord = null;
|
|
||||||
|
|
||||||
if (wasDragging) {
|
|
||||||
actionPerformed(new ScaleUndo(toolController.getSelectedSpatial(), startRotate, lastRotate));
|
|
||||||
wasDragging = false;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toolController.getSelectedSpatial() == null) {
|
if (toolController.getSelectedSpatial() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -103,7 +73,41 @@ public class RotateTool extends SceneEditTool {
|
|||||||
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
|
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
|
||||||
}
|
}
|
||||||
startRotate = toolController.getSelectedSpatial().getLocalRotation().clone();
|
startRotate = toolController.getSelectedSpatial().getLocalRotation().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
|
||||||
|
lastScreenCoord = null;
|
||||||
|
|
||||||
|
if (wasDragging) {
|
||||||
|
actionPerformed(new ScaleUndo(toolController.getSelectedSpatial(), startRotate, lastRotate));
|
||||||
|
wasDragging = false;
|
||||||
|
}
|
||||||
|
pickManager.reset();
|
||||||
|
} else if (wasDragging) {
|
||||||
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,38 +54,7 @@ public class ScaleTool 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, true);
|
|
||||||
} 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 axis constraint
|
|
||||||
if (wasDragging) {
|
|
||||||
actionPerformed(new ScaleUndo(toolController.getSelectedSpatial(), startScale, lastScale));
|
|
||||||
wasDragging = false;
|
|
||||||
}
|
|
||||||
pickManager.reset();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toolController.getSelectedSpatial() == null) {
|
if (toolController.getSelectedSpatial() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,8 +78,40 @@ public class ScaleTool extends SceneEditTool {
|
|||||||
constraintAxis = Vector3f.UNIT_Z; // scale only Z
|
constraintAxis = Vector3f.UNIT_Z; // scale only Z
|
||||||
}
|
}
|
||||||
startScale = toolController.getSelectedSpatial().getLocalScale().clone();
|
startScale = toolController.getSelectedSpatial().getLocalScale().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, true);
|
||||||
|
} 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 axis constraint
|
||||||
|
if (wasDragging) {
|
||||||
|
actionPerformed(new ScaleUndo(toolController.getSelectedSpatial(), startScale, lastScale));
|
||||||
|
wasDragging = false;
|
||||||
|
}
|
||||||
|
pickManager.reset();
|
||||||
|
} else if (wasDragging) {
|
||||||
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…
x
Reference in New Issue
Block a user