#include <PhysicsVehicle.h>
Public Member Functions | |
PhysicsCollisionObject::Type | getType () const |
PhysicsRigidBody * | getRigidBody () const |
void | setEnabled (bool enable) |
unsigned int | getWheelCount () const |
PhysicsVehicleWheel * | getWheel (unsigned int i) |
void | addWheel (PhysicsVehicleWheel *wheel) |
float | getSpeedKph () const |
float | getSpeedSmoothKph () const |
void | update (float elapsedTime, float steering, float braking, float driving) |
void | reset () |
float | getSteeringGain () const |
void | setSteeringGain (float steeringGain) |
float | getBrakingForce () const |
void | setBrakingForce (float brakingForce) |
float | getDrivingForce () const |
void | setDrivingForce (float drivingForce) |
float | getSteerdownSpeed () const |
float | getSteerdownGain () const |
void | setSteerdown (float steerdownSpeed, float steerdownGain) |
float | getBrakedownStart () const |
float | getBrakedownFull () const |
void | setBrakedown (float brakedownStart, float brakedownFull) |
float | getDrivedownStart () const |
float | getDrivedownFull () const |
void | setDrivedown (float drivedownStart, float drivedownFull) |
float | getBoostSpeed () const |
float | getBoostGain () const |
void | setBoost (float boostSpeed, float boostGain) |
float | getDownforce () const |
void | setDownforce (float downforce) |
Protected Member Functions | |
btCollisionObject * | getCollisionObject () const |
Defines a class for vehicle physics.
In addition to its own properties defined below, a vehicle has available to it all of the properties of a rigid body such as shape, mass, friction, etc which correspond to the vehicle body:
void gameplay::PhysicsVehicle::addWheel | ( | PhysicsVehicleWheel * | wheel | ) |
Permanently adds a wheel to this vehicle.
wheel | the wheel to add. |
float gameplay::PhysicsVehicle::getBoostGain | ( | ) | const |
Returns boost gain at zero speed, typically greater than 1. Driving force is boosted by this factor at zero speed, and that factor fades linearly with speed reaching 1 at a specified speed.
float gameplay::PhysicsVehicle::getBoostSpeed | ( | ) | const |
Returns upper limit of low-speed boost effect, in km/h. Driving force is boosted by a specified factor at zero speed, and that factor fades linearly with speed reaching 1 at this speed.
float gameplay::PhysicsVehicle::getBrakedownFull | ( | ) | const |
Returns speed where braking is fully faded, in km/h. This speed is typically greater than the brakedownStart speed.
float gameplay::PhysicsVehicle::getBrakedownStart | ( | ) | const |
Returns speed where braking starts to fade, in km/h.
float gameplay::PhysicsVehicle::getBrakingForce | ( | ) | const |
Gets braking force at full braking.
btCollisionObject* gameplay::PhysicsVehicle::getCollisionObject | ( | ) | const [protected, virtual] |
Implements gameplay::PhysicsCollisionObject.
float gameplay::PhysicsVehicle::getDownforce | ( | ) | const |
Returns the lumped constant that controls aerodynamic downforce. Technically speaking, this constant lumps together the reference area and the down-force coefficient, and is in world-units squared. The actual aerodynamic down-force is calculated as a function of current speed, and is proportional to this constant.
float gameplay::PhysicsVehicle::getDrivedownFull | ( | ) | const |
Returns speed where driving force is fully faded, in km/h. This speed is typically greater than the drivedownStart speed.
float gameplay::PhysicsVehicle::getDrivedownStart | ( | ) | const |
Returns speed where driving force starts to fade, in km/h.
float gameplay::PhysicsVehicle::getDrivingForce | ( | ) | const |
Gets driving force at full throttle.
Returns the rigid body associated with this vehicle.
float gameplay::PhysicsVehicle::getSpeedKph | ( | ) | const |
Gets an indication of vehicle speed in kilometers per hour.
float gameplay::PhysicsVehicle::getSpeedSmoothKph | ( | ) | const |
Gets a lagged version of vehicle speed in kilometers per hour, for example that might be used to control engine sounds.
float gameplay::PhysicsVehicle::getSteerdownGain | ( | ) | const |
Returns gain at the point of reduced steering, typically less than 1. A point of reduced steering is defined by speed and gain. Steering authority will reduce linearly with speed up to this point, and remain constant above that.
float gameplay::PhysicsVehicle::getSteerdownSpeed | ( | ) | const |
Returns speed at the point of reduced steering, in km/h. A point of reduced steering is defined by speed and gain. Steering authority will reduce linearly with speed up to this point, and remain constant above that.
float gameplay::PhysicsVehicle::getSteeringGain | ( | ) | const |
Gets steering gain at full deflection.
PhysicsCollisionObject::Type gameplay::PhysicsVehicle::getType | ( | ) | const [virtual] |
Implements gameplay::PhysicsCollisionObject.
PhysicsVehicleWheel* gameplay::PhysicsVehicle::getWheel | ( | unsigned int | i | ) |
Gets the wheel at the specified index.
i | index of wheel. |
unsigned int gameplay::PhysicsVehicle::getWheelCount | ( | ) | const |
Gets the number of wheels on this vehicle.
void gameplay::PhysicsVehicle::reset | ( | ) |
Resets the vehicle's state, for example in preparation for a reposition.
void gameplay::PhysicsVehicle::setBoost | ( | float | boostSpeed, |
float | boostGain | ||
) |
Sets parameters that define low-speed boost of the driving force. Driving force is boosted by the specified factor at zero speed, and that factor fades linearly with speed reaching 1 at the specified speed.
boostSpeed | upper limit of low-speed boost effect, in km/h. |
boostGain | boost gain at zero speed, typically greater than 1. A gain of 1 will effectively disable the feature. |
void gameplay::PhysicsVehicle::setBrakedown | ( | float | brakedownStart, |
float | brakedownFull | ||
) |
Sets points that control fade of brake force with speed, in km/h.
brakedownStart | braking fades above this speed. A very large value will effectively disable the feature. |
brakedownFull | braking is fully faded at this speed. This speed is typically greater than the brakedownStart speed. |
void gameplay::PhysicsVehicle::setBrakingForce | ( | float | brakingForce | ) |
Sets braking force at full braking.
brakingForce | braking force at full braking. |
void gameplay::PhysicsVehicle::setDownforce | ( | float | downforce | ) |
Sets the lumped constant that controls aerodynamic downforce. Technically speaking, this constant lumps together the reference area and the down-force coefficient, and is in world-units squared. The actual aerodynamic down-force is calculated as a function of current speed, and is proportional to this constant.
downforce | the lumped constant that controls aerodynamic downforce. A value of 0 will effectively disable this feature. |
void gameplay::PhysicsVehicle::setDrivedown | ( | float | drivedownStart, |
float | drivedownFull | ||
) |
Sets points that control fade of driving force with speed, in km/h.
drivedownStart | driving force fades above this speed. A very large value will effectively disable the feature. |
drivedownFull | driving force is fully faded at this speed. This speed is typically greater than the drivedownStart speed. |
void gameplay::PhysicsVehicle::setDrivingForce | ( | float | drivingForce | ) |
Sets driving force at full throttle.
drivingForce | driving force at full throttle. |
void gameplay::PhysicsVehicle::setEnabled | ( | bool | enable | ) |
Sets whether the associated rigid body is enabled or disabled in the physics world.
enable | true enables the collision object, false disables it. |
Reimplemented from gameplay::PhysicsCollisionObject.
void gameplay::PhysicsVehicle::setSteerdown | ( | float | steerdownSpeed, |
float | steerdownGain | ||
) |
Sets the point of reduced steering, defined by speed and gain. Typically the gain value is less than 1. Steering authority will reduce linearly with speed up to this point, and remain constant above that.
steerdownSpeed | speed at the point of reduced steering, in km/h. |
steerdownGain | gain at the point of reduced steering. A gain of 1 will effectively disable the feature. |
void gameplay::PhysicsVehicle::setSteeringGain | ( | float | steeringGain | ) |
Sets steering gain at full deflection.
steeringGain | steering gain at full deflection. |
void gameplay::PhysicsVehicle::update | ( | float | elapsedTime, |
float | steering, | ||
float | braking, | ||
float | driving | ||
) |
Updates the vehicle state using the specified normalized command inputs, and updates the transform on the visual node for each wheel.
elapsedTime | The elapsed game time. |
steering | steering command (-1 to 1). |
braking | braking command (0 to 1). |
driving | net drivetrain command (0 to 1). |