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 aCamera
instance and controls it via w,a,s,d and mouse panning.
-
-
Field Summary
Fields Modifier and Type Field Description boolean
autoUpdate
int
backwardKey
protected Camera
camera
protected float
degreesPerPixel
int
downKey
int
forwardKey
protected IntIntMap
keys
int
strafeLeftKey
int
strafeRightKey
protected Vector3
tmp
int
upKey
protected float
velocity
-
Constructor Summary
Constructors Constructor Description FirstPersonCameraController(Camera camera)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
keyDown(int keycode)
Called when a key was pressedboolean
keyUp(int keycode)
Called when a key was releasedvoid
setDegreesPerPixel(float degreesPerPixel)
Sets how many degrees to rotate per pixel the mouse moved.void
setVelocity(float velocity)
Sets the velocity in units per second for moving forward, backward and strafing left/right.boolean
touchDragged(int screenX, int screenY, int pointer)
Called when a finger or the mouse was dragged.void
update()
void
update(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:InputProcessor
Called when a key was pressed- Specified by:
keyDown
in interfaceInputProcessor
- Overrides:
keyDown
in 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:InputProcessor
Called when a key was released- Specified by:
keyUp
in interfaceInputProcessor
- Overrides:
keyUp
in 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:InputProcessor
Called when a finger or the mouse was dragged.- Specified by:
touchDragged
in interfaceInputProcessor
- Overrides:
touchDragged
in classInputAdapter
pointer
- the pointer for the event.- Returns:
- whether the input was processed
-
update
public void update()
-
update
public void update(float deltaTime)
-
-