|
|
@ -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,18 +159,34 @@ 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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (button == 1) { |
|
|
|
|
|
|
|
if (isTerrainEditButtonEnabled() && !forceCameraControls) { |
|
|
|
|
|
|
|
toolController.doTerrainEditToolAlternateActivated(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
if (button == 1) { |
|
|
|
if (button == 1) { |
|
|
|
if (isTerrainEditButtonEnabled() && !forceCameraControls) { |
|
|
|
if (isTerrainEditButtonEnabled() && !forceCameraControls) { |
|
|
|
toolController.doTerrainEditToolAlternateActivated(); |
|
|
|
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. |
|
|
|
* 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. |
|
|
|
* 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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|