From 4b57b7187aab9c92e7a9162ccc6fe0650a6ef22b Mon Sep 17 00:00:00 2001 From: "bre..ns" Date: Mon, 18 Jul 2011 16:42:43 +0000 Subject: [PATCH] fixed terrain camera controller to use the changes to AbstractCameraController git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7881 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../controller/AbstractCameraController.java | 3 - .../ComposerCameraController.java | 1 - .../TerrainCameraController.java | 64 ++++++++++--------- .../terraineditor/TerrainToolController.java | 4 +- 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/scene/controller/AbstractCameraController.java b/sdk/jme3-core/src/com/jme3/gde/core/scene/controller/AbstractCameraController.java index f5adc8f36..40a44f7d1 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/scene/controller/AbstractCameraController.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/scene/controller/AbstractCameraController.java @@ -44,11 +44,8 @@ import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; -import java.awt.FocusTraversalPolicy; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.logging.Logger; import org.openide.util.Exceptions; /** diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java index a4a7f3eb4..7b273542d 100644 --- a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java +++ b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java @@ -27,7 +27,6 @@ package com.jme3.gde.scenecomposer; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.scene.controller.AbstractCameraController; import com.jme3.gde.core.sceneexplorer.nodes.JmeNode; -import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent; import com.jme3.input.KeyInput; import com.jme3.input.event.KeyInputEvent; import com.jme3.math.Vector2f; diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainCameraController.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainCameraController.java index 9b5e5dec9..9a8e979b3 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainCameraController.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainCameraController.java @@ -57,6 +57,7 @@ public class TerrainCameraController extends AbstractCameraController { private TerrainToolController toolController; private TerrainEditorController editorController; private boolean forceCameraControls = false; // when user holds shift, this is true + private boolean useCameraControls = true; // based on what a tool specifies private boolean terrainEditToolActivated = false; protected Application app; @@ -101,60 +102,44 @@ public class TerrainCameraController extends AbstractCameraController { if ("MouseAxisX".equals(string)) { moved = true; movedR = true; - if (isTerrainEditButtonEnabled() && !forceCameraControls) { - if (leftMouse) - terrainEditToolActivated = true; - } - else { - if (leftMouse) { + if (useCameraControls || forceCameraControls) { + if (buttonDownL) { rotateCamera(Vector3f.UNIT_Y, -f1 * 2.5f); } - if (rightMouse) { + if (buttonDownR) { panCamera(f1 * 2.5f, 0); } } } else if ("MouseAxisY".equals(string)) { moved = true; movedR = true; - if (isTerrainEditButtonEnabled() && !forceCameraControls) { - if (leftMouse) - terrainEditToolActivated = true; - } - else { - if (leftMouse) { + if (useCameraControls || forceCameraControls) { + if (buttonDownL) { rotateCamera(cam.getLeft(), -f1 * 2.5f); } - if (rightMouse) { + if (buttonDownR) { panCamera(0, -f1 * 2.5f); } } } else if ("MouseAxisX-".equals(string)) { moved = true; movedR = true; - if (isTerrainEditButtonEnabled() && !forceCameraControls) { - if (leftMouse) - terrainEditToolActivated = true; - } - else { - if (leftMouse) { + if (useCameraControls || forceCameraControls) { + if (buttonDownL) { rotateCamera(Vector3f.UNIT_Y, f1 * 2.5f); } - if (rightMouse) { + if (buttonDownR) { panCamera(-f1 * 2.5f, 0); } } } else if ("MouseAxisY-".equals(string)) { moved = true; movedR = true; - if (isTerrainEditButtonEnabled() && !forceCameraControls) { - if (leftMouse) - terrainEditToolActivated = true; - } - else { - if (leftMouse) { + if (useCameraControls || forceCameraControls) { + if (buttonDownL) { rotateCamera(cam.getLeft(), f1 * 2.5f); } - if (rightMouse) { + if (buttonDownR) { panCamera(0, f1 * 2.5f); } } @@ -174,18 +159,34 @@ public class TerrainCameraController extends AbstractCameraController { @Override protected void checkClick(int button, boolean pressed) { - if (button == 0) { + /*if (button == 0) { if (isTerrainEditButtonEnabled() && !forceCameraControls) { if (leftMouse) terrainEditToolActivated = true; } } + if (button == 1) { + if (isTerrainEditButtonEnabled() && !forceCameraControls) { + toolController.doTerrainEditToolAlternateActivated(); + } + }*/ + if (button == 1) { if (isTerrainEditButtonEnabled() && !forceCameraControls) { toolController.doTerrainEditToolAlternateActivated(); } } } + + @Override + protected void checkDragged(int button, boolean pressed) { + terrainEditToolActivated = true; + } + + @Override + protected void checkMoved() { + + } /** * Update the terrain if it has had any editing done on it. @@ -221,6 +222,7 @@ public class TerrainCameraController extends AbstractCameraController { } } + /** * Find where on the terrain the mouse intersects. */ @@ -246,6 +248,10 @@ public class TerrainCameraController extends AbstractCameraController { return result.getContactPoint(); } + public void setUseCameraControls(boolean useCameraControls) { + this.useCameraControls = useCameraControls; + } + diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java index 1352dd967..e86819c17 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java @@ -125,7 +125,9 @@ public class TerrainToolController extends SceneToolController { terrainTool.radiusChanged(toolRadius); terrainTool.weightChanged(toolWeight); terrainTool.activate(manager, toolsNode); - } + cameraController.setUseCameraControls(false); + } else + cameraController.setUseCameraControls(true); } public void setEditToolSize(final float size) {