|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.bullet.collision.PhysicsCollisionObject
com.jme3.bullet.objects.PhysicsRigidBody
com.jme3.bullet.objects.PhysicsVehicle
public class PhysicsVehicle
PhysicsVehicleNode - Special PhysicsNode that implements vehicle functions
From bullet manual:
For most vehicle simulations, it is recommended to use the simplified Bullet
vehicle model as provided in btRaycastVehicle. Instead of simulation each wheel
and chassis as separate rigid bodies, connected by constraints, it uses a simplified model.
This simplified model has many benefits, and is widely used in commercial driving games.
The entire vehicle is represented as a single rigidbody, the chassis.
The collision detection of the wheels is approximated by ray casts,
and the tire friction is a basic anisotropic friction model.
Field Summary | |
---|---|
protected PhysicsSpace |
physicsSpace
|
protected long |
rayCasterId
|
protected VehicleTuning |
tuning
|
protected long |
vehicleId
|
protected java.util.ArrayList<VehicleWheel> |
wheels
|
Fields inherited from class com.jme3.bullet.objects.PhysicsRigidBody |
---|
joints, kinematic, mass, motionState |
Constructor Summary | |
---|---|
PhysicsVehicle()
|
|
PhysicsVehicle(CollisionShape shape)
|
|
PhysicsVehicle(CollisionShape shape,
float mass)
|
Method Summary | |
---|---|
void |
accelerate(float force)
Apply the given engine force to all wheels, works continuously |
void |
accelerate(int wheel,
float force)
Apply the given engine force, works continuously |
VehicleWheel |
addWheel(Spatial spat,
Vector3f connectionPoint,
Vector3f direction,
Vector3f axle,
float suspensionRestLength,
float wheelRadius,
boolean isFrontWheel)
Add a wheel to this vehicle |
VehicleWheel |
addWheel(Vector3f connectionPoint,
Vector3f direction,
Vector3f axle,
float suspensionRestLength,
float wheelRadius,
boolean isFrontWheel)
Add a wheel to this vehicle |
void |
applyWheelTransforms()
used internally |
void |
brake(float force)
Apply the given brake force to all wheels, works continuously |
void |
brake(int wheel,
float force)
Apply the given brake force, works continuously |
void |
createVehicle(PhysicsSpace space)
Used internally, creates the actual vehicle constraint when vehicle is added to phyicsspace |
protected void |
finalize()
|
float |
getCurrentVehicleSpeedKmHour()
Get the current speed of the vehicle in km/h |
protected Spatial |
getDebugShape()
|
Vector3f |
getForwardVector(Vector3f vector)
Get the current forward vector of the vehicle in world coordinates |
float |
getFrictionSlip()
|
float |
getMaxSuspensionForce()
|
float |
getMaxSuspensionTravelCm()
|
int |
getNumWheels()
|
float |
getSuspensionCompression()
|
float |
getSuspensionDamping()
|
float |
getSuspensionStiffness()
|
long |
getVehicleId()
used internally |
VehicleWheel |
getWheel(int wheel)
You can get access to the single wheels via this method. |
protected void |
postRebuild()
|
void |
read(JmeImporter im)
|
void |
removeWheel(int wheel)
This rebuilds the vehicle as there is no way in bullet to remove a wheel. |
void |
resetSuspension()
Reset the suspension |
void |
setFrictionSlip(float frictionSlip)
Use before adding wheels, this is the default used when adding wheels. |
void |
setFrictionSlip(int wheel,
float frictionSlip)
The coefficient of friction between the tyre and the ground. |
void |
setMaxSuspensionForce(float maxSuspensionForce)
This vaue caps the maximum suspension force, raise this above the default 6000 if your suspension cannot handle the weight of your vehcile. |
void |
setMaxSuspensionForce(int wheel,
float maxSuspensionForce)
This vaue caps the maximum suspension force, raise this above the default 6000 if your suspension cannot handle the weight of your vehcile. |
void |
setMaxSuspensionTravelCm(float maxSuspensionTravelCm)
Use before adding wheels, this is the default used when adding wheels. |
void |
setMaxSuspensionTravelCm(int wheel,
float maxSuspensionTravelCm)
The maximum distance the suspension can be compressed (centimetres) |
void |
setRollInfluence(int wheel,
float rollInfluence)
Reduces the rolling torque applied from the wheels that cause the vehicle to roll over. |
void |
setSuspensionCompression(float suspensionCompression)
Use before adding wheels, this is the default used when adding wheels. |
void |
setSuspensionCompression(int wheel,
float suspensionCompression)
The damping coefficient for when the suspension is compressed. |
void |
setSuspensionDamping(float suspensionDamping)
Use before adding wheels, this is the default used when adding wheels. |
void |
setSuspensionDamping(int wheel,
float suspensionDamping)
The damping coefficient for when the suspension is expanding. |
void |
setSuspensionStiffness(float suspensionStiffness)
Use before adding wheels, this is the default used when adding wheels. |
void |
setSuspensionStiffness(int wheel,
float suspensionStiffness)
The stiffness constant for the suspension. |
void |
steer(float value)
Set the given steering value to all front wheels (0 = forward) |
void |
steer(int wheel,
float value)
Set the given steering value to the given wheel (0 = forward) |
void |
updateWheels()
used internally |
void |
write(JmeExporter ex)
|
Methods inherited from class com.jme3.bullet.collision.PhysicsCollisionObject |
---|
addCollideWithGroup, attachCollisionShape, attachDebugShape, attachDebugShape, attachDebugShape, createDebugShape, debugShape, detachDebugShape, finalizeNative, getCollideWithGroups, getCollisionGroup, getCollisionShape, getObjectId, getUserObject, initUserPointer, removeCollideWithGroup, setCollideWithGroups, setCollisionGroup, setUserObject, updateDebugShape |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected long vehicleId
protected long rayCasterId
protected VehicleTuning tuning
protected java.util.ArrayList<VehicleWheel> wheels
protected PhysicsSpace physicsSpace
Constructor Detail |
---|
public PhysicsVehicle()
public PhysicsVehicle(CollisionShape shape)
public PhysicsVehicle(CollisionShape shape, float mass)
Method Detail |
---|
public void updateWheels()
public void applyWheelTransforms()
protected void postRebuild()
postRebuild
in class PhysicsRigidBody
public void createVehicle(PhysicsSpace space)
public VehicleWheel addWheel(Vector3f connectionPoint, Vector3f direction, Vector3f axle, float suspensionRestLength, float wheelRadius, boolean isFrontWheel)
connectionPoint
- The starting point of the ray, where the suspension connects to the chassis (chassis space)direction
- the direction of the wheel (should be -Y / 0,-1,0 for a normal car)axle
- The axis of the wheel, pointing right in vehicle direction (should be -X / -1,0,0 for a normal car)suspensionRestLength
- The current length of the suspension (metres)wheelRadius
- the wheel radiusisFrontWheel
- sets if this wheel is a front wheel (steering)
public VehicleWheel addWheel(Spatial spat, Vector3f connectionPoint, Vector3f direction, Vector3f axle, float suspensionRestLength, float wheelRadius, boolean isFrontWheel)
spat
- the wheel GeometryconnectionPoint
- The starting point of the ray, where the suspension connects to the chassis (chassis space)direction
- the direction of the wheel (should be -Y / 0,-1,0 for a normal car)axle
- The axis of the wheel, pointing right in vehicle direction (should be -X / -1,0,0 for a normal car)suspensionRestLength
- The current length of the suspension (metres)wheelRadius
- the wheel radiusisFrontWheel
- sets if this wheel is a front wheel (steering)
public void removeWheel(int wheel)
wheel
- public VehicleWheel getWheel(int wheel)
wheel
- the wheel index
public int getNumWheels()
public float getFrictionSlip()
public void setFrictionSlip(float frictionSlip)
frictionSlip
- the frictionSlip to setpublic void setFrictionSlip(int wheel, float frictionSlip)
wheel
- frictionSlip
- public void setRollInfluence(int wheel, float rollInfluence)
public float getMaxSuspensionTravelCm()
public void setMaxSuspensionTravelCm(float maxSuspensionTravelCm)
maxSuspensionTravelCm
- the maxSuspensionTravelCm to setpublic void setMaxSuspensionTravelCm(int wheel, float maxSuspensionTravelCm)
wheel
- maxSuspensionTravelCm
- public float getMaxSuspensionForce()
public void setMaxSuspensionForce(float maxSuspensionForce)
maxSuspensionForce
- public void setMaxSuspensionForce(int wheel, float maxSuspensionForce)
wheel
- maxSuspensionForce
- public float getSuspensionCompression()
public void setSuspensionCompression(float suspensionCompression)
suspensionCompression
- the suspensionCompression to setpublic void setSuspensionCompression(int wheel, float suspensionCompression)
wheel
- suspensionCompression
- public float getSuspensionDamping()
public void setSuspensionDamping(float suspensionDamping)
suspensionDamping
- the suspensionDamping to setpublic void setSuspensionDamping(int wheel, float suspensionDamping)
wheel
- suspensionDamping
- public float getSuspensionStiffness()
public void setSuspensionStiffness(float suspensionStiffness)
suspensionStiffness
- public void setSuspensionStiffness(int wheel, float suspensionStiffness)
wheel
- suspensionStiffness
- public void resetSuspension()
public void accelerate(float force)
force
- the forcepublic void accelerate(int wheel, float force)
wheel
- the wheel to apply the force onforce
- the forcepublic void steer(float value)
value
- the steering angle of the front wheels (Pi = 360deg)public void steer(int wheel, float value)
wheel
- the wheel to set the steering onvalue
- the steering angle of the front wheels (Pi = 360deg)public void brake(float force)
force
- the forcepublic void brake(int wheel, float force)
wheel
- the wheel to apply the force onforce
- the forcepublic float getCurrentVehicleSpeedKmHour()
public Vector3f getForwardVector(Vector3f vector)
vector
-
public long getVehicleId()
protected Spatial getDebugShape()
getDebugShape
in class PhysicsRigidBody
public void read(JmeImporter im) throws java.io.IOException
read
in interface Savable
read
in class PhysicsRigidBody
java.io.IOException
public void write(JmeExporter ex) throws java.io.IOException
write
in interface Savable
write
in class PhysicsRigidBody
java.io.IOException
protected void finalize() throws java.lang.Throwable
finalize
in class PhysicsCollisionObject
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |