public abstract class Engine extends java.lang.Object implements EngineSpeed
| Modifier and Type | Field and Description |
|---|---|
static float |
HP_TO_W
approximate factor to convert horsepower to Watts
|
static java.util.logging.Logger |
logger
message logger for this class
|
| Constructor and Description |
|---|
Engine(java.lang.String name,
float maxWatts,
float idleRpm,
float redlineRpm)
Instantiate an Engine in the "off" state, without audio.
|
| Modifier and Type | Method and Description |
|---|---|
protected static float |
evaluateSpline(com.jme3.math.Spline powerCurve,
float rpm)
Determine the power output for the specified speed, using a Spline.
|
float |
getMaxOutputWatts()
Determine the maximum power output.
|
java.lang.String |
getName()
Determine this engine's name.
|
Sound |
getSound()
Access the engine's sound.
|
float |
idleFraction()
Determine the idle speed as a fraction of the redline.
|
float |
idleRpm()
Determine the idle speed of the Engine.
|
boolean |
isRunning()
Test whether this Engine is running.
|
float |
outputWatts()
Determine the current power output.
|
abstract float |
powerFraction(float rpm)
Determine the power output for the specified speed.
|
float |
redlineRpm()
Determine the redline speed of the Engine.
|
float |
rpm()
Determine the current engine speed.
|
float |
rpmFraction()
Determine the current engine speed as a fraction of the redline.
|
void |
setMaxOutputWatts(float watts)
Alter this engine's maximum power output.
|
void |
setRpmFraction(float revs)
Alter the engine's speed as a fraction of the redline.
|
void |
setRunning(boolean newState)
Alter whether this Engine is running.
|
void |
setSound(Sound desiredSound)
Alter the engine's Sound.
|
void |
setVehicle(HasNode desiredVehicle)
Alter which vehicle (if any) contains this Engine.
|
public static final float HP_TO_W
public static final java.util.logging.Logger logger
public Engine(java.lang.String name,
float maxWatts,
float idleRpm,
float redlineRpm)
name - the desired name (not null)maxWatts - the desired maximum power output (in Watts, >0)idleRpm - the desired idle speed (in RPMs, ≥0, <redlineRpm)redlineRpm - the desired redline speed (>0)public float getMaxOutputWatts()
public java.lang.String getName()
public Sound getSound()
public boolean isRunning()
public float outputWatts()
public abstract float powerFraction(float rpm)
rpm - the crankshaft rotation rate (in revolutions per minute,
≥0)public void setMaxOutputWatts(float watts)
watts - the desired amount of power (>0)public void setRpmFraction(float revs)
revs - the desired fraction (≥0)public void setRunning(boolean newState)
newState - the desired state (default=false)public void setSound(Sound desiredSound)
desiredSound - the desired Sound (loaded), or null for silencepublic void setVehicle(HasNode desiredVehicle)
desiredVehicle - the desired Vehicle, or null for noneprotected static float evaluateSpline(com.jme3.math.Spline powerCurve,
float rpm)
powerCurve - the spline to use (not null, unaffected)rpm - the crankshaft rotation rate (in revolutions per minute)public float idleFraction()
idleFraction in interface EngineSpeedpublic float idleRpm()
idleRpm in interface EngineSpeedpublic float redlineRpm()
redlineRpm in interface EngineSpeedpublic float rpm()
rpm in interface EngineSpeedpublic float rpmFraction()
rpmFraction in interface EngineSpeed