|
|
@@ -123,7 +123,8 @@ The `addWheel()` method sets following properties:
|
|
|
* Vector3f axle – Axle direction is typically a (-1,0,0) vector.
|
|
|
* float suspensionRestLength – Suspension rest length in world units
|
|
|
* float wheelRadius – Wheel radius in world units
|
|
|
-* boolean isFrontWheel – Whether this wheel is one of the steering wheels. +Front wheels are the ones that rotate visibly when the vehicle turns.
|
|
|
+* boolean isFrontWheel – Whether this wheel is one of the steering wheels. +
|
|
|
+Front wheels are the ones that rotate visibly when the vehicle turns.
|
|
|
|
|
|
We initialize a few variables that we will reuse when we add the four wheels. yOff, etc, are the particular wheel offsets for our small vehicle model.
|
|
|
|
|
|
@@ -211,10 +212,14 @@ Not shown here is the standard way how we map the input keys to actions (see ful
|
|
|
|
|
|
In the ActionListener, we implement the actions that control the vehicle's direction and speed. For the four directions (accelerate=up, brake=down, left, right), we specify how we want the vehicle to move.
|
|
|
|
|
|
-* The braking action is pretty straightforward: +`vehicle.brake(brakeForce)`
|
|
|
-* For left and right turns, we add a constant to `steeringValue` when the key is pressed, and subtract it when the key is released. +`vehicle.steer(steeringValue);`
|
|
|
-* For acceleration we add a constant to `accelerationValue` when the key is pressed, and substract it when the key is released. +`vehicle.accelerate(accelerationValue);`
|
|
|
-* Because we can and it's fun, we also add a turbo booster that makes the vehicle jump when you press the assigned key (spacebar). +`vehicle.applyImpulse(jumpForce, Vector3f.ZERO);`
|
|
|
+* The braking action is pretty straightforward: +
|
|
|
+`vehicle.brake(brakeForce)`
|
|
|
+* For left and right turns, we add a constant to `steeringValue` when the key is pressed, and subtract it when the key is released. +
|
|
|
+`vehicle.steer(steeringValue);`
|
|
|
+* For acceleration we add a constant to `accelerationValue` when the key is pressed, and substract it when the key is released. +
|
|
|
+`vehicle.accelerate(accelerationValue);`
|
|
|
+* Because we can and it's fun, we also add a turbo booster that makes the vehicle jump when you press the assigned key (spacebar). +
|
|
|
+`vehicle.applyImpulse(jumpForce, Vector3f.ZERO);`
|
|
|
|
|
|
[source,java]
|
|
|
----
|