|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme.input.InputHandler
com.jme.input.ThirdPersonHandler
public class ThirdPersonHandler
ThirdPersonHandler
defines an InputHandler that sets input to
be controlled similar to games such as Zelda Windwaker and Mario 64, etc.
Field Summary | |
---|---|
protected KeyInputAction |
actionBack
|
protected KeyInputAction |
actionForward
|
protected KeyInputAction |
actionLeft
|
protected KeyInputAction |
actionRight
|
protected KeyInputAction |
actionStrafeLeft
|
protected KeyInputAction |
actionStrafeRight
|
static float |
angleEpsilon
|
protected Vector3f |
calcVector
An internal vector used for calculations to prevent object creation. |
protected Camera |
camera
The camera this handler uses for determining action movement. |
protected boolean |
cameraAlignedMovement
if true, movements of the character are in relation to the current camera view. |
static float |
DEFAULT_TURNSPEED
Default character turn speed is 1.5pi per sec. |
protected boolean |
doGradualRotation
When true, the controlled target will do turns by moving forward and turning at the same time. |
protected float |
faceAngle
The current facing direction of the controlled target in radians in terms of relationship to the world. |
protected Vector3f |
loc
Stores the new location of the node after actions. |
protected boolean |
lockBackwards
if true, backwards movement will not cause the target to rotate around to point backwards. |
protected boolean |
nowStrafing
internally used boolean for denoting that a turning action is currently being performed. |
protected boolean |
nowTurning
internally used boolean for denoting that a turning action is currently being performed. |
protected MovementPermitter |
permitter
When not null, gives a means for denying movement to the controller. |
protected ThirdPersonJoystickPlugin |
plugin
|
protected Vector3f |
prevLoc
The previous location of the target node... |
protected Quaternion |
prevRot
The previous rotation of the target node... |
static java.lang.String |
PROP_CAMERAALIGNEDMOVE
|
static java.lang.String |
PROP_DOGRADUAL
|
static java.lang.String |
PROP_KEY_BACKWARD
|
static java.lang.String |
PROP_KEY_FORWARD
|
static java.lang.String |
PROP_KEY_LEFT
|
static java.lang.String |
PROP_KEY_RIGHT
|
static java.lang.String |
PROP_KEY_STRAFELEFT
|
static java.lang.String |
PROP_KEY_STRAFERIGHT
|
static java.lang.String |
PROP_LOCKBACKWARDS
|
static java.lang.String |
PROP_PERMITTER
|
static java.lang.String |
PROP_ROTATEONLY
|
static java.lang.String |
PROP_STRAFETARGETALIGN
|
static java.lang.String |
PROP_TURNSPEED
|
static java.lang.String |
PROP_UPVECTOR
|
protected boolean |
rotateOnly
if true, left and right keys will rotate the target instead of moving them. |
protected float |
speed
|
protected boolean |
strafeAlignTarget
if true, strafe movements will always be target aligned, even if other movement is camera aligned. |
protected Spatial |
targetSpatial
The Spatial we are controlling with this handler. |
protected float |
turnSpeed
How fast the character can turn per second. |
protected Vector3f |
upVector
World up vector. |
protected boolean |
walkingBackwards
internally used boolean for denoting that a backwards action is currently being performed. |
protected boolean |
walkingForward
internally used boolean for denoting that a forward action is currently being performed. |
Fields inherited from class com.jme.input.InputHandler |
---|
activeTriggers, allTriggers, AXIS_ALL, AXIS_NONE, BUTTON_ALL, BUTTON_NONE, DEVICE_ALL, DEVICE_KEYBOARD, DEVICE_MOUSE, event, mouse |
Constructor Summary | |
---|---|
ThirdPersonHandler(Spatial target,
Camera cam)
Basic constructor for the ThirdPersonHandler. |
|
ThirdPersonHandler(Spatial target,
Camera cam,
java.util.HashMap<java.lang.String,java.lang.Object> props)
Full constructor for the ThirdPersonHandler. |
Method Summary | |
---|---|
protected void |
calcFaceAngle(float actAngle,
float time)
calcFaceAngle |
protected void |
doInputUpdate(float time)
|
Camera |
getCamera()
|
float |
getFaceAngle()
|
ThirdPersonJoystickPlugin |
getJoystickPlugin()
|
MovementPermitter |
getPermitter()
|
float |
getSpeed()
|
Spatial |
getTarget()
|
float |
getTurnSpeed()
|
Vector3f |
getUpVector()
|
boolean |
isCameraAlignedMovement()
|
boolean |
isDoGradualRotation()
|
boolean |
isLockBackwards()
|
boolean |
isNowTurning()
|
boolean |
isRotateOnly()
|
boolean |
isStrafeAlignTarget()
|
boolean |
isStrafing()
|
boolean |
isWalkingBackwards()
|
boolean |
isWalkingForward()
|
protected void |
setActions()
setActions sets the keyboard actions with the
corresponding key command. |
void |
setActionSpeed(float speed)
Sets the speed of all actions currently registered with this handler to the given value. |
void |
setCameraAlignedMovement(boolean b)
|
void |
setDoGradualRotation(boolean doGradualRotation)
|
void |
setGoingBackwards(boolean backwards)
Internal method used to let the handler know that the target is currently moving backwards (via use of the back key.) |
void |
setGoingForward(boolean forward)
Internal method used to let the handler know that the target is currently moving forward (via use of the forward key.) |
void |
setJoystickPlugin(ThirdPersonJoystickPlugin plugin)
|
void |
setLockBackwards(boolean b)
|
void |
setRotateOnly(boolean b)
|
void |
setStrafeAlignTarget(boolean b)
|
void |
setStrafing(boolean strafe)
Internal method used to let the handler know that the target is currently strafing left/right (via use of the strafe left/right keys.) |
void |
setTarget(Spatial target)
|
void |
setTurning(boolean turning)
Internal method used to let the handler know that the target is currently turning/moving left/right (via use of the left/right keys.) |
void |
setTurnSpeed(float turnSpeed)
|
void |
setUpVector(Vector3f upAngle)
|
void |
update(float time)
update updates the position and rotation of the target
based on the movement requested by the user. |
protected void |
updateFromJoystick(float time)
|
void |
updateKeyBindings(java.util.HashMap<java.lang.String,java.lang.Object> props)
updateKeyBindings allows a user to update the keys mapped to the various actions. |
void |
updateProperties(java.util.HashMap<java.lang.String,java.lang.Object> props)
setProperties sets up class fields from the given hashmap. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PROP_TURNSPEED
public static final java.lang.String PROP_DOGRADUAL
public static final java.lang.String PROP_ROTATEONLY
public static final java.lang.String PROP_PERMITTER
public static final java.lang.String PROP_UPVECTOR
public static final java.lang.String PROP_LOCKBACKWARDS
public static final java.lang.String PROP_CAMERAALIGNEDMOVE
public static final java.lang.String PROP_STRAFETARGETALIGN
public static final java.lang.String PROP_KEY_FORWARD
public static final java.lang.String PROP_KEY_BACKWARD
public static final java.lang.String PROP_KEY_LEFT
public static final java.lang.String PROP_KEY_RIGHT
public static final java.lang.String PROP_KEY_STRAFELEFT
public static final java.lang.String PROP_KEY_STRAFERIGHT
public static final float DEFAULT_TURNSPEED
public static float angleEpsilon
protected float speed
protected Spatial targetSpatial
protected Vector3f prevLoc
protected Quaternion prevRot
protected Vector3f loc
protected float faceAngle
protected float turnSpeed
protected boolean doGradualRotation
protected MovementPermitter permitter
protected Vector3f upVector
protected Vector3f calcVector
protected Camera camera
protected boolean lockBackwards
protected boolean strafeAlignTarget
protected boolean rotateOnly
protected boolean cameraAlignedMovement
protected boolean walkingBackwards
protected boolean walkingForward
protected boolean nowTurning
protected boolean nowStrafing
protected ThirdPersonJoystickPlugin plugin
protected KeyInputAction actionForward
protected KeyInputAction actionBack
protected KeyInputAction actionRight
protected KeyInputAction actionLeft
protected KeyInputAction actionStrafeRight
protected KeyInputAction actionStrafeLeft
Constructor Detail |
---|
public ThirdPersonHandler(Spatial target, Camera cam)
target
- the target to movecam
- the camera for movements to be in relation topublic ThirdPersonHandler(Spatial target, Camera cam, java.util.HashMap<java.lang.String,java.lang.Object> props)
target
- the target to movecam
- the camera for movements to be in relation toprops
- a hashmap of properties used to set handler characteristics
where the key is one of this class's static PROP_XXXX fields.Method Detail |
---|
public void updateProperties(java.util.HashMap<java.lang.String,java.lang.Object> props)
setProperties
sets up class fields from the given hashmap.
It also calls updateKeyBindings for you.
props
- public void updateKeyBindings(java.util.HashMap<java.lang.String,java.lang.Object> props)
updateKeyBindings
allows a user to update the keys mapped to the various actions.
props
- protected void setActions()
setActions
sets the keyboard actions with the
corresponding key command.
public void update(float time)
update
updates the position and rotation of the target
based on the movement requested by the user.
update
in class InputHandler
time
- InputHandler.update(float)
protected void doInputUpdate(float time)
protected void updateFromJoystick(float time)
protected void calcFaceAngle(float actAngle, float time)
calcFaceAngle
actAngle
- time
- public float getTurnSpeed()
public void setTurnSpeed(float turnSpeed)
turnSpeed
- The turnSpeed to set.public Vector3f getUpVector()
public void setUpVector(Vector3f upAngle)
upAngle
- The upAngle to set (as copy)public float getFaceAngle()
public boolean isDoGradualRotation()
public void setDoGradualRotation(boolean doGradualRotation)
doGradualRotation
- The doGradualRotation to set.public MovementPermitter getPermitter()
public Spatial getTarget()
public void setTarget(Spatial target)
public Camera getCamera()
public void setStrafeAlignTarget(boolean b)
public boolean isStrafeAlignTarget()
public void setLockBackwards(boolean b)
public boolean isLockBackwards()
public void setRotateOnly(boolean b)
public boolean isRotateOnly()
public void setCameraAlignedMovement(boolean b)
public boolean isCameraAlignedMovement()
public void setGoingForward(boolean forward)
forward
- public void setGoingBackwards(boolean backwards)
backwards
- public void setTurning(boolean turning)
turning
- public void setStrafing(boolean strafe)
strafe
- public boolean isNowTurning()
public boolean isWalkingBackwards()
public boolean isWalkingForward()
public boolean isStrafing()
public void setActionSpeed(float speed)
InputHandler
setActionSpeed
in class InputHandler
speed
- The new speed for all currently registered actions.InputAction.setSpeed(float)
public float getSpeed()
public ThirdPersonJoystickPlugin getJoystickPlugin()
public void setJoystickPlugin(ThirdPersonJoystickPlugin plugin)
plugin
- The joystick plugin to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |