java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.VehicleEngineSettings
com.github.stephengold.joltjni.VehicleEngine
- All Implemented Interfaces:
ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
The engine of a
VehicleController
.-
Method Summary
Modifier and TypeMethodDescriptionboolean
Test whether the vehicle is allowed to sleep.void
applyDamping
(float deltaTime) Update the engine RPM for damping.void
applyTorque
(float torque, float deltaTime) Apply the specified torque to the engine.void
clampRpm()
Clamp the engine's RPM between its minimum and maximum values.float
Return the engine's rotation rate in SI units.float
Return the engine's rotation rate in traditional units.float
getTorque
(float acceleration) Return how much torque the engine can supply for the specified acceleration.void
setCurrentRpm
(float rpm) Alter the engine's rotation rate.Methods inherited from class com.github.stephengold.joltjni.VehicleEngineSettings
getAngularDamping, getInertia, getMaxRpm, getMaxTorque, getMinRpm, setAngularDamping, setInertia, setMaxRpm, setMaxTorque, setMinRpm
Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
-
Method Details
-
allowSleep
public boolean allowSleep()Test whether the vehicle is allowed to sleep.- Returns:
true
if allowed, otherwisefalse
-
applyDamping
public void applyDamping(float deltaTime) Update the engine RPM for damping.- Parameters:
deltaTime
- the amount of time between updates (in seconds, ≥0)
-
applyTorque
public void applyTorque(float torque, float deltaTime) Apply the specified torque to the engine.- Parameters:
torque
- the torque to apply (in Newton.meters)deltaTime
- the amount of time between updates (in seconds, ≥0)
-
clampRpm
public void clampRpm()Clamp the engine's RPM between its minimum and maximum values. -
getAngularVelocity
public float getAngularVelocity()Return the engine's rotation rate in SI units.- Returns:
- the speed (in radians per second)
-
getCurrentRpm
public float getCurrentRpm()Return the engine's rotation rate in traditional units.- Returns:
- the rate (in revolutions per minute)
-
getTorque
public float getTorque(float acceleration) Return how much torque the engine can supply for the specified acceleration.- Parameters:
acceleration
- the position of the accelerator pedal (≥0, ≤1)- Returns:
- the available torque (in Newton.meters)
-
setCurrentRpm
public void setCurrentRpm(float rpm) Alter the engine's rotation rate.- Parameters:
rpm
- the desired rate (in revolutions per minute)
-