public class VehicleWheel
extends java.lang.Object
btWheelInfo.| Modifier and Type | Field and Description |
|---|---|
static java.util.logging.Logger |
logger
message logger for this class
|
| Constructor and Description |
|---|
VehicleWheel(Vector3f location,
Vector3f direction,
Vector3f axle,
float restLength,
float radius,
boolean frontWheel)
Instantiate a wheel.
|
| Modifier and Type | Method and Description |
|---|---|
Vector3f |
getAxle(Vector3f storeResult)
Determine this wheel's axis direction.
|
float |
getBrake()
Determine this wheel's braking impulse (native field: m_brake).
|
Vector3f |
getCollisionLocation(Vector3f storeResult)
Determine the location where the wheel touches the ground.
|
Vector3f |
getCollisionNormal(Vector3f storeResult)
Determine the normal direction where the wheel touches the ground.
|
float |
getDeltaRotation()
Determine how much this wheel has turned since the last simulation step.
|
Vector3f |
getDirection(Vector3f storeResult)
Determine this wheel's suspension direction.
|
float |
getEngineForce()
Determine this wheel's engine force (native field: m_engineForce).
|
float |
getFrictionSlip()
Determine the friction between this wheel's tire and the ground (native
field: m_frictionSlip).
|
int |
getIndex()
Determine the index of this wheel, based on creation order.
|
Vector3f |
getLocation(Vector3f storeResult)
Determine the location where the suspension connects to the chassis.
|
float |
getMaxSuspensionForce()
Determine the maximum force exerted by this wheel's suspension (native
field: m_maxSuspensionForce).
|
float |
getMaxSuspensionTravelCm()
Determine the maximum travel distance for this wheel's suspension (native
field: m_maxSuspensionTravelCm).
|
float |
getRadius()
Determine the radius of this wheel (native field: m_wheelsRadius).
|
float |
getRestLength()
Determine the rest length of this wheel (native field:
m_suspensionRestLength1).
|
float |
getRollInfluence()
Determine this wheel's roll influence (native field: m_rollInfluence).
|
float |
getRotationAngle()
Determine the total rotation of this wheel (native field: m_rotation).
|
float |
getSkidInfo()
Determine to what extent the wheel is skidding (for skid sounds/smoke
etcetera).
|
float |
getSteerAngle()
Determine this wheel's steering angle (native field: m_steering).
|
float |
getSuspensionLength()
Determine the length of this wheel's suspension (native field:
m_suspensionLength).
|
float |
getSuspensionStiffness()
Determine the stiffness of this wheel's suspension (native field:
m_suspensionStiffness).
|
float |
getWheelsDampingCompression()
Determine this wheel's damping when the suspension is compressed (native
field: m_wheelsDampingCompression).
|
float |
getWheelsDampingRelaxation()
Determine this wheel's damping when the suspension is expanded (native
field: m_wheelsDampingRelaxation).
|
Vector3f |
getWheelWorldLocation(Vector3f storeResult)
Determine this wheel's location.
|
Quaternion |
getWheelWorldRotation(Quaternion storeResult)
Determine this wheel's orientation.
|
boolean |
isApplyLocal()
Test whether physics coordinates should match the local transform of the
Spatial.
|
boolean |
isFrontWheel()
Test whether this wheel is a front (steering) wheel (native field:
m_bIsFrontWheel).
|
void |
setApplyLocal(boolean applyLocal)
Alter whether physics coordinates should match the local transform of the
Spatial.
|
void |
setFrictionSlip(float coeff)
Alter the friction between this wheel's tire and the ground (native
field: m_frictionSlip).
|
void |
setFrontWheel(boolean frontWheel)
Alter whether this wheel is a front (steering) wheel (native field:
m_bIsFrontWheel).
|
void |
setMaxSuspensionForce(float maxForce)
Alter the maximum force exerted by this wheel's suspension (native field:
m_maxSuspensionForce).
|
void |
setMaxSuspensionTravelCm(float travelCm)
Alter the maximum travel distance for this wheel's suspension (native
field: m_maxSuspensionTravelCm).
|
void |
setRadius(float radius)
Alter the radius of this wheel (native field: m_wheelsRadius).
|
void |
setRestLength(float restLength)
Alter the rest length of the suspension of this wheel (native field:
m_suspensionRestLength1).
|
void |
setRollInfluence(float rollInfluence)
Alter this wheel's roll influence (native field: m_rollInfluence).
|
void |
setRotationAngle(float angle)
Alter the total rotation of this wheel (native field: m_rotation).
|
void |
setSuspensionLength(float length)
Alter the length of this wheel's suspension (native field:
m_suspensionLength).
|
void |
setSuspensionStiffness(float stiffness)
Alter the stiffness of this wheel's suspension (native field:
m_suspensionStiffness).
|
void |
setVehicleId(long vehicleId,
int wheelIndex)
Assign this wheel to a vehicle.
|
void |
setWheelsDampingCompression(float damping)
Alter this wheel's damping when the suspension is compressed (native
field: m_wheelsDampingCompression).
|
void |
setWheelsDampingRelaxation(float wheelsDampingRelaxation)
Alter this wheel's damping when the suspension is expanded (native field:
m_wheelsDampingRelaxation).
|
void |
updatePhysicsState()
Update this wheel's location and orientation.
|
public static final java.util.logging.Logger logger
public VehicleWheel(Vector3f location, Vector3f direction, Vector3f axle, float restLength, float radius, boolean frontWheel)
location - the location where the suspension connects to the chassis
(in chassis coordinates, not null, unaffected)direction - the suspension direction (in chassis coordinates, not
null, unaffected, typically down/0,-1,0)axle - the axis direction (in chassis coordinates, not null,
unaffected, typically right/-1,0,0)restLength - the rest length of the suspension (in physics-space
units)radius - the wheel's radius (in physics-space units, ≥0)frontWheel - true→front (steering) wheel, false→non-front
wheelpublic Vector3f getAxle(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public float getBrake()
public Vector3f getCollisionLocation(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public Vector3f getCollisionNormal(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public float getDeltaRotation()
public Vector3f getDirection(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public float getEngineForce()
public float getFrictionSlip()
public int getIndex()
public Vector3f getLocation(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public float getMaxSuspensionForce()
public float getMaxSuspensionTravelCm()
public float getRadius()
public float getRestLength()
public float getRollInfluence()
public float getRotationAngle()
public float getSkidInfo()
PhysicsVehicle.castRay(int) is negative!public float getSteerAngle()
public float getSuspensionLength()
public float getSuspensionStiffness()
public float getWheelsDampingCompression()
public float getWheelsDampingRelaxation()
public Vector3f getWheelWorldLocation(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public Quaternion getWheelWorldRotation(Quaternion storeResult)
storeResult - storage for the result (modified if not null)public boolean isApplyLocal()
public boolean isFrontWheel()
public void setApplyLocal(boolean applyLocal)
applyLocal - true→match local transform, false→match world
transform (default=false)public void setFrictionSlip(float coeff)
Should be about 0.8 for realistic cars, but can be increased for better handling. Set large (10000) for kart racers.
coeff - the desired coefficient of friction (default=10.5)public void setFrontWheel(boolean frontWheel)
frontWheel - true→front wheel, false→non-front wheelpublic void setMaxSuspensionForce(float maxForce)
Increase this if your suspension cannot handle the weight of your vehicle.
maxForce - the desired maximum force (default=6000)public void setMaxSuspensionTravelCm(float travelCm)
travelCm - the desired maximum amount the suspension can be
compressed or expanded, relative to its rest length (in hundredths of a
physics-space unit, default=500)public void setRadius(float radius)
radius - the desired radius (in physics-space units, ≥0,
default=0.5)public void setRestLength(float restLength)
restLength - the desired length (default=1)public void setRollInfluence(float rollInfluence)
The roll-influence factor reduces (or magnifies) the torque contributed by this wheel that tends to cause the vehicle to roll over. This is a bit of a hack, but it's quite effective.
If the friction between the tires and the ground is too high, you may reduce this factor to prevent the vehicle from rolling over. You should also try lowering the vehicle's center of mass.
rollInfluence - the desired roll-influence factor (0→no roll
torque, 1→realistic behavior, default=1)public void setRotationAngle(float angle)
angle - the desired angle (in radians)public void setSuspensionLength(float length)
length - the desired length (in physics-space units)public void setSuspensionStiffness(float stiffness)
stiffness - the desired stiffness constant (10→off-road buggy,
50→sports car, 200→Formula-1 race car, default=5.88)public void setVehicleId(long vehicleId,
int wheelIndex)
vehicleId - the ID of the btRaycastVehicle (not zero)wheelIndex - index among the vehicle's wheels (≥0)public void setWheelsDampingCompression(float damping)
Set to k * 2 * FastMath.sqrt(m_suspensionStiffness) where k is the damping ratio:
k = 0.0 undamped and bouncy, k = 1.0 critical damping, k between 0.1 and 0.3 are good values
damping - the desired damping (0→no damping, default=0.83)public void setWheelsDampingRelaxation(float wheelsDampingRelaxation)
Set to k * 2 * FastMath.sqrt(m_suspensionStiffness) where k is the damping ratio:
k=0: undamped and bouncy, k=1: critical damping, k between 0.1 and 0.3 are good values
wheelsDampingRelaxation - the desired damping (default=0.88)public void updatePhysicsState()