FlyByCamera and ChaseCamera refactored all input mapping constants in a dedicated constant class CameraInput with proper doc

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@11101 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
rem..om 11 years ago
parent 035ed5ebec
commit ae20de9edf
  1. 143
      engine/src/core/com/jme3/input/CameraInput.java
  2. 134
      engine/src/core/com/jme3/input/ChaseCamera.java
  3. 102
      engine/src/core/com/jme3/input/FlyByCamera.java

@ -0,0 +1,143 @@
/*
* Copyright (c) 2009-2012 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme3.input;
/**
* This class defines all the constants used in camera handlers for registration
* with the inputManager
*
* @author Nehon
*/
public class CameraInput {
//ChaseCamera constants
/**
* Chase camera mapping for moving down. Default assigned to
* MouseInput.AXIS_Y direction depending on the invertYaxis configuration
*/
public final static String CHASECAM_DOWN = "ChaseCamDown";
/**
* Chase camera mapping for moving up. Default assigned to MouseInput.AXIS_Y
* direction depending on the invertYaxis configuration
*/
public final static String CHASECAM_UP = "ChaseCamUp";
/**
* Chase camera mapping for zooming in. Default assigned to
* MouseInput.AXIS_WHEEL direction positive
*/
public final static String CHASECAM_ZOOMIN = "ChaseCamZoomIn";
/**
* Chase camera mapping for zooming out. Default assigned to
* MouseInput.AXIS_WHEEL direction negative
*/
public final static String CHASECAM_ZOOMOUT = "ChaseCamZoomOut";
/**
* Chase camera mapping for moving left. Default assigned to
* MouseInput.AXIS_X direction depending on the invertXaxis configuration
*/
public final static String CHASECAM_MOVELEFT = "ChaseCamMoveLeft";
/**
* Chase camera mapping for moving right. Default assigned to
* MouseInput.AXIS_X direction depending on the invertXaxis configuration
*/
public final static String CHASECAM_MOVERIGHT = "ChaseCamMoveRight";
/**
* Chase camera mapping to initiate the rotation of the cam. Default assigned
* to MouseInput.BUTTON_LEFT and MouseInput.BUTTON_RIGHT
*/
public final static String CHASECAM_TOGGLEROTATE = "ChaseCamToggleRotate";
//fly cameara constants
/**
* Fly camera mapping to look left. Default assigned to MouseInput.AXIS_X,
* direction negative
*/
public final static String FLYCAM_LEFT = "FLYCAM_Left";
/**
* Fly camera mapping to look right. Default assigned to MouseInput.AXIS_X,
* direction positive
*/
public final static String FLYCAM_RIGHT = "FLYCAM_Right";
/**
* Fly camera mapping to look up. Default assigned to MouseInput.AXIS_Y,
* direction positive
*/
public final static String FLYCAM_UP = "FLYCAM_Up";
/**
* Fly camera mapping to look down. Default assigned to MouseInput.AXIS_Y,
* direction negative
*/
public final static String FLYCAM_DOWN = "FLYCAM_Down";
/**
* Fly camera mapping to move left. Default assigned to KeyInput.KEY_A
*/
public final static String FLYCAM_STRAFELEFT = "FLYCAM_StrafeLeft";
/**
* Fly camera mapping to move right. Default assigned to KeyInput.KEY_D
*/
public final static String FLYCAM_STRAFERIGHT = "FLYCAM_StrafeRight";
/**
* Fly camera mapping to move forward. Default assigned to KeyInput.KEY_W
*/
public final static String FLYCAM_FORWARD = "FLYCAM_Forward";
/**
* Fly camera mapping to move backward. Default assigned to KeyInput.KEY_S
*/
public final static String FLYCAM_BACKWARD = "FLYCAM_Backward";
/**
* Fly camera mapping to zoom in. Default assigned to MouseInput.AXIS_WHEEL,
* direction positive
*/
public final static String FLYCAM_ZOOMIN = "FLYCAM_ZoomIn";
/**
* Fly camera mapping to zoom in. Default assigned to MouseInput.AXIS_WHEEL,
* direction negative
*/
public final static String FLYCAM_ZOOMOUT = "FLYCAM_ZoomOut";
/**
* Fly camera mapping to toggle rotation. Default assigned to
* MouseInput.BUTTON_LEFT
*/
public final static String FLYCAM_ROTATEDRAG = "FLYCAM_RotateDrag";
/**
* Fly camera mapping to move up. Default assigned to KeyInput.KEY_Q
*/
public final static String FLYCAM_RISE = "FLYCAM_Rise";
/**
* Fly camera mapping to move down. Default assigned to KeyInput.KEY_W
*/
public final static String FLYCAM_LOWER = "FLYCAM_Lower";
public final static String FLYCAM_INVERTY = "FLYCAM_InvertY";
}

