Package com.github.stephengold.joltjni
Class VehicleTransmission
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.VehicleTransmissionSettings
com.github.stephengold.joltjni.VehicleTransmission
- All Implemented Interfaces:
ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
The transmission (gearbox) of a
VehicleController
.-
Method Summary
Modifier and TypeMethodDescriptionboolean
Test whether to allow sleeping only when the transmission is idle.float
Return how friction the clutch gives.int
Return the current gear.float
Return transmission ratio based on the current gear.boolean
Test whether the transmission is currently switching gears.void
set
(int currentGear, float clutchFriction) Alter the input from the driver (only relevant in manual mode).void
update
(float deltaTime, float rpm, float forwardInput, boolean canShiftUp) Update the gear and clutch friction if the transmission is in auto mode.Methods inherited from class com.github.stephengold.joltjni.VehicleTransmissionSettings
getClutchReleaseTime, getClutchStrength, getGearRatios, getMode, getReverseGearRatios, getShiftDownRpm, getShiftUpRpm, getSwitchLatency, getSwitchTime, setClutchReleaseTime, setClutchStrength, setGearRatios, setMode, setReverseGearRatios, setShiftDownRpm, setShiftUpRpm, setSwitchLatency, setSwitchTime
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 to allow sleeping only when the transmission is idle.- Returns:
true
if allowed, otherwisefalse
-
getClutchFriction
public float getClutchFriction()Return how friction the clutch gives. The settings are unaffected.- Returns:
- the amount of friction (≥0, ≤1, 1=full friction)
-
getCurrentGear
public int getCurrentGear()Return the current gear.- Returns:
- the gear number (-1=reverse, 0=neutral, 1=1st gear)
-
getCurrentRatio
public float getCurrentRatio()Return transmission ratio based on the current gear. The settings are unaffected.- Returns:
- the ratio between engine and differential
-
isSwitchingGear
public boolean isSwitchingGear()Test whether the transmission is currently switching gears.- Returns:
true
if switching, otherwisefalse
-
set
public void set(int currentGear, float clutchFriction) Alter the input from the driver (only relevant in manual mode).- Parameters:
currentGear
- the selected gear (-1=reverse, 0=neutral, 1=1st gear)clutchFriction
- the amount of clutch friction (0=none, 1=full friction)
-
update
public void update(float deltaTime, float rpm, float forwardInput, boolean canShiftUp) Update the gear and clutch friction if the transmission is in auto mode.- Parameters:
deltaTime
- the time step (in seconds, ≥0)rpm
- the engine's current rate (in revolutions per minute)forwardInput
- positive if the driver wants to go forward, otherwise negativecanShiftUp
-true
if the driver wants to upshift, otherwisefalse
-