SDK :
- applied changes of the core to terraineditor git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7931 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
b8025984a0
commit
3b47418f4f
@ -44,7 +44,6 @@ import com.jme3.math.Vector2f;
|
|||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs in the JME thread, not awt thread.
|
* Runs in the JME thread, not awt thread.
|
||||||
* Listens to mouse/camera input and relays the movements
|
* Listens to mouse/camera input and relays the movements
|
||||||
@ -58,7 +57,6 @@ public class TerrainCameraController extends AbstractCameraController {
|
|||||||
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 useCameraControls = true; // based on what a tool specifies
|
||||||
|
|
||||||
private boolean terrainEditToolActivated = false;
|
private boolean terrainEditToolActivated = false;
|
||||||
protected Application app;
|
protected Application app;
|
||||||
private float toolModifyRate = 0.05f; // how frequently (in seconds) it should update to throttle down the tool effect
|
private float toolModifyRate = 0.05f; // how frequently (in seconds) it should update to throttle down the tool effect
|
||||||
@ -77,79 +75,27 @@ public class TerrainCameraController extends AbstractCameraController {
|
|||||||
this.editorController = editorController;
|
this.editorController = editorController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMouseMotionEvent(MouseMotionEvent mme) {
|
public void onMouseMotionEvent(MouseMotionEvent mme) {
|
||||||
super.onMouseMotionEvent(mme);
|
super.onMouseMotionEvent(mme);
|
||||||
|
|
||||||
|
|
||||||
// if one of the terrain edit buttons is not enabled, return
|
// if one of the terrain edit buttons is not enabled, return
|
||||||
if (!isTerrainEditButtonEnabled())
|
if (!isTerrainEditButtonEnabled()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// move the marker
|
// move the marker
|
||||||
Vector3f pos = getTerrainCollisionPoint();
|
Vector3f pos = getTerrainCollisionPoint();
|
||||||
if (pos != null)
|
if (pos != null) {
|
||||||
toolController.doMoveEditTool(pos);
|
toolController.doMoveEditTool(pos);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isTerrainEditButtonEnabled() {
|
private boolean isTerrainEditButtonEnabled() {
|
||||||
return toolController.isTerrainEditButtonEnabled();
|
return toolController.isTerrainEditButtonEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnalog(String string, float f1, float f) {
|
|
||||||
if ("MouseAxisX".equals(string)) {
|
|
||||||
moved = true;
|
|
||||||
movedR = true;
|
|
||||||
if (useCameraControls || forceCameraControls) {
|
|
||||||
if (buttonDownL) {
|
|
||||||
rotateCamera(Vector3f.UNIT_Y, -f1 * 2.5f);
|
|
||||||
}
|
|
||||||
if (buttonDownR) {
|
|
||||||
panCamera(f1 * 2.5f, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ("MouseAxisY".equals(string)) {
|
|
||||||
moved = true;
|
|
||||||
movedR = true;
|
|
||||||
if (useCameraControls || forceCameraControls) {
|
|
||||||
if (buttonDownL) {
|
|
||||||
rotateCamera(cam.getLeft(), -f1 * 2.5f);
|
|
||||||
}
|
|
||||||
if (buttonDownR) {
|
|
||||||
panCamera(0, -f1 * 2.5f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ("MouseAxisX-".equals(string)) {
|
|
||||||
moved = true;
|
|
||||||
movedR = true;
|
|
||||||
if (useCameraControls || forceCameraControls) {
|
|
||||||
if (buttonDownL) {
|
|
||||||
rotateCamera(Vector3f.UNIT_Y, f1 * 2.5f);
|
|
||||||
}
|
|
||||||
if (buttonDownR) {
|
|
||||||
panCamera(-f1 * 2.5f, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ("MouseAxisY-".equals(string)) {
|
|
||||||
moved = true;
|
|
||||||
movedR = true;
|
|
||||||
if (useCameraControls || forceCameraControls) {
|
|
||||||
if (buttonDownL) {
|
|
||||||
rotateCamera(cam.getLeft(), f1 * 2.5f);
|
|
||||||
}
|
|
||||||
if (buttonDownR) {
|
|
||||||
panCamera(0, f1 * 2.5f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ("MouseWheel".equals(string)) {
|
|
||||||
zoomCamera(.1f);
|
|
||||||
} else if ("MouseWheel-".equals(string)) {
|
|
||||||
zoomCamera(-.1f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float f) {
|
public void update(float f) {
|
||||||
super.update(f);
|
super.update(f);
|
||||||
@ -159,12 +105,13 @@ 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)
|
|
||||||
terrainEditToolActivated = true;
|
terrainEditToolActivated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button == 1) {
|
if (button == 1) {
|
||||||
if (isTerrainEditButtonEnabled() && !forceCameraControls) {
|
if (isTerrainEditButtonEnabled() && !forceCameraControls) {
|
||||||
toolController.doTerrainEditToolAlternateActivated();
|
toolController.doTerrainEditToolAlternateActivated();
|
||||||
@ -180,12 +127,13 @@ public class TerrainCameraController extends AbstractCameraController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkDragged(int button, boolean pressed) {
|
protected void checkDragged(int button, boolean pressed) {
|
||||||
|
if (button == 0 && !forceCameraControls) {
|
||||||
terrainEditToolActivated = true;
|
terrainEditToolActivated = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkMoved() {
|
protected void checkMoved() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -201,8 +149,9 @@ public class TerrainCameraController extends AbstractCameraController {
|
|||||||
if (lastModifyTime >= toolModifyRate) {
|
if (lastModifyTime >= toolModifyRate) {
|
||||||
|
|
||||||
lastModifyTime = 0;
|
lastModifyTime = 0;
|
||||||
if (terrainEditToolActivated)
|
if (terrainEditToolActivated) {
|
||||||
toolController.doTerrainEditToolActivated();
|
toolController.doTerrainEditToolActivated();
|
||||||
|
}
|
||||||
terrainEditToolActivated = false;
|
terrainEditToolActivated = false;
|
||||||
lastModifyTime = app.getContext().getTimer().getTime();
|
lastModifyTime = app.getContext().getTimer().getTime();
|
||||||
}
|
}
|
||||||
@ -211,6 +160,7 @@ public class TerrainCameraController extends AbstractCameraController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onKeyEvent(KeyInputEvent kie) {
|
public void onKeyEvent(KeyInputEvent kie) {
|
||||||
|
super.onKeyEvent(kie);
|
||||||
if (kie.isPressed()) {
|
if (kie.isPressed()) {
|
||||||
if (KeyInput.KEY_LSHIFT == kie.getKeyCode()) {
|
if (KeyInput.KEY_LSHIFT == kie.getKeyCode()) {
|
||||||
forceCameraControls = true;
|
forceCameraControls = true;
|
||||||
@ -222,14 +172,14 @@ public class TerrainCameraController extends AbstractCameraController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find where on the terrain the mouse intersects.
|
* Find where on the terrain the mouse intersects.
|
||||||
*/
|
*/
|
||||||
protected Vector3f getTerrainCollisionPoint() {
|
protected Vector3f getTerrainCollisionPoint() {
|
||||||
|
|
||||||
if (editorController.getTerrain(null) == null)
|
if (editorController.getTerrain(null) == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
CollisionResults results = new CollisionResults();
|
CollisionResults results = new CollisionResults();
|
||||||
Ray ray = new Ray();
|
Ray ray = new Ray();
|
||||||
@ -243,8 +193,9 @@ public class TerrainCameraController extends AbstractCameraController {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final CollisionResult result = results.getClosestCollision();
|
final CollisionResult result = results.getClosestCollision();
|
||||||
if (result == null)
|
if (result == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return result.getContactPoint();
|
return result.getContactPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +203,8 @@ public class TerrainCameraController extends AbstractCameraController {
|
|||||||
this.useCameraControls = useCameraControls;
|
this.useCameraControls = useCameraControls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useCameraControls() {
|
||||||
|
return useCameraControls || forceCameraControls;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user