Package com.jme3.bullet.objects.infos
Class VehicleController
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.objects.infos.VehicleController
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
The "action" (controller) portion of a PhysicsVehicle, based on Bullet's
btRaycastVehicle.
-
Field Summary
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ConstructorDescriptionVehicleController
(PhysicsVehicle vehicle, PhysicsSpace space) Instantiate a controller for the specified collision object. -
Method Summary
Modifier and TypeMethodDescriptionint
addWheel
(VehicleWheel wheel, VehicleTuning tuning) Add a wheel to this controller.void
applyEngineForce
(VehicleWheel wheel, float force) Apply the specified engine force to the specified wheel.void
brake
(VehicleWheel wheel, float impulse) Apply the specified brake impulse to the specified wheel.float
castRay
(VehicleWheel wheel) Determine the depth for the specified wheel by raycasting.int
Determine the number of wheels in this controller.int
Determine the index of the vehicle's forward axis.float
Determine the vehicle's speed in km/h.com.jme3.math.Vector3f
getForwardVector
(com.jme3.math.Vector3f storeResult) Determine the vehicle's forward direction.void
Reset the vehicle's suspension.int
Determine the index of the vehicle's right-side axis.void
setCoordinateSystem
(int rightAxisIndex, int upAxisIndex, int forwardAxisIndex) Alter the coordinate system of the vehicle.void
setCoordinateSystem
(com.jme3.math.Vector3f right, com.jme3.math.Vector3f up, com.jme3.math.Vector3f forward) Customize the coordinate system of the vehicle.void
steer
(VehicleWheel wheel, float angle) Alter the steering angle of the specified wheel.int
Determine the index of the vehicle's up axis.void
updateWheelTransform
(VehicleWheel wheel) Used internally.Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, toString, unassignNativeObject
-
Field Details
-
logger
message logger for this class
-
-
Constructor Details
-
VehicleController
Instantiate a controller for the specified collision object.- Parameters:
vehicle
- the collision object to control (not null)space
- the PhysicsSpace where the collision object is or will be added (not null)
-
-
Method Details
-
addWheel
Add a wheel to this controller. Used internally.- Parameters:
wheel
- (not null, unaffected)tuning
- (not null, unaffected)- Returns:
- the wheel index to be assigned (≥0)
-
applyEngineForce
Apply the specified engine force to the specified wheel. Works continuously. The vehicle must be added to a PhysicsSpace.- Parameters:
wheel
- which wheel (not null)force
- the desired amount of force (may be negative)
-
brake
Apply the specified brake impulse to the specified wheel. Works continuously. The vehicle must be added to a PhysicsSpace.- Parameters:
wheel
- which wheel (not null)impulse
- the desired impulse
-
castRay
Determine the depth for the specified wheel by raycasting. The vehicle must be added to a PhysicsSpace.- Parameters:
wheel
- which wheel (not null, unaffected)- Returns:
- the depth value, or -1 if the raycast finds no result
-
countWheels
public int countWheels()Determine the number of wheels in this controller.- Returns:
- the count (≥0)
-
forwardAxisIndex
public int forwardAxisIndex()Determine the index of the vehicle's forward axis. The vehicle must be added to a PhysicsSpace.- Returns:
- the index of the local axis: 0→X, 1→Y, 2→Z, -1→custom axes
-
getCurrentVehicleSpeedKmHour
public float getCurrentVehicleSpeedKmHour()Determine the vehicle's speed in km/h. The vehicle must be added to a PhysicsSpace.- Returns:
- the speed (in kilometers per hour, positive in the forward direction)
-
getForwardVector
public com.jme3.math.Vector3f getForwardVector(com.jme3.math.Vector3f storeResult) Determine the vehicle's forward direction. The vehicle must be added to a PhysicsSpace.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a direction vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
resetSuspension
public void resetSuspension()Reset the vehicle's suspension. The vehicle must be added to a PhysicsSpace. -
rightAxisIndex
public int rightAxisIndex()Determine the index of the vehicle's right-side axis. The vehicle must be added to a PhysicsSpace.- Returns:
- the index of the local axis: 0→X, 1→Y, 2→Z, -1→custom axes
-
setCoordinateSystem
public void setCoordinateSystem(int rightAxisIndex, int upAxisIndex, int forwardAxisIndex) Alter the coordinate system of the vehicle. Note that the Libbulletjme's default coordinate system is left-handed. That's not required, nor is it even a good idea.- Parameters:
rightAxisIndex
- the desired local axis index (0→X, 1→Y, 2→Z, default=0)upAxisIndex
- the desired local axis index (0→X, 1→Y, 2→Z, default=1)forwardAxisIndex
- the desired local axis index (0→X, 1→Y, 2→Z, default=2)
-
setCoordinateSystem
public void setCoordinateSystem(com.jme3.math.Vector3f right, com.jme3.math.Vector3f up, com.jme3.math.Vector3f forward) Customize the coordinate system of the vehicle. The arguments must form an orthonormal basis. Note that the Libbulletjme's default coordinate system is left-handed. That's not required, nor is it even a good idea.- Parameters:
right
- the desired direction (in chassis coordinates, not null, length=1, default=(1,0,0))up
- the desired direction (in chassis coordinates, not null, length=1, default=(0,1,0))forward
- the desired direction (in chassis coordinates, not null, length=1, default=(0,0,1))
-
steer
Alter the steering angle of the specified wheel. The vehicle must be added to a PhysicsSpace.- Parameters:
wheel
- which wheel to steer (not null)angle
- the desired angle (in radians, 0=straight, positive=left)
-
upAxisIndex
public int upAxisIndex()Determine the index of the vehicle's up axis. The vehicle must be added to a PhysicsSpace.- Returns:
- the index of the local axis: 0→X, 1→Y, 2→Z, -1→custom axes
-
updateWheelTransform
Used internally.- Parameters:
wheel
- (not null)
-