com.jme.input.thirdperson
Class ThirdPersonMouseLook

java.lang.Object
  extended by com.jme.input.action.InputAction
      extended by com.jme.input.action.MouseInputAction
          extended by com.jme.input.thirdperson.ThirdPersonMouseLook
All Implemented Interfaces:
InputActionInterface

public class ThirdPersonMouseLook
extends MouseInputAction


Field Summary
protected  ChaseCamera camera
           
static boolean DEFAULT_ENABLED
           
static boolean DEFAULT_INVERTEDY
           
static boolean DEFAULT_INVERTROTATE
           
static boolean DEFAULT_LOCKASCENT
           
static float DEFAULT_MAXASCENT
           
static float DEFAULT_MAXROLLOUT
           
static float DEFAULT_MINASCENT
           
static float DEFAULT_MINROLLOUT
           
static int DEFAULT_MOUSEBUTTON_FOR_LOOKING
           
static float DEFAULT_MOUSEROLLMULT
           
static float DEFAULT_MOUSEXMULT
           
static float DEFAULT_MOUSEYMULT
           
static boolean DEFAULT_ROTATETARGET
           
static float DEFAULT_TARGETTURNSPEED
           
protected  Vector3f difTemp
           
protected  boolean enabled
           
protected  boolean invertedY
           
protected  boolean invertRotate
           
protected  boolean lockAscent
           
protected  int lookMouse
           
protected  float maxAscent
           
protected  float maxRollOut
           
protected  float minAscent
           
protected  float minRollOut
           
protected  float mouseRollMultiplier
           
protected  float mouseXMultiplier
           
protected  float mouseXSpeed
           
protected  float mouseYMultiplier
           
protected  float mouseYSpeed
           
protected  ThirdPersonJoystickPlugin plugin
           
static java.lang.String PROP_ENABLED
           
static java.lang.String PROP_INVERTEDY
           
static java.lang.String PROP_INVERTROTATE
           
static java.lang.String PROP_LOCKASCENT
           
static java.lang.String PROP_MAXASCENT
           
static java.lang.String PROP_MAXROLLOUT
           
static java.lang.String PROP_MINASCENT
           
static java.lang.String PROP_MINROLLOUT
           
static java.lang.String PROP_MOUSEBUTTON_FOR_LOOKING
           
static java.lang.String PROP_MOUSEROLLMULT
           
static java.lang.String PROP_MOUSEXMULT
           
static java.lang.String PROP_MOUSEYMULT
           
static java.lang.String PROP_ROTATETARGET
           
static java.lang.String PROP_TARGETTURNSPEED
           
protected  Vector3f rightTemp
           
protected  float rollInSpeed
           
protected  boolean rotateTarget
           
protected  Quaternion rotTemp
           
protected  Vector3f sphereTemp
           
protected  Spatial target
           
protected  float targetTurnSpeed
           
protected  boolean updated
           
protected  Vector3f worldUpVec
           
 
Fields inherited from class com.jme.input.action.MouseInputAction
mouse
 
Fields inherited from class com.jme.input.action.InputAction
speed
 
Constructor Summary
ThirdPersonMouseLook(RelativeMouse mouse, ChaseCamera camera, Spatial target)
          Constructor creates a new MouseLook object.
 
Method Summary
 ChaseCamera getChaseCamera()
           
 ThirdPersonJoystickPlugin getJoystickPlugin()
           
 int getLookMouseButton()
           
 float getMaxAscent()
           
 float getMaxRollOut()
           
 float getMinAscent()
           
 float getMinRollOut()
           
 float getMouseRollMultiplier()
           
 float getMouseXMultiplier()
           
 float getMouseYMultiplier()
           
 Spatial getTarget()
           
 float getTargetTurnSpeed()
           
 boolean isEnabled()
           
 boolean isInvertedY()
          Returns whether vertical control is inverted (ie pulling down on the mouse causes the camera to look up)
 boolean isLockAscent()
           
 boolean isRotateTarget()
           
 void performAction(InputActionEvent event)
          performAction checks for any movement of the mouse, and calls the appropriate method to alter the camera's orientation when applicable.
 void setChaseCamera(ChaseCamera camera)
           
 void setEnabled(boolean enabled)
           
 void setInvertedY(boolean invertY)
           
 void setJoystickPlugin(ThirdPersonJoystickPlugin joystick)
           
 void setLockAscent(boolean lock)
           
 void setLookMouseButton(int button)
          Sets the button to use for look actions.
 void setMaxAscent(float maxAscent)
           
 void setMaxRollOut(float maxRollOut)
           
 void setMinAscent(float minAscent)
           
 void setMinRollOut(float minRollOut)
           
 void setMouseRollMultiplier(float mouseRollMultiplier)
           
 void setMouseXMultiplier(float mouseXMultiplier)
           
 void setMouseYMultiplier(float mouseYMultiplier)
           
 void setRotateTarget(boolean rotateTarget)
           
 void setSpeed(float speed)
          setSpeed sets the speed of the mouse look.
 void setTarget(Spatial target)
           
 void setTargetTurnSpeed(float speed)
           
 void setWorldUpVec(Vector3f worldUpVec)
           
