Class CameraInputController
- java.lang.Object
-
- com.badlogic.gdx.InputAdapter
-
- com.badlogic.gdx.input.GestureDetector
-
- com.badlogic.gdx.graphics.g3d.utils.CameraInputController
-
- All Implemented Interfaces:
InputProcessor
public class CameraInputController extends GestureDetector
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classCameraInputController.CameraGestureListener-
Nested classes/interfaces inherited from class com.badlogic.gdx.input.GestureDetector
GestureDetector.GestureAdapter, GestureDetector.GestureListener
-
-
Field Summary
Fields Modifier and Type Field Description intactivateKeyThe key which must be pressed to activate rotate, translate and forward or 0 to always activate.protected booleanactivatePressedIndicates if the activateKey is currently being pressed.booleanalwaysScrollWhether scrolling requires the activeKey to be pressed (false) or always allow scrolling (true).booleanautoUpdateWhether to update the camera after it has been changed.intbackwardKeyprotected booleanbackwardPressedprotected intbuttonThe current (first) button being pressed.CameracameraThe camera.protected booleancontrolsInvertedintforwardButtonThe button for translating the camera along the direction axisintforwardKeyprotected booleanforwardPressedbooleanforwardTargetWhether to update the target on forwardprotected CameraInputController.CameraGestureListenergestureListenerfloatpinchZoomFactorWorld units per screen sizefloatrotateAngleThe angle to rotate when moved the full width or height of the screen.introtateButtonThe button for rotating the camera.introtateLeftKeyprotected booleanrotateLeftPressedintrotateRightKeyprotected booleanrotateRightPressedfloatscrollFactorThe weight for each scrolled amount.booleanscrollTargetWhether to update the target on scrollVector3targetThe target to rotate around.inttranslateButtonThe button for translating the camera along the up/right planebooleantranslateTargetWhether to update the target on translationfloattranslateUnitsThe units to translate the camera when moved the full width or height of the screen.
-
Constructor Summary
Constructors Modifier Constructor Description CameraInputController(Camera camera)protectedCameraInputController(CameraInputController.CameraGestureListener gestureListener, Camera camera)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleankeyDown(int keycode)Called when a key was pressedbooleankeyUp(int keycode)Called when a key was releasedprotected booleanpinchZoom(float amount)protected booleanprocess(float deltaX, float deltaY, int button)booleanscrolled(float amountX, float amountY)Called when the mouse wheel was scrolled.voidsetInvertedControls(boolean invertControls)Sets the CameraInputControllers' control inversion.booleantouchDown(int screenX, int screenY, int pointer, int button)Called when the screen was touched or a mouse button was pressed.booleantouchDragged(int screenX, int screenY, int pointer)Called when a finger or the mouse was dragged.booleantouchUp(int screenX, int screenY, int pointer, int button)Called when a finger was lifted or a mouse button was released.voidupdate()booleanzoom(float amount)-
Methods inherited from class com.badlogic.gdx.input.GestureDetector
cancel, invalidateTapSquare, isLongPressed, isLongPressed, isPanning, reset, setLongPressSeconds, setMaxFlingDelay, setTapCountInterval, setTapRectangleSize, setTapSquareSize, touchCancelled, touchDown, touchDragged, touchUp
-
Methods inherited from class com.badlogic.gdx.InputAdapter
keyTyped, mouseMoved
-
-
-
-
Field Detail
-
rotateButton
public int rotateButton
The button for rotating the camera.
-
rotateAngle
public float rotateAngle
The angle to rotate when moved the full width or height of the screen.
-
translateButton
public int translateButton
The button for translating the camera along the up/right plane
-
translateUnits
public float translateUnits
The units to translate the camera when moved the full width or height of the screen.
-
forwardButton
public int forwardButton
The button for translating the camera along the direction axis
-
activateKey
public int activateKey
The key which must be pressed to activate rotate, translate and forward or 0 to always activate.
-
activatePressed
protected boolean activatePressed
Indicates if the activateKey is currently being pressed.
-
alwaysScroll
public boolean alwaysScroll
Whether scrolling requires the activeKey to be pressed (false) or always allow scrolling (true).
-
scrollFactor
public float scrollFactor
The weight for each scrolled amount.
-
pinchZoomFactor
public float pinchZoomFactor
World units per screen size
-
autoUpdate
public boolean autoUpdate
Whether to update the camera after it has been changed.
-
target
public Vector3 target
The target to rotate around.
-
translateTarget
public boolean translateTarget
Whether to update the target on translation
-
forwardTarget
public boolean forwardTarget
Whether to update the target on forward
-
scrollTarget
public boolean scrollTarget
Whether to update the target on scroll
-
forwardKey
public int forwardKey
-
forwardPressed
protected boolean forwardPressed
-
backwardKey
public int backwardKey
-
backwardPressed
protected boolean backwardPressed
-
rotateRightKey
public int rotateRightKey
-
rotateRightPressed
protected boolean rotateRightPressed
-
rotateLeftKey
public int rotateLeftKey
-
rotateLeftPressed
protected boolean rotateLeftPressed
-
controlsInverted
protected boolean controlsInverted
-
camera
public Camera camera
The camera.
-
button
protected int button
The current (first) button being pressed.
-
gestureListener
protected final CameraInputController.CameraGestureListener gestureListener
-
-
Constructor Detail
-
CameraInputController
protected CameraInputController(CameraInputController.CameraGestureListener gestureListener, Camera camera)
-
CameraInputController
public CameraInputController(Camera camera)
-
-
Method Detail
-
update
public void update()
-
touchDown
public boolean touchDown(int screenX, int screenY, int pointer, int button)Description copied from interface:InputProcessorCalled when the screen was touched or a mouse button was pressed. The button parameter will beInput.Buttons.LEFTon iOS.- Specified by:
touchDownin interfaceInputProcessor- Overrides:
touchDownin classGestureDetector- Parameters:
screenX- The x coordinate, origin is in the upper left cornerscreenY- The y coordinate, origin is in the upper left cornerpointer- the pointer for the event.button- the button- Returns:
- whether the input was processed
-
touchUp
public boolean touchUp(int screenX, int screenY, int pointer, int button)Description copied from interface:InputProcessorCalled when a finger was lifted or a mouse button was released. The button parameter will beInput.Buttons.LEFTon iOS.- Specified by:
touchUpin interfaceInputProcessor- Overrides:
touchUpin classGestureDetectorpointer- the pointer for the event.button- the button- Returns:
- whether the input was processed
-
setInvertedControls
public void setInvertedControls(boolean invertControls)
Sets the CameraInputControllers' control inversion.- Parameters:
invertControls- Whether or not to invert the controls
-
process
protected boolean process(float deltaX, float deltaY, int button)
-
touchDragged
public boolean touchDragged(int screenX, int screenY, int pointer)Description copied from interface:InputProcessorCalled when a finger or the mouse was dragged.- Specified by:
touchDraggedin interfaceInputProcessor- Overrides:
touchDraggedin classGestureDetectorpointer- the pointer for the event.- Returns:
- whether the input was processed
-
scrolled
public boolean scrolled(float amountX, float amountY)Description copied from interface:InputProcessorCalled when the mouse wheel was scrolled. Will not be called on iOS.- Specified by:
scrolledin interfaceInputProcessor- Overrides:
scrolledin classInputAdapter- Parameters:
amountX- the horizontal scroll amount, negative or positive depending on the direction the wheel was scrolled.amountY- the vertical scroll amount, negative or positive depending on the direction the wheel was scrolled.- Returns:
- whether the input was processed.
-
zoom
public boolean zoom(float amount)
-
pinchZoom
protected boolean pinchZoom(float amount)
-
keyDown
public boolean keyDown(int keycode)
Description copied from interface:InputProcessorCalled when a key was pressed- Specified by:
keyDownin interfaceInputProcessor- Overrides:
keyDownin classInputAdapter- Parameters:
keycode- one of the constants inInput.Keys- Returns:
- whether the input was processed
-
keyUp
public boolean keyUp(int keycode)
Description copied from interface:InputProcessorCalled when a key was released- Specified by:
keyUpin interfaceInputProcessor- Overrides:
keyUpin classInputAdapter- Parameters:
keycode- one of the constants inInput.Keys- Returns:
- whether the input was processed
-
-