jme.physics.mobile
Class LandMobility

java.lang.Object
  extended byjme.physics.mobile.LandMobility
All Implemented Interfaces:
PhysicsModule

public class LandMobility
extends java.lang.Object
implements PhysicsModule

LandMobility handles the acceleration and velocity of a land vehicle. It is set such that to move forward/backward the entity is accelerated/decelerated. The velocity of entity is determined by: V1 = V0 + a(t). Turning is also determined by a set turning velocity. Future enhancements should include using the normal of the geometry moving over to for friction, gravity changes.

Author:
Mark Powell

Constructor Summary
LandMobility()
          Constuctor instantiates a new LandMobility object.
 
Method Summary
 float getCurrentAngle()
          getCurrentAngle returns the current angle the entity is facing.
 float getCurrentTurningVel()
          getCurrentTurningVel returns the current velocity of turning.
 float getCurrentVelocity()
          getCurrentVelocity returns the current velocity of the entity.
 void move(float accelerationScalar)
          move sets the current acceleration to the base acceleration to the acceleration scalar.
 void setBaseAcceleration(float baseAcceleration)
          setBaseAcceleration sets the acceleration of the entity.
 void setCoastDeceleration(float coastDeceleration)
          setCoastDeceleration sets the deceleration rate of the entity.
 void setCurrentAngle(float currentAngle)
          setCurrentAngle sets the current angle of the entity.
 void setMaxVelocity(float maxVelocity)
          setMaxVelocity sets the maximum velocity the entity is allowed to obtain.
 void setMinVelocity(float minVelocity)
          setMinVelocity sets the minimum velocity (backward movement) the entity is allowed to obtain.
 void setTurningVelocity(float f)
          setTurningVelocity sets the rate at which the entity can turn.
 void strafe(float strafeScalar)
          strafe sets the current acceleration to the base strafe acceleration to the acceleration scalar.
 void turn(float turnScalar)
          turn affects the current turning velocity, where negative one turns right by the set turning velocity and positive one turns left by the set turning velocity.
 void update(float time)
          update calculates the current velocity of the entity, as well as the current angle the entity is facing.
 void updatePosition(Vector position)
          updatePosition sets the entities new position based on it's current velocity and angle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LandMobility

public LandMobility()
Constuctor instantiates a new LandMobility object.

Method Detail

update

public void update(float time)
update calculates the current velocity of the entity, as well as the current angle the entity is facing. This is scaled by the current time frame sent as a parameter. This insures independance from the framerate.

Specified by:
update in interface PhysicsModule
Parameters:
time - the time between updates.

updatePosition

public void updatePosition(Vector position)
updatePosition sets the entities new position based on it's current velocity and angle.

Specified by:
updatePosition in interface PhysicsModule
Parameters:
position - the position to update.

turn

public void turn(float turnScalar)
turn affects the current turning velocity, where negative one turns right by the set turning velocity and positive one turns left by the set turning velocity. For increases of turning speed increase the scalar and vice versa for decreasing.

Specified by:
turn in interface PhysicsModule
Parameters:
turnScalar - the amount to multiply the turning velocity by.

move

public void move(float accelerationScalar)
move sets the current acceleration to the base acceleration to the acceleration scalar. Therefore, if you wanted to move forward at full speed the accelerationScalar would be set to 1. If you wanted to decelerate by half the speed (-0.5).

Specified by:
move in interface PhysicsModule
Parameters:
accelerationScalar - the scalar to multiply the baseAcceleration and set the current acceleration.

strafe

public void strafe(float strafeScalar)
strafe sets the current acceleration to the base strafe acceleration to the acceleration scalar. Therefore, if you want to strafe to the right, you would set it to -1. To the left would be 1.

Specified by:
strafe in interface PhysicsModule
Parameters:
strafeScalar - is the scalar to multiply the strafe acceleration by.

setCoastDeceleration

public void setCoastDeceleration(float coastDeceleration)
setCoastDeceleration sets the deceleration rate of the entity. This value is used when the entity is not actively moving.

Parameters:
coastDeceleration - the deceleration rate of the entity.

setMaxVelocity

public void setMaxVelocity(float maxVelocity)
setMaxVelocity sets the maximum velocity the entity is allowed to obtain.

Parameters:
maxVelocity - the maximum velocity of the entity.

setMinVelocity

public void setMinVelocity(float minVelocity)
setMinVelocity sets the minimum velocity (backward movement) the entity is allowed to obtain.

Parameters:
minVelocity - the minimum velocity of the entity.

setTurningVelocity

public void setTurningVelocity(float f)
setTurningVelocity sets the rate at which the entity can turn.


setBaseAcceleration

public void setBaseAcceleration(float baseAcceleration)
setBaseAcceleration sets the acceleration of the entity. This base is used to determine the velocity of the entity.

Parameters:
baseAcceleration - the base (unmodified) acceleration rate of the entity.

setCurrentAngle

public void setCurrentAngle(float currentAngle)
setCurrentAngle sets the current angle of the entity. Effectively rotating the entity instantly.

Parameters:
currentAngle - the angle to set the entity to.

getCurrentAngle

public float getCurrentAngle()
getCurrentAngle returns the current angle the entity is facing.

Specified by:
getCurrentAngle in interface PhysicsModule
Returns:
the current angle of the entity.

getCurrentVelocity

public float getCurrentVelocity()
getCurrentVelocity returns the current velocity of the entity.

Specified by:
getCurrentVelocity in interface PhysicsModule
Returns:
the current velocity of the entity.

getCurrentTurningVel

public float getCurrentTurningVel()
getCurrentTurningVel returns the current velocity of turning.

Specified by:
getCurrentTurningVel in interface PhysicsModule
Returns:
the current turning velocity.