Merge pull request #268 from Dokthar/scenecomposer/master
SDK SceneComposer : right click to cancel current transformation
This commit is contained in:
commit
d3c644123a
@ -357,7 +357,7 @@ public class SceneComposerToolController extends SceneToolController {
|
||||
public void setTransformationType(String type) {
|
||||
if(type != null){
|
||||
if(type.equals("Local")){
|
||||
setTransformationType(transformationType.local);
|
||||
setTransformationType(TransformationType.local);
|
||||
} else if(type.equals("Global")){
|
||||
setTransformationType(TransformationType.global);
|
||||
} else if(type.equals("Camera")){
|
||||
@ -365,15 +365,9 @@ public class SceneComposerToolController extends SceneToolController {
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @return the transformationType
|
||||
*/
|
||||
public TransformationType getTransformationType() {
|
||||
return transformationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param transformationType the transformationType to set
|
||||
* @param type the transformationType to set
|
||||
*/
|
||||
public void setTransformationType(TransformationType type) {
|
||||
if(type != this.transformationType){
|
||||
@ -385,6 +379,13 @@ public class SceneComposerToolController extends SceneToolController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the transformationType
|
||||
*/
|
||||
public TransformationType getTransformationType() {
|
||||
return transformationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* A marker on the screen that shows where a point light or
|
||||
* a spot light is. This marker is not part of the scene,
|
||||
|
@ -60,38 +60,7 @@ public class MoveTool extends SceneEditTool {
|
||||
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 {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@ -119,8 +88,41 @@ public class MoveTool extends SceneEditTool {
|
||||
constraintAxis = Vector3f.UNIT_Z; // move only Z
|
||||
}
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
@ -135,12 +137,25 @@ public class MoveTool extends SceneEditTool {
|
||||
lastPosition = position;
|
||||
toolController.getSelectedSpatial().setLocalTranslation(position);
|
||||
updateToolsTransformation();
|
||||
|
||||
wasDragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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 {
|
||||
|
@ -53,38 +53,8 @@ public class RotateTool extends SceneEditTool {
|
||||
actionPerformed(new ScaleUndo(toolController.getSelectedSpatial(), startRotate, lastRotate));
|
||||
wasDragging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
pickManager.reset();
|
||||
} 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) {
|
||||
return;
|
||||
}
|
||||
@ -103,7 +73,41 @@ public class RotateTool extends SceneEditTool {
|
||||
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
|
||||
}
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
@ -114,13 +118,24 @@ public class RotateTool extends SceneEditTool {
|
||||
lastRotate = rotation;
|
||||
}
|
||||
updateToolsTransformation();
|
||||
wasDragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
@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().setLocalRotation(startRotate);
|
||||
setDefaultAxisMarkerColors();
|
||||
pickedMarker = null; // mouse released, reset selection
|
||||
pickManager.reset();
|
||||
}
|
||||
}
|
||||
|
||||
private class ScaleUndo extends AbstractUndoableSceneEdit {
|
||||
|
@ -54,38 +54,7 @@ public class ScaleTool extends SceneEditTool {
|
||||
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, 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();
|
||||
return;
|
||||
}
|
||||
|
||||
if (toolController.getSelectedSpatial() == null) {
|
||||
return;
|
||||
}
|
||||
@ -109,8 +78,40 @@ public class ScaleTool extends SceneEditTool {
|
||||
constraintAxis = Vector3f.UNIT_Z; // scale only Z
|
||||
}
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
@ -131,13 +132,24 @@ public class ScaleTool extends SceneEditTool {
|
||||
toolController.getSelectedSpatial().setLocalScale(scale);
|
||||
}
|
||||
updateToolsTransformation();
|
||||
|
||||
wasDragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user