com.jme3.input
Class FlyByCamera

java.lang.Object
  extended by com.jme3.input.FlyByCamera
All Implemented Interfaces:
ActionListener, AnalogListener, InputListener

public class FlyByCamera
extends java.lang.Object
implements AnalogListener, ActionListener

A first person view camera controller. After creation, you must register the camera controller with the dispatcher using #registerWithDispatcher(). Controls: - Move the mouse to rotate the camera - Mouse wheel for zooming in or out - WASD keys for moving forward/backward and strafing - QZ keys raise or lower the camera


Field Summary
protected  Camera cam
           
protected  boolean canRotate
           
protected  boolean dragToRotate
           
protected  boolean enabled
           
protected  Vector3f initialUpVec
           
protected  InputManager inputManager
           
protected  MotionAllowedListener motionAllowed
           
protected  float moveSpeed
           
protected  float rotationSpeed
           
 
Constructor Summary
FlyByCamera(Camera cam)
          Creates a new FlyByCamera to control the given Camera object.
 
Method Summary
 float getMoveSpeed()
          Gets the move speed.
 float getRotationSpeed()
          Gets the move speed.
 boolean isDragToRotate()
           
 boolean isEnabled()
           
protected  void moveCamera(float value, boolean sideways)
           
 void onAction(java.lang.String name, boolean value, float tpf)
          Called when an input to which this listener is registered to is invoked.
 void onAnalog(java.lang.String name, float value, float tpf)
          Called to notify the implementation that an analog event has occurred.
 void registerWithInput(InputManager inputManager)
          Registers the FlyByCamera to receive input events from the provided Dispatcher.
protected  void riseCamera(float value)
           
protected  void rotateCamera(float value, Vector3f axis)
           
 void setDragToRotate(boolean dragToRotate)
          Set if drag to rotate mode is enabled.
 void setEnabled(boolean enable)
           
 void setMotionAllowedListener(MotionAllowedListener listener)
           
 void setMoveSpeed(float moveSpeed)
          Sets the move speed.
 void setRotationSpeed(float rotationSpeed)
          Sets the rotation speed.
 void setUpVector(Vector3f upVec)
          Sets the up vector that should be used for the camera.
 void unregisterInput()
          Registers the FlyByCamera to receive input events from the provided Dispatcher.
protected  void zoomCamera(float value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cam

protected Camera cam

initialUpVec

protected Vector3f initialUpVec

rotationSpeed

protected float rotationSpeed

moveSpeed

protected float moveSpeed

motionAllowed

protected MotionAllowedListener motionAllowed

enabled

protected boolean enabled

dragToRotate

protected boolean dragToRotate

canRotate

protected boolean canRotate

inputManager

protected InputManager inputManager
Constructor Detail

FlyByCamera

public FlyByCamera(Camera cam)
Creates a new FlyByCamera to control the given Camera object.

Parameters:
cam -
Method Detail

setUpVector

public void setUpVector(Vector3f upVec)
Sets the up vector that should be used for the camera.

Parameters:
upVec -

setMotionAllowedListener

public void setMotionAllowedListener(MotionAllowedListener listener)

setMoveSpeed

public void setMoveSpeed(float moveSpeed)
Sets the move speed. The speed is given in world units per second.

Parameters:
moveSpeed -

getMoveSpeed

public float getMoveSpeed()
Gets the move speed. The speed is given in world units per second.

Returns:
moveSpeed

setRotationSpeed

public void setRotationSpeed(float rotationSpeed)
Sets the rotation speed.

Parameters:
rotationSpeed -

getRotationSpeed

public float getRotationSpeed()
Gets the move speed. The speed is given in world units per second.

Returns:
rotationSpeed

setEnabled

public void setEnabled(boolean enable)
Parameters:
enable - If false, the camera will ignore input.

isEnabled

public boolean isEnabled()
Returns:
If enabled
See Also:
setEnabled(boolean)

isDragToRotate

public boolean isDragToRotate()
Returns:
If drag to rotate feature is enabled.
See Also:
setDragToRotate(boolean)

setDragToRotate

public void setDragToRotate(boolean dragToRotate)
Set if drag to rotate mode is enabled. When true, the user must hold the mouse button and drag over the screen to rotate the camera, and the cursor is visible until dragged. Otherwise, the cursor is invisible at all times and holding the mouse button is not needed to rotate the camera. This feature is disabled by default.

Parameters:
dragToRotate - True if drag to rotate mode is enabled.

registerWithInput

public void registerWithInput(InputManager inputManager)
Registers the FlyByCamera to receive input events from the provided Dispatcher.

Parameters:
inputManager -

unregisterInput

public void unregisterInput()
Registers the FlyByCamera to receive input events from the provided Dispatcher.

Parameters:
inputManager -

rotateCamera

protected void rotateCamera(float value,
                            Vector3f axis)

zoomCamera

protected void zoomCamera(float value)

riseCamera

protected void riseCamera(float value)

moveCamera

protected void moveCamera(float value,
                          boolean sideways)

onAnalog

public void onAnalog(java.lang.String name,
                     float value,
                     float tpf)
Description copied from interface: AnalogListener
Called to notify the implementation that an analog event has occurred. The results of KeyTrigger and MouseButtonTrigger events will have tpf == value.

Specified by:
onAnalog in interface AnalogListener
Parameters:
name - The name of the mapping that was invoked
value - Value of the axis, from 0 to 1.
tpf - The time per frame value.

onAction

public void onAction(java.lang.String name,
                     boolean value,
                     float tpf)
Description copied from interface: ActionListener
Called when an input to which this listener is registered to is invoked.

Specified by:
onAction in interface ActionListener
Parameters:
name - The name of the mapping that was invoked
value - True if the action is "pressed", false otherwise
tpf - The time per frame value.