Package com.jme3.input
Class FlyByCamera
java.lang.Object
com.jme3.input.FlyByCamera
- All Implemented Interfaces:
- ActionListener,- AnalogListener,- InputListener
A first-person camera controller.
 After creation, you (or FlyCamAppState) must register the controller using
 
registerWithInput(com.jme3.input.InputManager).
 Controls:
  - Move (or, in drag-to-rotate mode, drag) 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 SummaryFieldsModifier and TypeFieldDescriptionprotected Cameracamera controlled by this controller (not null)protected booleanprotected booleandrag-to-rotate mode flagprotected booleanenable flag for controller (false→ignoring input)protected Vector3fnormalized "up" direction (a unit vector)protected InputManagerprotected booleanprotected MotionAllowedListenerprotected floattranslation speed (in world units per second)protected floatrotation-rate multiplier (1=default)protected floatzoom-rate multiplier (1=default)
- 
Constructor SummaryConstructorsConstructorDescriptionFlyByCamera(Camera cam) Creates a new FlyByCamera to control the specified camera.
- 
Method SummaryModifier and TypeMethodDescriptionfloatRead the translation speed.floatRead the rotation-rate multiplier.floatRead the zoom-rate multiplier.booleanTest whether drag-to-rotate mode is enabled.booleanTest whether this controller is enabled.protected voidmapJoystick(Joystick joystick) protected voidmoveCamera(float value, boolean sideways) Translate the camera left or forward by the specified amount.voidCallback to notify this controller of an action input event.voidCallback to notify this controller of an analog input event.voidregisterWithInput(InputManager inputManager) Register this controller to receive input events from the specified input manager.protected voidriseCamera(float value) Translate the camera upward by the specified amount.protected voidrotateCamera(float value, Vector3f axis) Rotate the camera by the specified amount around the specified axis.voidsetDragToRotate(boolean dragToRotate) Enable or disable drag-to-rotate mode.voidsetEnabled(boolean enable) Enable or disable this controller.voidvoidsetMoveSpeed(float moveSpeed) Set the translation speed.voidsetRotationSpeed(float rotationSpeed) Set the rotation-rate multiplier.voidsetUpVector(Vector3f upVec) Sets the up vector that should be used for the camera.voidsetZoomSpeed(float zoomSpeed) Set the zoom-rate multiplier.voidUnregister this controller from its input manager.protected voidzoomCamera(float value) Zoom the camera by the specified amount.
- 
Field Details- 
camcamera controlled by this controller (not null)
- 
initialUpVecnormalized "up" direction (a unit vector)
- 
rotationSpeedprotected float rotationSpeedrotation-rate multiplier (1=default)
- 
moveSpeedprotected float moveSpeedtranslation speed (in world units per second)
- 
zoomSpeedprotected float zoomSpeedzoom-rate multiplier (1=default)
- 
motionAllowed
- 
enabledprotected boolean enabledenable flag for controller (false→ignoring input)
- 
dragToRotateprotected boolean dragToRotatedrag-to-rotate mode flag
- 
canRotateprotected boolean canRotate
- 
invertYprotected boolean invertY
- 
inputManager
 
- 
- 
Constructor Details- 
FlyByCameraCreates a new FlyByCamera to control the specified camera.- Parameters:
- cam- camera to be controlled (not null)
 
 
- 
- 
Method Details- 
setUpVectorSets the up vector that should be used for the camera.- Parameters:
- upVec- the desired direction (not null, unaffected)
 
- 
setMotionAllowedListener
- 
setMoveSpeedpublic void setMoveSpeed(float moveSpeed) Set the translation speed.- Parameters:
- moveSpeed- new speed (in world units per second)
 
- 
getMoveSpeedpublic float getMoveSpeed()Read the translation speed.- Returns:
- current speed (in world units per second)
 
- 
setRotationSpeedpublic void setRotationSpeed(float rotationSpeed) Set the rotation-rate multiplier. The bigger the multiplier, the more rotation for a given movement of the mouse.- Parameters:
- rotationSpeed- new rate multiplier (1=default)
 
- 
getRotationSpeedpublic float getRotationSpeed()Read the rotation-rate multiplier. The bigger the multiplier, the more rotation for a given movement of the mouse.- Returns:
- current rate multiplier (1=default)
 
- 
setZoomSpeedpublic void setZoomSpeed(float zoomSpeed) Set the zoom-rate multiplier. The bigger the multiplier, the more zoom for a given movement of the mouse wheel.- Parameters:
- zoomSpeed- new rate multiplier (1=default)
 
- 
getZoomSpeedpublic float getZoomSpeed()Read the zoom-rate multiplier. The bigger the multiplier, the more zoom for a given movement of the mouse wheel.- Returns:
- current rate multiplier (1=default)
 
- 
setEnabledpublic void setEnabled(boolean enable) Enable or disable this controller. When disabled, the controller ignored input.- Parameters:
- enable- true to enable, false to disable
 
- 
isEnabledpublic boolean isEnabled()Test whether this controller is enabled.- Returns:
- true if enabled, otherwise false
- See Also:
 
- 
isDragToRotatepublic boolean isDragToRotate()Test whether drag-to-rotate mode is enabled.- Returns:
- If drag to rotate feature is enabled.
- See Also:
 
- 
setDragToRotatepublic void setDragToRotate(boolean dragToRotate) Enable or disable drag-to-rotate mode. When drag-to-rotate mode is enabled, the user must hold the mouse button and drag over the screen to rotate the camera, and the cursor is visible until dragged. When drag-to-rotate mode is disabled, the cursor is invisible at all times and holding the mouse button is not needed to rotate the camera. This mode is disabled by default.- Parameters:
- dragToRotate- true to enable, false to disable
 
- 
registerWithInputRegister this controller to receive input events from the specified input manager.- Parameters:
- inputManager- (not null, alias created)
 
- 
mapJoystick
- 
unregisterInputpublic void unregisterInput()Unregister this controller from its input manager.
- 
rotateCameraRotate the camera by the specified amount around the specified axis.- Parameters:
- value- rotation amount
- axis- direction of rotation (a unit vector)
 
- 
zoomCameraprotected void zoomCamera(float value) Zoom the camera by the specified amount.- Parameters:
- value- zoom amount
 
- 
riseCameraprotected void riseCamera(float value) Translate the camera upward by the specified amount.- Parameters:
- value- translation amount
 
- 
moveCameraprotected void moveCamera(float value, boolean sideways) Translate the camera left or forward by the specified amount.- Parameters:
- value- translation amount
- sideways- true→left, false→forward
 
- 
onAnalogCallback to notify this controller of an analog input event.- Specified by:
- onAnalogin interface- AnalogListener
- Parameters:
- name- name of the input event
- value- value of the axis (from 0 to 1)
- tpf- time per frame (in seconds)
 
- 
onActionCallback to notify this controller of an action input event.- Specified by:
- onActionin interface- ActionListener
- Parameters:
- name- name of the input event
- value- true if the action is "pressed", false otherwise
- tpf- time per frame (in seconds)
 
 
-