protected  void updateFromJoystick(float time)
           
 void updateProperties(java.util.Map<java.lang.String,java.lang.Object> props)
          updateProperties
 
Methods inherited from class com.jme.input.action.MouseInputAction
setMouse
 
Methods inherited from class com.jme.input.action.InputAction
getSpeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_MAXASCENT

public static final java.lang.String PROP_MAXASCENT
See Also:
Constant Field Values

PROP_MINASCENT

public static final java.lang.String PROP_MINASCENT
See Also:
Constant Field Values

PROP_MAXROLLOUT

public static final java.lang.String PROP_MAXROLLOUT
See Also:
Constant Field Values

PROP_MINROLLOUT

public static final java.lang.String PROP_MINROLLOUT
See Also:
Constant Field Values

PROP_MOUSEXMULT

public static final java.lang.String PROP_MOUSEXMULT
See Also:
Constant Field Values

PROP_MOUSEYMULT

public static final java.lang.String PROP_MOUSEYMULT
See Also:
Constant Field Values

PROP_MOUSEROLLMULT

public static final java.lang.String PROP_MOUSEROLLMULT
See Also:
Constant Field Values

PROP_INVERTEDY

public static final java.lang.String PROP_INVERTEDY
See Also:
Constant Field Values

PROP_LOCKASCENT

public static final java.lang.String PROP_LOCKASCENT
See Also:
Constant Field Values

PROP_ROTATETARGET

public static final java.lang.String PROP_ROTATETARGET
See Also:
Constant Field Values

PROP_ENABLED

public static final java.lang.String PROP_ENABLED
See Also:
Constant Field Values

PROP_TARGETTURNSPEED

public static final java.lang.String PROP_TARGETTURNSPEED
See Also:
Constant Field Values

PROP_MOUSEBUTTON_FOR_LOOKING

public static final java.lang.String PROP_MOUSEBUTTON_FOR_LOOKING
See Also:
Constant Field Values

PROP_INVERTROTATE

public static final java.lang.String PROP_INVERTROTATE
See Also:
Constant Field Values

DEFAULT_MOUSEXMULT

public static final float DEFAULT_MOUSEXMULT
See Also:
Constant Field Values

DEFAULT_MOUSEYMULT

public static final float DEFAULT_MOUSEYMULT
See Also:
Constant Field Values

DEFAULT_MOUSEROLLMULT

public static final float DEFAULT_MOUSEROLLMULT
See Also:
Constant Field Values

DEFAULT_MAXASCENT

public static final float DEFAULT_MAXASCENT
See Also:
Constant Field Values

DEFAULT_MINASCENT

public static final float DEFAULT_MINASCENT
See Also:
Constant Field Values

DEFAULT_MAXROLLOUT

public static final float DEFAULT_MAXROLLOUT
See Also:
Constant Field Values

DEFAULT_MINROLLOUT

public static final float DEFAULT_MINROLLOUT
See Also:
Constant Field Values

DEFAULT_TARGETTURNSPEED

public static final float DEFAULT_TARGETTURNSPEED
See Also:
Constant Field Values

DEFAULT_INVERTEDY

public static final boolean DEFAULT_INVERTEDY
See Also:
Constant Field Values

DEFAULT_LOCKASCENT

public static final boolean DEFAULT_LOCKASCENT
See Also:
Constant Field Values

DEFAULT_ENABLED

public static final boolean DEFAULT_ENABLED
See Also:
Constant Field Values

DEFAULT_ROTATETARGET

public static final boolean DEFAULT_ROTATETARGET
See Also:
Constant Field Values

DEFAULT_INVERTROTATE

public static final boolean DEFAULT_INVERTROTATE
See Also:
Constant Field Values

DEFAULT_MOUSEBUTTON_FOR_LOOKING

public static final int DEFAULT_MOUSEBUTTON_FOR_LOOKING
See Also:
Constant Field Values

maxAscent

protected float maxAscent

minAscent

protected float minAscent

maxRollOut

protected float maxRollOut

minRollOut

protected float minRollOut

mouseXMultiplier

protected float mouseXMultiplier

mouseYMultiplier

protected float mouseYMultiplier

mouseRollMultiplier

protected float mouseRollMultiplier

mouseXSpeed

protected float mouseXSpeed

mouseYSpeed

protected float mouseYSpeed

rollInSpeed

protected float rollInSpeed

targetTurnSpeed

protected float targetTurnSpeed

camera

protected ChaseCamera camera

target

protected Spatial target

updated

protected boolean updated

invertedY

protected boolean invertedY

lockAscent

protected boolean lockAscent

enabled

protected boolean enabled

rotateTarget

protected boolean rotateTarget

invertRotate

protected boolean invertRotate

lookMouse

protected int lookMouse

difTemp

protected Vector3f difTemp

sphereTemp

protected Vector3f sphereTemp

rightTemp

protected Vector3f rightTemp

rotTemp

protected Quaternion rotTemp

worldUpVec

protected Vector3f worldUpVec

plugin

protected ThirdPersonJoystickPlugin plugin
Constructor Detail

ThirdPersonMouseLook

