Modifier and Type | Field and Description |
---|---|
protected Vector3f |
axle
axis direction (in chassis coordinates, typically to the right/-1,0,0)
|
protected Vector3f |
direction
suspension direction (in chassis coordinates, typically down/0,-1,0)
|
protected float |
frictionSlip
copy of coefficient of friction between tyre and ground
(0.8→realistic car, 10000→kart racer, default=10.5)
|
protected boolean |
frontWheel
copy of wheel type: true→front (steering) wheel,
false→non-front wheel
|
protected Vector3f |
location
location where the suspension connects to the chassis (in chassis
coordinates)
|
protected float |
maxSuspensionForce
copy of maximum force exerted by the suspension (default=6000)
|
protected float |
maxSuspensionTravelCm
copy of maximum suspension travel distance (in centimeters, default=500)
|
protected float |
radius
copy of wheel radius (in physics-space units, >0)
|
protected float |
restLength
copy of rest length of the suspension (in physics-space units)
|
protected float |
rollInfluence
copy of roll-influence factor (0→no roll torque, 1→realistic
behavior, default=1)
|
protected float |
suspensionStiffness
copy of suspension stiffness constant (10→off-road buggy,
50→sports car, 200→Formula-1 race car, default=20)
|
protected Quaternion |
tmp_inverseWorldRotation |
protected Matrix3f |
tmp_Matrix |
protected long |
wheelId
unique identifier of the btRaycastVehicle
|
protected int |
wheelIndex
0-origin index among the vehicle's wheels (≥0)
|
protected float |
wheelsDampingCompression
copy of suspension damping when compressed (0→no damping,
default=4.4)
|
protected float |
wheelsDampingRelaxation
copy of suspension damping when expanded (0→no damping, default=2.3)
|
protected Spatial |
wheelSpatial
associated spatial, or null if none
|
protected Vector3f |
wheelWorldLocation
wheel location in physics-space coordinates
|
protected Quaternion |
wheelWorldRotation
wheel orientation in physics-space coordinates
|
Modifier | Constructor and Description |
---|---|
protected |
VehicleWheel()
No-argument constructor needed by SavableClassUtil.
|
|
VehicleWheel(Spatial spat,
Vector3f location,
Vector3f direction,
Vector3f axle,
float restLength,
float radius,
boolean frontWheel)
Instantiate a wheel.
|
|
VehicleWheel(Vector3f location,
Vector3f direction,
Vector3f axle,
float restLength,
float radius,
boolean frontWheel)
Instantiate a wheel without an associated spatial.
|
Modifier and Type | Method and Description |
---|---|
void |
applyWheelTransform()
Apply this wheel's physics location and orientation to its associated
spatial, if any.
|
Vector3f |
getAxle()
Access this wheel's axle direction.
|
Vector3f |
getCollisionLocation()
Copy the location where the wheel collides with the ground.
|
Vector3f |
getCollisionLocation(Vector3f vec)
Copy the location where the wheel touches the ground.
|
Vector3f |
getCollisionNormal()
Copy the normal where the wheel touches the ground.
|
Vector3f |
getCollisionNormal(Vector3f vec)
Copy the normal where the wheel touches the ground.
|
float |
getDeltaRotation()
Calculate how much this wheel has turned since the last physics step.
|
float |
getDeltaRotation(long wheelId,
int wheelIndex) |
Vector3f |
getDirection()
Access this wheel's suspension direction.
|
float |
getFrictionSlip()
Read the friction between this wheel's tyre and the ground.
|
PhysicsCollisionObject |
getGroundObject()
returns the object this wheel is in contact with or null if no contact
|
Vector3f |
getLocation()
Access the location where the suspension connects to the chassis.
|
float |
getMaxSuspensionForce()
Read the maximum force exerted by this wheel's suspension.
|
float |
getMaxSuspensionTravelCm()
Read the travel distance for this wheel's suspension.
|
float |
getRadius()
Read the radius of this wheel.
|
float |
getRestLength()
Read the rest length of this wheel.
|
float |
getRollInfluence()
Read this wheel's roll influence.
|
float |
getSkidInfo()
Calculate to what extent the wheel is skidding (for skid sounds/smoke
etc.)
|
float |
getSkidInfo(long wheelId,
int wheelIndex) |
float |
getSuspensionStiffness()
Read the stiffness constant for this wheel's suspension.
|
long |
getWheelId()
Read the id of the btRaycastVehicle.
|
float |
getWheelsDampingCompression()
Read this wheel's damping when the suspension is compressed.
|
float |
getWheelsDampingRelaxation()
Read this wheel's damping when the suspension is expanded.
|
Spatial |
getWheelSpatial()
Access the spatial associated with this wheel.
|
void |
getWheelWorldLocation(Vector3f store)
Copy this wheel's physics-space location to the specified vector.
|
void |
getWheelWorldRotation(Quaternion store)
Copy this wheel's physics-space orientation to the specified quaternion.
|
boolean |
isApplyLocal()
Test whether physics coordinates should match the local transform of the
Spatial.
|
boolean |
isFrontWheel()
Test whether this wheel is a front wheel.
|
void |
read(JmeImporter im)
De-serialize this wheel, for example when loading from a J3O file.
|
void |
setApplyLocal(boolean applyLocal)
Alter whether physics coordinates should match the local transform of the
Spatial.
|
void |
setFrictionSlip(float frictionSlip)
Alter the friction between this wheel's tyre and the ground.
|
void |
setFrontWheel(boolean frontWheel)
Alter whether this wheel is a front (steering) wheel.
|
void |
setMaxSuspensionForce(float maxSuspensionForce)
Alter the maximum force exerted by this wheel's suspension.
|
void |
setMaxSuspensionTravelCm(float maxSuspensionTravelCm)
Alter the travel distance for this wheel's suspension.
|
void |
setRadius(float radius)
Alter the radius of this wheel.
|
void |
setRestLength(float restLength)
Alter the rest length of the suspension of this wheel.
|
void |
setRollInfluence(float rollInfluence)
Alter this wheel's roll influence.
|
void |
setSuspensionStiffness(float suspensionStiffness)
Alter the stiffness constant for this wheel's suspension.
|
void |
setVehicleId(long vehicleId,
int wheelIndex)
Assign this wheel to a vehicle.
|
void |
setWheelsDampingCompression(float wheelsDampingCompression)
Alter this wheel's damping when the suspension is compressed.
|
void |
setWheelsDampingRelaxation(float wheelsDampingRelaxation)
Alter this wheel's damping when the suspension is expanded.
|
void |
setWheelSpatial(Spatial wheelSpatial)
Alter which spatial is associated with this wheel.
|
void |
updatePhysicsState()
Update this wheel's location and orientation in physics space.
|
void |
write(JmeExporter ex)
Serialize this wheel, for example when saving to a J3O file.
|
protected long wheelId
protected int wheelIndex
protected boolean frontWheel
protected Vector3f location
protected Vector3f direction
protected Vector3f axle
protected float suspensionStiffness
protected float wheelsDampingRelaxation
protected float wheelsDampingCompression
protected float frictionSlip
protected float rollInfluence
protected float maxSuspensionTravelCm
protected float maxSuspensionForce
protected float radius
protected float restLength
protected Vector3f wheelWorldLocation
protected Quaternion wheelWorldRotation
protected Spatial wheelSpatial
protected Matrix3f tmp_Matrix
protected final Quaternion tmp_inverseWorldRotation
protected VehicleWheel()
public VehicleWheel(Spatial spat, Vector3f location, Vector3f direction, Vector3f axle, float restLength, float radius, boolean frontWheel)
spat
- the associated spatial, or null if nonelocation
- 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 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 void updatePhysicsState()
public void applyWheelTransform()
public long getWheelId()
public void setVehicleId(long vehicleId, int wheelIndex)
vehicleId
- the id of the btRaycastVehicle (not zero)wheelIndex
- index among the vehicle's wheels (≥0)public boolean isFrontWheel()
public void setFrontWheel(boolean frontWheel)
frontWheel
- true→front wheel, false→non-front wheelpublic Vector3f getLocation()
public Vector3f getDirection()
public Vector3f getAxle()
public float getSuspensionStiffness()
public void setSuspensionStiffness(float suspensionStiffness)
suspensionStiffness
- the desired stiffness constant
(10→off-road buggy, 50→sports car, 200→Formula-1 race car,
default=20)public float getWheelsDampingRelaxation()
public void setWheelsDampingRelaxation(float wheelsDampingRelaxation)
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
wheelsDampingRelaxation
- the desired damping (default=2.3)public float getWheelsDampingCompression()
public void setWheelsDampingCompression(float wheelsDampingCompression)
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
wheelsDampingCompression
- the desired damping (default=4.4)public float getFrictionSlip()
public void setFrictionSlip(float frictionSlip)
Should be about 0.8 for realistic cars, but can increased for better handling. Set large (10000.0) for kart racers.
frictionSlip
- the desired coefficient of friction (default=10.5)public float getRollInfluence()
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 tyres 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 centre of mass.
rollInfluence
- the desired roll-influence factor (0→no roll
torque, 1→realistic behaviour, default=1)public float getMaxSuspensionTravelCm()
public void setMaxSuspensionTravelCm(float maxSuspensionTravelCm)
maxSuspensionTravelCm
- the desired maximum travel distance (in
centimetres, default=500)public float getMaxSuspensionForce()
public void setMaxSuspensionForce(float maxSuspensionForce)
Increase this if your suspension cannot handle the weight of your vehicle.
maxSuspensionForce
- the desired maximum force (default=6000)public float getRadius()
public void setRadius(float radius)
radius
- the desired radius (in physics-space units, ≥0,
default=0.5)public float getRestLength()
public void setRestLength(float restLength)
restLength
- the desired length (default=1)public PhysicsCollisionObject getGroundObject()
public Vector3f getCollisionLocation(Vector3f vec)
vec
- storage for the result (not null, modified)public Vector3f getCollisionLocation()
public Vector3f getCollisionNormal(Vector3f vec)
vec
- storage for the result (not null, modified)public Vector3f getCollisionNormal()
public float getSkidInfo()
public float getSkidInfo(long wheelId, int wheelIndex)
public float getDeltaRotation()
public float getDeltaRotation(long wheelId, int wheelIndex)
public void read(JmeImporter im) throws java.io.IOException
public void write(JmeExporter ex) throws java.io.IOException
public Spatial getWheelSpatial()
public void setWheelSpatial(Spatial wheelSpatial)
wheelSpatial
- the desired spatial, or null for nonepublic boolean isApplyLocal()
public void setApplyLocal(boolean applyLocal)
applyLocal
- true→match local transform, false→match world
transform (default=false)public void getWheelWorldRotation(Quaternion store)
store
- storage for the result (not null, modified)public void getWheelWorldLocation(Vector3f store)
store
- storage for the result (not null, modified)