Package com.jme3.bullet.objects
Class VehicleWheel
java.lang.Object
com.jme3.bullet.objects.VehicleWheel
- All Implemented Interfaces:
com.jme3.export.Savable
Stores info about one wheel of a PhysicsVehicle
- Author:
- normenhansen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.jme3.math.Vector3fprotected com.jme3.math.Vector3fprotected floatprotected booleanprotected com.jme3.math.Vector3fprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected final com.jme3.math.Quaternionprotected com.jme3.math.Matrix3fprotected com.bulletphysics.dynamics.vehicle.WheelInfoprotected floatprotected floatprotected com.jme3.scene.Spatialprotected com.jme3.math.Vector3fprotected com.jme3.math.Quaternion -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedVehicleWheel(com.jme3.math.Vector3f location, com.jme3.math.Vector3f direction, com.jme3.math.Vector3f axle, float restLength, float radius, boolean frontWheel) VehicleWheel(com.jme3.scene.Spatial spat, com.jme3.math.Vector3f location, com.jme3.math.Vector3f direction, com.jme3.math.Vector3f axle, float restLength, float radius, boolean frontWheel) -
Method Summary
Modifier and TypeMethodDescriptionvoidcom.jme3.math.Vector3fgetAxle()com.jme3.math.Vector3freturns the location where the wheel collides with the ground (world space)com.jme3.math.Vector3fgetCollisionLocation(com.jme3.math.Vector3f vec) returns the location where the wheel collides with the ground (world space)com.jme3.math.Vector3freturns the normal where the wheel collides with the ground (world space)com.jme3.math.Vector3fgetCollisionNormal(com.jme3.math.Vector3f vec) returns the normal where the wheel collides with the ground (world space)floatreturns how many degrees the wheel has turned since the last physics step.com.jme3.math.Vector3ffloatreturns the object this wheel is in contact with or null if no contactcom.jme3.math.Vector3ffloatfloatfloatfloatfloatfloatreturns how much the wheel skids on the ground (for skid sounds/smoke etc.)
0.0 = wheels are sliding, 1.0 = wheels have traction.floatcom.bulletphysics.dynamics.vehicle.WheelInfofloatfloatcom.jme3.scene.SpatialvoidgetWheelWorldLocation(com.jme3.math.Vector3f store) write the content of the wheelWorldLocation into the storevoidgetWheelWorldRotation(com.jme3.math.Quaternion store) write the content of the wheelWorldRotation into the storebooleanbooleanvoidread(com.jme3.export.JmeImporter im) voidsetApplyLocal(boolean applyLocal) voidsetFrictionSlip(float frictionSlip) the coefficient of friction between the tyre and the ground.voidsetFrontWheel(boolean frontWheel) voidsetMaxSuspensionForce(float maxSuspensionForce) The maximum suspension force, raise this above the default 6000 if your suspension cannot handle the weight of your vehicle.voidsetMaxSuspensionTravelCm(float maxSuspensionTravelCm) the maximum distance the suspension can be compressed (centimetres)voidsetRadius(float radius) voidsetRestLength(float restLength) voidsetRollInfluence(float rollInfluence) reduces the rolling torque applied from the wheels that cause the vehicle to roll over.voidsetSuspensionStiffness(float suspensionStiffness) the stiffness constant for the suspension.voidsetWheelInfo(com.bulletphysics.dynamics.vehicle.WheelInfo wheelInfo) voidsetWheelsDampingCompression(float wheelsDampingCompression) the damping coefficient for when the suspension is compressed.voidsetWheelsDampingRelaxation(float wheelsDampingRelaxation) the damping coefficient for when the suspension is expanding.voidsetWheelSpatial(com.jme3.scene.Spatial wheelSpatial) voidvoidwrite(com.jme3.export.JmeExporter ex)
-
Field Details
-
wheelInfo
protected com.bulletphysics.dynamics.vehicle.WheelInfo wheelInfo -
frontWheel
protected boolean frontWheel -
location
protected com.jme3.math.Vector3f location -
direction
protected com.jme3.math.Vector3f direction -
axle
protected com.jme3.math.Vector3f axle -
suspensionStiffness
protected float suspensionStiffness -
wheelsDampingRelaxation
protected float wheelsDampingRelaxation -
wheelsDampingCompression
protected float wheelsDampingCompression -
frictionSlip
protected float frictionSlip -
rollInfluence
protected float rollInfluence -
maxSuspensionTravelCm
protected float maxSuspensionTravelCm -
maxSuspensionForce
protected float maxSuspensionForce -
radius
protected float radius -
restLength
protected float restLength -
wheelWorldLocation
protected com.jme3.math.Vector3f wheelWorldLocation -
wheelWorldRotation
protected com.jme3.math.Quaternion wheelWorldRotation -
wheelSpatial
protected com.jme3.scene.Spatial wheelSpatial -
tmp_Matrix
protected com.jme3.math.Matrix3f tmp_Matrix -
tmp_inverseWorldRotation
protected final com.jme3.math.Quaternion tmp_inverseWorldRotation
-
-
Constructor Details
-
VehicleWheel
protected VehicleWheel() -
VehicleWheel
public VehicleWheel(com.jme3.scene.Spatial spat, com.jme3.math.Vector3f location, com.jme3.math.Vector3f direction, com.jme3.math.Vector3f axle, float restLength, float radius, boolean frontWheel) -
VehicleWheel
public VehicleWheel(com.jme3.math.Vector3f location, com.jme3.math.Vector3f direction, com.jme3.math.Vector3f axle, float restLength, float radius, boolean frontWheel)
-
-
Method Details
-
updatePhysicsState
public void updatePhysicsState() -
applyWheelTransform
public void applyWheelTransform() -
getWheelInfo
public com.bulletphysics.dynamics.vehicle.WheelInfo getWheelInfo() -
setWheelInfo
public void setWheelInfo(com.bulletphysics.dynamics.vehicle.WheelInfo wheelInfo) -
isFrontWheel
public boolean isFrontWheel() -
setFrontWheel
public void setFrontWheel(boolean frontWheel) -
getLocation
public com.jme3.math.Vector3f getLocation() -
getDirection
public com.jme3.math.Vector3f getDirection() -
getAxle
public com.jme3.math.Vector3f getAxle() -
getSuspensionStiffness
public float getSuspensionStiffness() -
setSuspensionStiffness
public void setSuspensionStiffness(float suspensionStiffness) the stiffness constant for the suspension. 10.0 - Offroad buggy, 50.0 - Sports car, 200.0 - F1 Car- Parameters:
suspensionStiffness- the desired stiffness coefficient (10→off-road buggy, 50→sports car, 200→Formula-1 race car, default=20)
-
getWheelsDampingRelaxation
public float getWheelsDampingRelaxation() -
setWheelsDampingRelaxation
public void setWheelsDampingRelaxation(float wheelsDampingRelaxation) the damping coefficient for when the suspension is expanding. See the comments for setWheelsDampingCompression for how to set k.- Parameters:
wheelsDampingRelaxation- the desired damping coefficient (default=2.3)
-
getWheelsDampingCompression
public float getWheelsDampingCompression() -
setWheelsDampingCompression
public void setWheelsDampingCompression(float wheelsDampingCompression) the damping coefficient for when the suspension is compressed. Set to k * 2.0 * FastMath.sqrt(m_suspensionStiffness) so k is proportional to critical damping.
k = 0.0 undamped/bouncy, k = 1.0 critical damping
0.1 to 0.3 are good values- Parameters:
wheelsDampingCompression- the desired damping coefficient (default=4.4)
-
getFrictionSlip
public float getFrictionSlip() -
setFrictionSlip
public void setFrictionSlip(float frictionSlip) the coefficient of friction between the tyre and the ground. Should be about 0.8 for realistic cars, but can be increased for better handling. Set large (10000.0) for kart racers- Parameters:
frictionSlip- the desired coefficient of friction between tyre and ground (0.8→realistic car, 10000→kart racer, default=10.5)
-
getRollInfluence
public float getRollInfluence() -
setRollInfluence
public void setRollInfluence(float rollInfluence) reduces the rolling torque applied from the wheels that cause the vehicle to roll over. This is a bit of a hack, but it's quite effective. 0.0 = no roll, 1.0 = physical behaviour. If m_frictionSlip is too high, you'll need to reduce this to stop the vehicle rolling over. You should also try lowering the vehicle's centre of mass- Parameters:
rollInfluence- the rollInfluence to set
-
getMaxSuspensionTravelCm
public float getMaxSuspensionTravelCm() -
setMaxSuspensionTravelCm
public void setMaxSuspensionTravelCm(float maxSuspensionTravelCm) the maximum distance the suspension can be compressed (centimetres)- Parameters:
maxSuspensionTravelCm- 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)
-
getMaxSuspensionForce
public float getMaxSuspensionForce() -
setMaxSuspensionForce
public void setMaxSuspensionForce(float maxSuspensionForce) The maximum suspension force, raise this above the default 6000 if your suspension cannot handle the weight of your vehicle.- Parameters:
maxSuspensionForce- the desired maximum force per wheel (default=6000)
-
getRadius
public float getRadius() -
setRadius
public void setRadius(float radius) -
getRestLength
public float getRestLength() -
setRestLength
public void setRestLength(float restLength) -
getGroundObject
returns the object this wheel is in contact with or null if no contact- Returns:
- the PhysicsCollisionObject (PhysicsRigidBody, PhysicsGhostObject)
-
getCollisionLocation
public com.jme3.math.Vector3f getCollisionLocation(com.jme3.math.Vector3f vec) returns the location where the wheel collides with the ground (world space)- Parameters:
vec- storage for the result (not null, modified)- Returns:
- a location vector (in physics-space coordinates)
-
getCollisionLocation
public com.jme3.math.Vector3f getCollisionLocation()returns the location where the wheel collides with the ground (world space)- Returns:
- a new location vector (in physics-space coordinates)
-
getCollisionNormal
public com.jme3.math.Vector3f getCollisionNormal(com.jme3.math.Vector3f vec) returns the normal where the wheel collides with the ground (world space)- Parameters:
vec- storage for the result (not null, modified)- Returns:
- a unit vector (in physics-space coordinates)
-
getCollisionNormal
public com.jme3.math.Vector3f getCollisionNormal()returns the normal where the wheel collides with the ground (world space)- Returns:
- a new unit vector (in physics-space coordinates)
-
getSkidInfo
public float getSkidInfo()returns how much the wheel skids on the ground (for skid sounds/smoke etc.)
0.0 = wheels are sliding, 1.0 = wheels have traction.- Returns:
- the relative amount of traction (0→wheel is sliding, 1→wheel has full traction)
-
getDeltaRotation
public float getDeltaRotation()returns how many degrees the wheel has turned since the last physics step.- Returns:
- the rotation angle (in radians)
-
read
- Specified by:
readin interfacecom.jme3.export.Savable- Throws:
IOException
-
write
- Specified by:
writein interfacecom.jme3.export.Savable- Throws:
IOException
-
getWheelSpatial
public com.jme3.scene.Spatial getWheelSpatial()- Returns:
- the wheelSpatial
-
setWheelSpatial
public void setWheelSpatial(com.jme3.scene.Spatial wheelSpatial) - Parameters:
wheelSpatial- the wheelSpatial to set
-
isApplyLocal
public boolean isApplyLocal() -
setApplyLocal
public void setApplyLocal(boolean applyLocal) -
getWheelWorldRotation
public void getWheelWorldRotation(com.jme3.math.Quaternion store) write the content of the wheelWorldRotation into the store- Parameters:
store- storage for the result (not null, modified)
-
getWheelWorldLocation
public void getWheelWorldLocation(com.jme3.math.Vector3f store) write the content of the wheelWorldLocation into the store- Parameters:
store- storage for the result (not null, modified)
-