public ThirdPersonMouseLook(RelativeMouse mouse,
                            ChaseCamera camera,
                            Spatial target)
Constructor creates a new MouseLook object. It takes the mouse, camera and speed of the looking.

Parameters:
mouse - the mouse to calculate view changes.
camera - the camera to move.
Method Detail

updateProperties

public void updateProperties(java.util.Map<java.lang.String,java.lang.Object> props)
updateProperties

Parameters:
props -

setSpeed

public void setSpeed(float speed)
setSpeed sets the speed of the mouse look.

Overrides:
setSpeed in class InputAction
Parameters:
speed - the speed of the mouse look.

performAction

public void performAction(InputActionEvent event)
performAction checks for any movement of the mouse, and calls the appropriate method to alter the camera's orientation when applicable.

Parameters:
event - the event that triggered the perform action method.
See Also:
InputActionInterface.performAction(InputActionEvent)

updateFromJoystick

protected void updateFromJoystick(float time)

setInvertedY

public void setInvertedY(boolean invertY)
Parameters:
invertY - true if mouse control should be inverted vertically

isInvertedY

public boolean isInvertedY()
Returns whether vertical control is inverted (ie pulling down on the mouse causes the camera to look up)

Returns:
true if vertical control is inverted (aircraft style)

getMaxAscent

public float getMaxAscent()
Returns:
Returns the maxAscent.

setMaxAscent

public void setMaxAscent(float maxAscent)
Parameters:
maxAscent - The maxAscent to set.

getMinAscent

public float getMinAscent()
Returns:
Returns the minAscent.

setMinAscent

public void setMinAscent(float minAscent)
Parameters:
minAscent - The minAscent to set.

getMaxRollOut

public float getMaxRollOut()
Returns:
Returns the maxRollOut.

setMaxRollOut

public void setMaxRollOut(float maxRollOut)
Parameters:
maxRollOut - The maxRollOut to set.

getMinRollOut

public float getMinRollOut()
Returns:
Returns the minRollOut.

setMinRollOut

public void setMinRollOut(float minRollOut)
Parameters:
minRollOut - The minRollOut to set.

getTargetTurnSpeed

public float getTargetTurnSpeed()
Returns:
how quickly to turn the target in radians per second - only applicable if rotateTarget is true.

setTargetTurnSpeed

public void setTargetTurnSpeed(float speed)
Parameters:
speed - how quickly to turn the target in radians per second - only applicable if rotateTarget is true.

getMouseXMultiplier

public float getMouseXMultiplier()
Returns:
Returns the mouseXMultiplier.

setMouseXMultiplier

public void setMouseXMultiplier(float mouseXMultiplier)
Parameters:
mouseXMultiplier - The mouseXMultiplier to set. Updates mouseXSpeed as well.

getMouseYMultiplier

public float getMouseYMultiplier()
Returns:
Returns the mouseYMultiplier.

setMouseYMultiplier

public void setMouseYMultiplier(float mouseYMultiplier)
Parameters:
mouseYMultiplier - The mouseYMultiplier to set. Updates mouseYSpeed as well.

getMouseRollMultiplier

public float getMouseRollMultiplier()
Returns:
Returns the mouseRollMultiplier.

setMouseRollMultiplier

public void setMouseRollMultiplier(float mouseRollMultiplier)
Parameters:
mouseRollMultiplier - The mouseRollMultiplier to set. Updates rollInSpeed as well.

setLockAscent

public void setLockAscent(boolean lock)
Parameters:
lock - true if camera's polar angle / ascent value should never change.

isLockAscent

public boolean isLockAscent()
Returns:
true if camera's polar angle / ascent value should never change.

isEnabled

public boolean isEnabled()
Returns:
true if mouselook is enabled.

setEnabled

public void setEnabled(boolean enabled)
Parameters:
enabled - true to allow mouselook to affect camera.

isRotateTarget

public boolean isRotateTarget()
Returns:
true if turning mouse should cause the target to turn as well.

setRotateTarget

public void setRotateTarget(boolean rotateTarget)
Parameters:
rotateTarget - true if turning mouse should cause the target to turn as well.

getLookMouseButton

public int getLookMouseButton()
Returns:
the index of the button that must be pressed to activate looking or -1 if no button is needed

setLookMouseButton

public void setLookMouseButton(int button)
Sets the button to use for look actions. For example, if set to 0, the left button must be held down to move the camera around.

Parameters:
button - index of required button or -1 (default) if none

setWorldUpVec

public void setWorldUpVec(Vector3f worldUpVec)
Parameters:
worldUpVec - The worldUpVec to set (as copy)

getJoystickPlugin

public ThirdPersonJoystickPlugin getJoystickPlugin()
Returns:
Returns the joystick plugin or null if not set.

setJoystickPlugin

public void setJoystickPlugin(ThirdPersonJoystickPlugin joystick)
Parameters:
joystick - The joystick plugin to set.

getChaseCamera

public ChaseCamera getChaseCamera()

setChaseCamera

public void setChaseCamera(ChaseCamera camera)

getTarget

public Spatial getTarget()

setTarget

public void setTarget(Spatial target)