public abstract class Vehicle extends java.lang.Object implements HasNode, jme3utilities.Loadable, com.jme3.bullet.PhysicsTickListener, VehicleSpeed, VehicleSteering
| Modifier and Type | Field and Description |
|---|---|
static float |
KPH_TO_MPH
factor to convert km/hr to miles per hour
|
static float |
KPH_TO_WUPS
factor to convert km/hr to wu/sec
|
static java.util.logging.Logger |
logger
message logger for this class
|
| Constructor and Description |
|---|
Vehicle(java.lang.String name)
Instantiate a Vehicle with the specified name.
|
| Modifier and Type | Method and Description |
|---|---|
float |
accelerateSignal()
Evaluate the "accelerate" control signal.
|
void |
addToWorld(VehicleWorld world,
GlobalAudio globalAudio)
Add this Vehicle to the specified world.
|
Wheel |
addWheel(WheelModel wheelModel,
com.jme3.math.Vector3f connectionLocation,
boolean isSteering,
boolean isSteeringFlipped,
float mainBrakePeakForce,
float parkingBrakePeakForce,
float extraDamping)
Add a single Wheel to this Vehicle.
|
protected void |
build()
Should be invoked last, after all parts have been configured and added.
|
float |
chassisDamping()
Determine the linear damping due to air resistance.
|
int |
countWheels()
Count how many wheels this Vehicle has.
|
float |
driveWheelCircumference()
Determine the circumference of the first drive wheel.
|
com.jme3.math.Vector3f |
forwardDirection(com.jme3.math.Vector3f storeResult)
Determine the forward direction.
|
float |
forwardSpeed(SpeedUnit speedUnit)
Determine the forward component of the vehicle's inertial velocity.
|
com.jme3.scene.Spatial |
getChassis()
Access the computer-graphics (C-G) model for visualization.
|
Engine |
getEngine()
Access the Engine.
|
GearBox |
getGearBox()
Access the GearBox.
|
Sound |
getHornSound()
Access the horn sound.
|
java.lang.String |
getName()
Determine this vehicle's name.
|
com.jme3.scene.Node |
getNode()
Access the scene-graph subtree that represents this Vehicle.
|
SpeedUnit |
getSpeedometerUnits()
Determine which units to use in the speedometer.
|
com.jme3.bullet.control.VehicleControl |
getVehicleControl()
Access the PhysicsControl.
|
Wheel |
getWheel(int index)
Access the indexed Wheel.
|
VehicleWorld |
getWorld()
Access the world that contains this Vehicle.
|
boolean |
isBurningRubber()
Test whether the tires are forced to emit smoke.
|
boolean |
isHornRequested()
Test whether the driver is sounding the horn.
|
Wheel[] |
listWheels()
Enumerate all wheels.
|
void |
load(com.jme3.asset.AssetManager assetManager)
Load the assets of this Vehicle.
|
abstract void |
locateDashCam(com.jme3.math.Vector3f storeResult)
Determine the offset of the vehicle's DashCamera in scaled shape
coordinates.
|
com.jme3.math.Vector3f |
locateTarget(float bias,
com.jme3.math.Vector3f storeResult)
Determine the location of the ChaseCamera target.
|
protected abstract void |
locateTarget(com.jme3.math.Vector3f storeResult)
Determine the offset of the vehicle's ChaseCamera target in scaled shape
coordinates.
|
float |
maxForwardSpeed(SpeedUnit speedUnit)
Estimate the vehicle's maximum forward speed.
|
float |
maxReverseSpeed(SpeedUnit speedUnit)
Estimate the vehicle's maximum reverse speed.
|
void |
physicsTick(com.jme3.bullet.PhysicsSpace space,
float timeStep)
Callback from Bullet, invoked just after the physics has been stepped.
|
void |
prePhysicsTick(com.jme3.bullet.PhysicsSpace space,
float timeStep)
Callback from Bullet, invoked just before the physics is stepped.
|
void |
removeFromWorld()
Remove this Vehicle from the world to which it was added.
|
void |
setAccelerateSignal(float strength)
Alter the "accelerate" control signal.
|
void |
setBrakeSignals(float mainStrength,
float parkingStrength)
Alter the values of the brake control signals.
|
void |
setBurningRubber(boolean setting)
Alter whether the tires are forced to emit smoke.
|
protected void |
setChassis(com.jme3.scene.Spatial cgmRoot,
com.jme3.bullet.collision.shapes.CollisionShape shape,
float mass,
float damping)
Configure the "chassis".
|
protected void |
setChassis(java.lang.String folderName,
java.lang.String cgmBaseFileName,
com.jme3.asset.AssetManager assetManager,
float mass,
float damping)
Configure a "chassis" that's loaded from J3O assets in the usual folders.
|
protected void |
setEngine(Engine desiredEngine)
Alter the vehicle's Engine.
|
protected void |
setGearBox(GearBox gearBox)
Alter the vehicle's GearBox.
|
protected void |
setHornSound(Sound sound)
Alter the horn sound.
|
void |
setHornStatus(boolean isRequested)
Update the status of the horn.
|
void |
setSpeedometerUnits(SpeedUnit units)
Alter which units to use in the speedometer.
|
void |
setTireSkidMarksEnabled(boolean enabled) |
void |
setTireSkidMarksVisible(boolean enabled) |
void |
setTireSmokeEnabled(boolean enabled) |
void |
setWheelModel(int wheelIndex,
java.lang.Class<? extends WheelModel> modelClass)
Replace the WheelModel of the indexed wheel with a new instance of the
specified class.
|
void |
startEngine() |
void |
steer(float wheelAngle) |
float |
steeringWheelAngle()
Determine the rotation angle of the steering wheel, handlebars, or
tiller.
|
void |
stopEngine() |
void |
warpToStart()
Warp this vehicle to a suitable start position.
|
public static final float KPH_TO_MPH
public static final float KPH_TO_WUPS
public static final java.util.logging.Logger logger
public Vehicle(java.lang.String name)
name - the desired name (not null)public float accelerateSignal()
public void addToWorld(VehicleWorld world, GlobalAudio globalAudio)
world - where to attach (not null, alias created)globalAudio - the global audio controls (not null, alias created)public Wheel addWheel(WheelModel wheelModel, com.jme3.math.Vector3f connectionLocation, boolean isSteering, boolean isSteeringFlipped, float mainBrakePeakForce, float parkingBrakePeakForce, float extraDamping)
wheelModel - the desired WheelModel (not null)connectionLocation - the location where the suspension connects to
the chassis (in chassis coordinates, not null, unaffected)isSteering - true if used for steering, otherwise falseisSteeringFlipped - true for rear-wheel steering, otherwise falsemainBrakePeakForce - (in Newtons, ≥0)parkingBrakePeakForce - (in Newtons, ≥0)extraDamping - (≥0, <1)public float chassisDamping()
public int countWheels()
public float driveWheelCircumference()
public com.jme3.math.Vector3f forwardDirection(com.jme3.math.Vector3f storeResult)
storeResult - storage for the result (modified if not null)public com.jme3.scene.Spatial getChassis()
public Engine getEngine()
public GearBox getGearBox()
public Sound getHornSound()
public java.lang.String getName()
public SpeedUnit getSpeedometerUnits()
public com.jme3.bullet.control.VehicleControl getVehicleControl()
public Wheel getWheel(int index)
index - which Wheel to access (≥0)public VehicleWorld getWorld()
public boolean isBurningRubber()
public boolean isHornRequested()
public Wheel[] listWheels()
public abstract void locateDashCam(com.jme3.math.Vector3f storeResult)
storeResult - storage for the result (not null)public com.jme3.math.Vector3f locateTarget(float bias,
com.jme3.math.Vector3f storeResult)
bias - how much to displace the target toward the rear (0=center of
mass, 1=back bumper)storeResult - storage for the result (modified if not null)public void removeFromWorld()
public void setAccelerateSignal(float strength)
strength - the desired strength of the "accelerate" control signal:
between 0 (coasting) and 1 (full throttle)public void setBrakeSignals(float mainStrength,
float parkingStrength)
mainStrength - the desired strength of the main-brake control
signal, between 0 (not applied) and 1 (applied as strongly as possible)parkingStrength - the desired strength of the parking-brake control
signal, between 0 (not applied) and 1 (applied as strongly as possible)public void setBurningRubber(boolean setting)
setting - true→forced, false→not forcedpublic void setHornStatus(boolean isRequested)
isRequested - true → requested, false → not requestedpublic void setSpeedometerUnits(SpeedUnit units)
units - an enum value, or null for no speedometerpublic void setTireSkidMarksEnabled(boolean enabled)
public void setTireSkidMarksVisible(boolean enabled)
public void setTireSmokeEnabled(boolean enabled)
public void setWheelModel(int wheelIndex,
java.lang.Class<? extends WheelModel> modelClass)
wheelIndex - which wheel to replace (≥0, <numWheels-1)modelClass - the desired type of wheel (not null)public void startEngine()
public void steer(float wheelAngle)
public void stopEngine()
public void warpToStart()
protected void build()
protected abstract void locateTarget(com.jme3.math.Vector3f storeResult)
storeResult - storage for the result (not null)protected void setChassis(java.lang.String folderName,
java.lang.String cgmBaseFileName,
com.jme3.asset.AssetManager assetManager,
float mass,
float damping)
folderName - the name of the folder containing the C-G model asset
(not null, not empty)cgmBaseFileName - the base filename of the C-G model asset (not
null, not empty)assetManager - to load assets (not null)mass - the mass of the chassis (in kilos, >0)damping - the drag on the chassis due to air resistance (≥0,
<1)protected void setChassis(com.jme3.scene.Spatial cgmRoot,
com.jme3.bullet.collision.shapes.CollisionShape shape,
float mass,
float damping)
cgmRoot - the root of the C-G model to visualize the chassis (not
null, alias created)shape - the shape for the chassis (not null, alias created)mass - the mass of the chassis (in kilos, >0)damping - the drag on the chassis due to air resistance (≥0,
<1)protected void setEngine(Engine desiredEngine)
desiredEngine - the desired Engine (not null)protected void setGearBox(GearBox gearBox)
gearBox - the desired GearBoxprotected void setHornSound(Sound sound)
sound - the desired Sound (loaded), or null for silencepublic com.jme3.scene.Node getNode()
public void load(com.jme3.asset.AssetManager assetManager)
load in interface jme3utilities.LoadableassetManager - for loading assets (not null)public void physicsTick(com.jme3.bullet.PhysicsSpace space,
float timeStep)
physicsTick in interface com.jme3.bullet.PhysicsTickListenerspace - the space that was just stepped (not null)timeStep - the time per physics step (in seconds, ≥0)public void prePhysicsTick(com.jme3.bullet.PhysicsSpace space,
float timeStep)
prePhysicsTick in interface com.jme3.bullet.PhysicsTickListenerspace - the space that is about to be stepped (not null)timeStep - the time per physics step (in seconds, ≥0)public float forwardSpeed(SpeedUnit speedUnit)
forwardSpeed in interface VehicleSpeedspeedUnit - the unit of measurement to use (not null)public float maxForwardSpeed(SpeedUnit speedUnit)
maxForwardSpeed in interface VehicleSpeedspeedUnit - the unit of measurement to use (not null)public float maxReverseSpeed(SpeedUnit speedUnit)
maxReverseSpeed in interface VehicleSpeedspeedUnit - the unit of measurement to use (not null)public float steeringWheelAngle()
steeringWheelAngle in interface VehicleSteering