@ -99,13 +99,43 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
protected Vector3f temp = new Vector3f(0, 0, 0);
protected boolean invertYaxis = false;
protected boolean invertXaxis = false;
/**
* @deprecated use {@link CameraInput#CHASECAM_DOWN}
*/
@Deprecated
public final static String ChaseCamDown = "ChaseCamDown";
/**
* @deprecated use {@link CameraInput#CHASECAM_UP}
*/
@Deprecated
public final static String ChaseCamUp = "ChaseCamUp";
/**
* @deprecated use {@link CameraInput#CHASECAM_ZOOMIN}
*/
@Deprecated
public final static String ChaseCamZoomIn = "ChaseCamZoomIn";
/**
* @deprecated use {@link CameraInput#CHASECAM_ZOOMOUT}
*/
@Deprecated
public final static String ChaseCamZoomOut = "ChaseCamZoomOut";
/**
* @deprecated use {@link CameraInput#CHASECAM_MOVELEFT}
*/
@Deprecated
public final static String ChaseCamMoveLeft = "ChaseCamMoveLeft";
/**
* @deprecated use {@link CameraInput#CHASECAM_MOVERIGHT}
*/
@Deprecated
public final static String ChaseCamMoveRight = "ChaseCamMoveRight";
/**
* @deprecated use {@link CameraInput#CHASECAM_TOGGLEROTATE}
*/
@Deprecated
public final static String ChaseCamToggleRotate = "ChaseCamToggleRotate";
protected boolean zoomin;
protected boolean hideCursorOnRotate = true;
@ -155,7 +185,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
public void onAction(String name, boolean keyPressed, float tpf) {
if (dragToRotate) {
if (name.equals(ChaseCamToggleRotate) && enabled) {
if (name.equals(CameraInput.CHASECAM_TOGGLEROTATE) && enabled) {
if (keyPressed) {
canRotate = true;
if (hideCursorOnRotate) {
@ -174,21 +204,21 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
public void onAnalog(String name, float value, float tpf) {
if (name.equals(ChaseCamMoveLeft)) {
if (name.equals(CameraInput.CHASECAM_MOVELEFT)) {
rotateCamera(-value);
} else if (name.equals(ChaseCamMoveRight)) {
} else if (name.equals(CameraInput.CHASECAM_MOVERIGHT)) {
rotateCamera(value);
} else if (name.equals(ChaseCamUp)) {
} else if (name.equals(CameraInput.CHASECAM_UP)) {
vRotateCamera(value);
} else if (name.equals(ChaseCamDown)) {
} else if (name.equals(CameraInput.CHASECAM_DOWN)) {
vRotateCamera(-value);
} else if (name.equals(ChaseCamZoomIn)) {
} else if (name.equals(CameraInput.CHASECAM_ZOOMIN)) {
zoomCamera(-value);
if (zoomin == false) {
distanceLerpFactor = 0;
}
zoomin = true;
} else if (name.equals(ChaseCamZoomOut)) {
} else if (name.equals(CameraInput.CHASECAM_ZOOMOUT)) {
zoomCamera(+value);
if (zoomin == true) {
distanceLerpFactor = 0;
@ -203,33 +233,33 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
*/
public final void registerWithInput(InputManager inputManager) {
String[] inputs = {ChaseCamToggleRotate,
ChaseCamDown,
ChaseCamUp,
ChaseCamMoveLeft,
ChaseCamMoveRight,
ChaseCamZoomIn,
ChaseCamZoomOut};
String[] inputs = {CameraInput.CHASECAM_TOGGLEROTATE,
CameraInput.CHASECAM_DOWN,
CameraInput.CHASECAM_UP,
CameraInput.CHASECAM_MOVELEFT,
CameraInput.CHASECAM_MOVERIGHT,
CameraInput.CHASECAM_ZOOMIN,
CameraInput.CHASECAM_ZOOMOUT};
this.inputManager = inputManager;
if (!invertYaxis) {
inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(CameraInput.CHASECAM_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping(CameraInput.CHASECAM_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
} else {
inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping(CameraInput.CHASECAM_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(CameraInput.CHASECAM_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
}
inputManager.addMapping(ChaseCamZoomIn, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
inputManager.addMapping(ChaseCamZoomOut, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
inputManager.addMapping(CameraInput.CHASECAM_ZOOMIN, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
inputManager.addMapping(CameraInput.CHASECAM_ZOOMOUT, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
if (!invertXaxis) {
inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(CameraInput.CHASECAM_MOVELEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(CameraInput.CHASECAM_MOVERIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
} else {
inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(CameraInput.CHASECAM_MOVELEFT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(CameraInput.CHASECAM_MOVERIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
}
inputManager.addMapping(ChaseCamToggleRotate, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addMapping(ChaseCamToggleRotate, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addMapping(CameraInput.CHASECAM_TOGGLEROTATE, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addMapping(CameraInput.CHASECAM_TOGGLEROTATE, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addListener(this, inputs);
}
@ -242,9 +272,9 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
* @param triggers
*/
public void setToggleRotationTrigger(Trigger... triggers) {
inputManager.deleteMapping(ChaseCamToggleRotate);
inputManager.addMapping(ChaseCamToggleRotate, triggers);
inputManager.addListener(this, ChaseCamToggleRotate);
inputManager.deleteMapping(CameraInput.CHASECAM_TOGGLEROTATE);
inputManager.addMapping(CameraInput.CHASECAM_TOGGLEROTATE, triggers);
inputManager.addListener(this, CameraInput.CHASECAM_TOGGLEROTATE);
}
/**
@ -254,9 +284,9 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
* @param triggers
*/
public void setZoomInTrigger(Trigger... triggers) {
inputManager.deleteMapping(ChaseCamZoomIn);
inputManager.addMapping(ChaseCamZoomIn, triggers);
inputManager.addListener(this, ChaseCamZoomIn);
inputManager.deleteMapping(CameraInput.CHASECAM_ZOOMIN);
inputManager.addMapping(CameraInput.CHASECAM_ZOOMIN, triggers);
inputManager.addListener(this, CameraInput.CHASECAM_ZOOMIN);
}
/**
@ -266,9 +296,9 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
* @param triggers
*/
public void setZoomOutTrigger(Trigger... triggers) {
inputManager.deleteMapping(ChaseCamZoomOut);
inputManager.addMapping(ChaseCamZoomOut, triggers);
inputManager.addListener(this, ChaseCamZoomOut);
inputManager.deleteMapping(CameraInput.CHASECAM_ZOOMOUT);
inputManager.addMapping(CameraInput.CHASECAM_ZOOMOUT, triggers);
inputManager.addListener(this, CameraInput.CHASECAM_ZOOMOUT);
}
protected void computePosition() {
@ -581,9 +611,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
* @throws IOException
*/
public void write(JmeExporter ex) throws IOException {
OutputCapsule capsule = ex.getCapsule(this);
capsule.write(maxDistance, "maxDistance", 40);
capsule.write(minDistance, "minDistance", 1);
throw new UnsupportedOperationException("remove ChaseCamera before saving");
}
/**
@ -745,7 +773,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
/**
* Sets the zoom sensitivity, the lower the value, the slower the camera will zoom in and out.
* default is 5.
* default is 2.
* @param zoomSensitivity
*/
public void setZoomSensitivity(float zoomSensitivity) {
@ -910,16 +938,16 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
*/
public void setInvertVerticalAxis(boolean invertYaxis) {
this.invertYaxis = invertYaxis;
inputManager.deleteMapping(ChaseCamDown);
inputManager.deleteMapping(ChaseCamUp);
inputManager.deleteMapping(CameraInput.CHASECAM_DOWN);
inputManager.deleteMapping(CameraInput.CHASECAM_UP);
if (!invertYaxis) {
inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(CameraInput.CHASECAM_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping(CameraInput.CHASECAM_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
} else {
inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping(CameraInput.CHASECAM_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(CameraInput.CHASECAM_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
}
inputManager.addListener(this, ChaseCamDown, ChaseCamUp);
inputManager.addListener(this, CameraInput.CHASECAM_DOWN, CameraInput.CHASECAM_UP);
}
/**
@ -928,15 +956,15 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
*/
public void setInvertHorizontalAxis(boolean invertXaxis) {
this.invertXaxis = invertXaxis;
inputManager.deleteMapping(ChaseCamMoveLeft);
inputManager.deleteMapping(ChaseCamMoveRight);
inputManager.deleteMapping(CameraInput.CHASECAM_MOVELEFT);
inputManager.deleteMapping(CameraInput.CHASECAM_MOVERIGHT);
if (!invertXaxis) {
inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(CameraInput.CHASECAM_MOVELEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(CameraInput.CHASECAM_MOVERIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
} else {
inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(CameraInput.CHASECAM_MOVELEFT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(CameraInput.CHASECAM_MOVERIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
}
inputManager.addListener(this, ChaseCamMoveLeft, ChaseCamMoveRight);
inputManager.addListener(this, CameraInput.CHASECAM_MOVELEFT, CameraInput.CHASECAM_MOVERIGHT);
}
}

@ -53,24 +53,24 @@ import com.jme3.renderer.Camera;
public class FlyByCamera implements AnalogListener, ActionListener {
private static String[] mappings = new String[]{
"FLYCAM_Left",
"FLYCAM_Right",
"FLYCAM_Up",
"FLYCAM_Down",
CameraInput.FLYCAM_LEFT,
CameraInput.FLYCAM_RIGHT,
CameraInput.FLYCAM_UP,
CameraInput.FLYCAM_DOWN,
"FLYCAM_StrafeLeft",
"FLYCAM_StrafeRight",
"FLYCAM_Forward",
"FLYCAM_Backward",
CameraInput.FLYCAM_STRAFELEFT,
CameraInput.FLYCAM_STRAFERIGHT,
CameraInput.FLYCAM_FORWARD,
CameraInput.FLYCAM_BACKWARD,
"FLYCAM_ZoomIn",
"FLYCAM_ZoomOut",
"FLYCAM_RotateDrag",
CameraInput.FLYCAM_ZOOMIN,
CameraInput.FLYCAM_ZOOMOUT,
CameraInput.FLYCAM_ROTATEDRAG,
"FLYCAM_Rise",
"FLYCAM_Lower",
CameraInput.FLYCAM_RISE,
CameraInput.FLYCAM_LOWER,
"FLYCAM_InvertY"
CameraInput.FLYCAM_INVERTY
};
protected Camera cam;
@ -211,30 +211,30 @@ public class FlyByCamera implements AnalogListener, ActionListener {
this.inputManager = inputManager;
// both mouse and button - rotation of cam
inputManager.addMapping("FLYCAM_Left", new MouseAxisTrigger(MouseInput.AXIS_X, true),
inputManager.addMapping(CameraInput.FLYCAM_LEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true),
new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping("FLYCAM_Right", new MouseAxisTrigger(MouseInput.AXIS_X, false),
inputManager.addMapping(CameraInput.FLYCAM_RIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false),
new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping("FLYCAM_Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false),
inputManager.addMapping(CameraInput.FLYCAM_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false),
new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("FLYCAM_Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true),
inputManager.addMapping(CameraInput.FLYCAM_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true),
new KeyTrigger(KeyInput.KEY_DOWN));
// mouse only - zoom in/out with wheel, and rotate drag
inputManager.addMapping("FLYCAM_ZoomIn", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
inputManager.addMapping("FLYCAM_ZoomOut", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
inputManager.addMapping("FLYCAM_RotateDrag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addMapping(CameraInput.FLYCAM_ZOOMIN, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
inputManager.addMapping(CameraInput.FLYCAM_ZOOMOUT, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
inputManager.addMapping(CameraInput.FLYCAM_ROTATEDRAG, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
// keyboard only WASD for movement and WZ for rise/lower height
inputManager.addMapping("FLYCAM_StrafeLeft", new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping("FLYCAM_StrafeRight", new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping("FLYCAM_Forward", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("FLYCAM_Backward", new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping("FLYCAM_Rise", new KeyTrigger(KeyInput.KEY_Q));
inputManager.addMapping("FLYCAM_Lower", new KeyTrigger(KeyInput.KEY_Z));
inputManager.addMapping(CameraInput.FLYCAM_STRAFELEFT, new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping(CameraInput.FLYCAM_STRAFERIGHT, new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping(CameraInput.FLYCAM_FORWARD, new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping(CameraInput.FLYCAM_BACKWARD, new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping(CameraInput.FLYCAM_RISE, new KeyTrigger(KeyInput.KEY_Q));
inputManager.addMapping(CameraInput.FLYCAM_LOWER, new KeyTrigger(KeyInput.KEY_Z));
inputManager.addListener(this, mappings);
inputManager.setCursorVisible(dragToRotate || !isEnabled());
@ -253,26 +253,26 @@ public class FlyByCamera implements AnalogListener, ActionListener {
if( joystick.getAxis( JoystickAxis.Z_ROTATION ) != null && joystick.getAxis( JoystickAxis.Z_AXIS ) != null ) {
// Make the left stick move
joystick.getXAxis().assignAxis( "FLYCAM_StrafeRight", "FLYCAM_StrafeLeft" );
joystick.getYAxis().assignAxis( "FLYCAM_Backward", "FLYCAM_Forward" );
joystick.getXAxis().assignAxis( CameraInput.FLYCAM_STRAFERIGHT, CameraInput.FLYCAM_STRAFELEFT );
joystick.getYAxis().assignAxis( CameraInput.FLYCAM_BACKWARD, CameraInput.FLYCAM_FORWARD );
// And the right stick control the camera
joystick.getAxis( JoystickAxis.Z_ROTATION ).assignAxis( "FLYCAM_Down", "FLYCAM_Up" );
joystick.getAxis( JoystickAxis.Z_AXIS ).assignAxis( "FLYCAM_Right", "FLYCAM_Left" );
joystick.getAxis( JoystickAxis.Z_ROTATION ).assignAxis( CameraInput.FLYCAM_DOWN, CameraInput.FLYCAM_UP );
joystick.getAxis( JoystickAxis.Z_AXIS ).assignAxis( CameraInput.FLYCAM_RIGHT, CameraInput.FLYCAM_LEFT );
// And let the dpad be up and down
joystick.getPovYAxis().assignAxis("FLYCAM_Rise", "FLYCAM_Lower");
joystick.getPovYAxis().assignAxis(CameraInput.FLYCAM_RISE, CameraInput.FLYCAM_LOWER);
if( joystick.getButton( "Button 8" ) != null ) {
// Let the stanard select button be the y invert toggle
joystick.getButton( "Button 8" ).assignButton( "FLYCAM_InvertY" );
joystick.getButton( "Button 8" ).assignButton( CameraInput.FLYCAM_INVERTY );
}
} else {
joystick.getPovXAxis().assignAxis("FLYCAM_StrafeRight", "FLYCAM_StrafeLeft");
joystick.getPovYAxis().assignAxis("FLYCAM_Forward", "FLYCAM_Backward");
joystick.getXAxis().assignAxis("FLYCAM_Right", "FLYCAM_Left");
joystick.getYAxis().assignAxis("FLYCAM_Down", "FLYCAM_Up");
joystick.getPovXAxis().assignAxis(CameraInput.FLYCAM_STRAFERIGHT, CameraInput.FLYCAM_STRAFELEFT);
joystick.getPovYAxis().assignAxis(CameraInput.FLYCAM_FORWARD, CameraInput.FLYCAM_BACKWARD);
joystick.getXAxis().assignAxis(CameraInput.FLYCAM_RIGHT, CameraInput.FLYCAM_LEFT);
joystick.getYAxis().assignAxis(CameraInput.FLYCAM_DOWN, CameraInput.FLYCAM_UP);
}
}
@ -391,29 +391,29 @@ public class FlyByCamera implements AnalogListener, ActionListener {
if (!enabled)
return;
if (name.equals("FLYCAM_Left")){
if (name.equals(CameraInput.FLYCAM_LEFT)){
rotateCamera(value, initialUpVec);
}else if (name.equals("FLYCAM_Right")){
}else if (name.equals(CameraInput.FLYCAM_RIGHT)){
rotateCamera(-value, initialUpVec);
}else if (name.equals("FLYCAM_Up")){
}else if (name.equals(CameraInput.FLYCAM_UP)){
rotateCamera(-value * (invertY ? -1 : 1), cam.getLeft());
}else if (name.equals("FLYCAM_Down")){
}else if (name.equals(CameraInput.FLYCAM_DOWN)){
rotateCamera(value * (invertY ? -1 : 1), cam.getLeft());
}else if (name.equals("FLYCAM_Forward")){
}else if (name.equals(CameraInput.FLYCAM_FORWARD)){
moveCamera(value, false);
}else if (name.equals("FLYCAM_Backward")){
}else if (name.equals(CameraInput.FLYCAM_BACKWARD)){
moveCamera(-value, false);
}else if (name.equals("FLYCAM_StrafeLeft")){
}else if (name.equals(CameraInput.FLYCAM_STRAFELEFT)){
moveCamera(value, true);
}else if (name.equals("FLYCAM_StrafeRight")){
}else if (name.equals(CameraInput.FLYCAM_STRAFERIGHT)){
moveCamera(-value, true);
}else if (name.equals("FLYCAM_Rise")){
}else if (name.equals(CameraInput.FLYCAM_RISE)){
riseCamera(value);
}else if (name.equals("FLYCAM_Lower")){
}else if (name.equals(CameraInput.FLYCAM_LOWER)){
riseCamera(-value);
}else if (name.equals("FLYCAM_ZoomIn")){
}else if (name.equals(CameraInput.FLYCAM_ZOOMIN)){
zoomCamera(value);
}else if (name.equals("FLYCAM_ZoomOut")){
}else if (name.equals(CameraInput.FLYCAM_ZOOMOUT)){
zoomCamera(-value);
}
}
@ -422,10 +422,10 @@ public class FlyByCamera implements AnalogListener, ActionListener {
if (!enabled)
return;
if (name.equals("FLYCAM_RotateDrag") && dragToRotate){
if (name.equals(CameraInput.FLYCAM_ROTATEDRAG) && dragToRotate){
canRotate = value;
inputManager.setCursorVisible(!value);
} else if (name.equals("FLYCAM_InvertY")) {
} else if (name.equals(CameraInput.FLYCAM_INVERTY)) {
// Toggle on the up.
if( !value ) {
invertY = !invertY;

Loading…
Cancel
Save