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
3.0
bre..ns 14 years ago
parent 381764a0ec
commit 4b57b7187a
  1. 3
      sdk/jme3-core/src/com/jme3/gde/core/scene/controller/AbstractCameraController.java
  2. 1
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java
  3. 64
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainCameraController.java
  4. 4
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java

@ -44,11 +44,8 @@ import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import java.awt.FocusTraversalPolicy;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.logging.Logger;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
/** /**

@ -27,7 +27,6 @@ package com.jme3.gde.scenecomposer;
import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.gde.core.scene.controller.AbstractCameraController; import com.jme3.gde.core.scene.controller.AbstractCameraController;
import com.jme3.gde.core.sceneexplorer.nodes.JmeNode; import com.jme3.gde.core.sceneexplorer.nodes.JmeNode;
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
import com.jme3.input.KeyInput; import com.jme3.input.KeyInput;
import com.jme3.input.event.KeyInputEvent; import com.jme3.input.event.KeyInputEvent;
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;

@ -57,6 +57,7 @@ public class TerrainCameraController extends AbstractCameraController {
private TerrainToolController toolController; private TerrainToolController toolController;
private TerrainEditorController editorController; private TerrainEditorController editorController;
private boolean forceCameraControls = false; // when user holds shift, this is true 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; private boolean terrainEditToolActivated = false;
protected Application app; protected Application app;
@ -101,60 +102,44 @@ public class TerrainCameraController extends AbstractCameraController {
if ("MouseAxisX".equals(string)) { if ("MouseAxisX".equals(string)) {
moved = true; moved = true;
movedR = true; movedR = true;
if (isTerrainEditButtonEnabled() && !forceCameraControls) { if (useCameraControls || forceCameraControls) {
if (leftMouse) if (buttonDownL) {
terrainEditToolActivated = true;
}
else {
if (leftMouse) {
rotateCamera(Vector3f.UNIT_Y, -f1 * 2.5f); rotateCamera(Vector3f.UNIT_Y, -f1 * 2.5f);
} }
if (rightMouse) { if (buttonDownR) {
panCamera(f1 * 2.5f, 0); panCamera(f1 * 2.5f, 0);
} }
} }
} else if ("MouseAxisY".equals(string)) { } else if ("MouseAxisY".equals(string)) {
moved = true; moved = true;
movedR = true; movedR = true;
if (isTerrainEditButtonEnabled() && !forceCameraControls) { if (useCameraControls || forceCameraControls) {
if (leftMouse) if (buttonDownL) {
terrainEditToolActivated = true;
}
else {
if (leftMouse) {
rotateCamera(cam.getLeft(), -f1 * 2.5f); rotateCamera(cam.getLeft(), -f1 * 2.5f);
} }
if (rightMouse) { if (buttonDownR) {
panCamera(0, -f1 * 2.5f); panCamera(0, -f1 * 2.5f);
} }
} }
} else if ("MouseAxisX-".equals(string)) { } else if ("MouseAxisX-".equals(string)) {
moved = true; moved = true;
movedR = true; movedR = true;
if (isTerrainEditButtonEnabled() && !forceCameraControls) { if (useCameraControls || forceCameraControls) {
if (leftMouse) if (buttonDownL) {
terrainEditToolActivated = true;
}
else {
if (leftMouse) {
rotateCamera(Vector3f.UNIT_Y, f1 * 2.5f); rotateCamera(Vector3f.UNIT_Y, f1 * 2.5f);
} }
if (rightMouse) { if (buttonDownR) {
panCamera(-f1 * 2.5f, 0); panCamera(-f1 * 2.5f, 0);
} }
} }
} else if ("MouseAxisY-".equals(string)) { } else if ("MouseAxisY-".equals(string)) {
moved = true; moved = true;
movedR = true; movedR = true;
if (isTerrainEditButtonEnabled() && !forceCameraControls) { if (useCameraControls || forceCameraControls) {
if (leftMouse) if (buttonDownL) {
terrainEditToolActivated = true;
}
else {
if (leftMouse) {
rotateCamera(cam.getLeft(), f1 * 2.5f); rotateCamera(cam.getLeft(), f1 * 2.5f);
} }
if (rightMouse) { if (buttonDownR) {
panCamera(0, f1 * 2.5f); panCamera(0, f1 * 2.5f);
} }
} }
@ -174,7 +159,7 @@ public class TerrainCameraController extends AbstractCameraController {
@Override @Override
protected void checkClick(int button, boolean pressed) { protected void checkClick(int button, boolean pressed) {
if (button == 0) { /*if (button == 0) {
if (isTerrainEditButtonEnabled() && !forceCameraControls) { if (isTerrainEditButtonEnabled() && !forceCameraControls) {
if (leftMouse) if (leftMouse)
terrainEditToolActivated = true; terrainEditToolActivated = true;
@ -184,7 +169,23 @@ public class TerrainCameraController extends AbstractCameraController {
if (isTerrainEditButtonEnabled() && !forceCameraControls) { if (isTerrainEditButtonEnabled() && !forceCameraControls) {
toolController.doTerrainEditToolAlternateActivated(); toolController.doTerrainEditToolAlternateActivated();
} }
}*/
if (button == 1) {
if (isTerrainEditButtonEnabled() && !forceCameraControls) {
toolController.doTerrainEditToolAlternateActivated();
}
}
}
@Override
protected void checkDragged(int button, boolean pressed) {
terrainEditToolActivated = true;
} }
@Override
protected void checkMoved() {
} }
/** /**
@ -221,6 +222,7 @@ public class TerrainCameraController extends AbstractCameraController {
} }
} }
/** /**
* Find where on the terrain the mouse intersects. * Find where on the terrain the mouse intersects.
*/ */
@ -246,6 +248,10 @@ public class TerrainCameraController extends AbstractCameraController {
return result.getContactPoint(); return result.getContactPoint();
} }
public void setUseCameraControls(boolean useCameraControls) {
this.useCameraControls = useCameraControls;
}

@ -125,7 +125,9 @@ public class TerrainToolController extends SceneToolController {
terrainTool.radiusChanged(toolRadius); terrainTool.radiusChanged(toolRadius);
terrainTool.weightChanged(toolWeight); terrainTool.weightChanged(toolWeight);
terrainTool.activate(manager, toolsNode); terrainTool.activate(manager, toolsNode);
} cameraController.setUseCameraControls(false);
} else
cameraController.setUseCameraControls(true);
} }
public void setEditToolSize(final float size) { public void setEditToolSize(final float size) {

Loading…
Cancel
Save