Class FirstPersonCameraController
- java.lang.Object
-
- com.badlogic.gdx.InputAdapter
-
- com.badlogic.gdx.graphics.g3d.utils.FirstPersonCameraController
-
- All Implemented Interfaces:
InputProcessor
public class FirstPersonCameraController extends InputAdapter
Takes aCamerainstance and controls it via w,a,s,d and mouse panning.
-
-
Field Summary
Fields Modifier and Type Field Description booleanautoUpdateintbackwardKeyprotected Cameracameraprotected floatdegreesPerPixelintdownKeyintforwardKeyprotected IntIntMapkeysintstrafeLeftKeyintstrafeRightKeyprotected Vector3tmpintupKeyprotected floatvelocity
-
Constructor Summary
Constructors Constructor Description FirstPersonCameraController(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 releasedvoidsetDegreesPerPixel(float degreesPerPixel)Sets how many degrees to rotate per pixel the mouse moved.voidsetVelocity(float velocity)Sets the velocity in units per second for moving forward, backward and strafing left/right.booleantouchDragged(int screenX, int screenY, int pointer)Called when a finger or the mouse was dragged.voidupdate()voidupdate(float deltaTime)-
Methods inherited from class com.badlogic.gdx.InputAdapter
keyTyped, mouseMoved, scrolled, touchCancelled, touchDown, touchUp
-
-
-
-
Field Detail
-
camera
protected final Camera camera
-
keys
protected final IntIntMap keys
-
strafeLeftKey
public int strafeLeftKey
-
strafeRightKey
public int strafeRightKey
-
forwardKey
public int forwardKey
-
backwardKey
public int backwardKey
-
upKey
public int upKey
-
downKey
public int downKey
-
autoUpdate
public boolean autoUpdate
-
velocity
protected float velocity
-
degreesPerPixel
protected float degreesPerPixel
-
tmp
protected final Vector3 tmp
-
-
Constructor Detail
-
FirstPersonCameraController
public FirstPersonCameraController(Camera camera)
-
-
Method Detail
-
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
-
setVelocity
public void setVelocity(float velocity)
Sets the velocity in units per second for moving forward, backward and strafing left/right.- Parameters:
velocity- the velocity in units per second
-
setDegreesPerPixel
public void setDegreesPerPixel(float degreesPerPixel)
Sets how many degrees to rotate per pixel the mouse moved.- Parameters:
degreesPerPixel-
-
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 classInputAdapterpointer- the pointer for the event.- Returns:
- whether the input was processed
-
update
public void update()
-
update
public void update(float deltaTime)
-
-