Simulates a raycast vehicle which casts a ray per wheel at the ground as a cheap replacement for complex suspension simulation. More...
#include "bulletVehicle.h"
Public Member Functions | |
BulletVehicle (BulletWorld *world, BulletRigidBodyNode *chassis) | |
Creates a new BulletVehicle instance in the given world and with a chassis node. More... | |
void | apply_engine_force (PN_stdfloat force, int idx) |
Applies force at the wheel with index idx for acceleration. More... | |
BulletWheel | create_wheel () |
Factory method for creating wheels for this vehicle instance. More... | |
BulletRigidBodyNode * | do_get_chassis () |
Returns the chassis of this vehicle. More... | |
void | do_sync_b2p () |
Assumes the lock(bullet global lock) is held by the caller. More... | |
virtual TypeHandle | force_init_type () |
BulletRigidBodyNode * | get_chassis () |
PN_stdfloat | get_current_speed_km_hour () const |
LVector3 | get_forward_vector () const |
int | get_num_wheels () const |
PN_stdfloat | get_steering_value (int idx) const |
Returns the steering angle of the wheel with index idx in degrees. More... | |
BulletVehicleTuning & | get_tuning () |
virtual TypeHandle | get_type () const |
btRaycastVehicle * | get_vehicle () const |
BulletWheel | get_wheel (int idx) const |
void | reset_suspension () |
Resets the vehicle's suspension. More... | |
void | set_brake (PN_stdfloat brake, int idx) |
Applies braking force to the wheel with index idx. More... | |
void | set_coordinate_system (BulletUpAxis up) |
Specifies which axis is "up". More... | |
void | set_pitch_control (PN_stdfloat pitch) |
void | set_steering_value (PN_stdfloat steering, int idx) |
Sets the steering value (in degrees) of the wheel with index idx. More... | |
![]() | |
TypedReferenceCount (const TypedReferenceCount ©) | |
void | operator= (const TypedReferenceCount ©) |
![]() | |
TypedObject (const TypedObject ©)=default | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
int | get_best_parent_from_Set (const std::set< int > &) const |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
TypedObject & | operator= (const TypedObject ©)=default |
![]() | |
int | get_ref_count () const |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
Public Attributes | |
get_chassis | |
Returns the chassis of this vehicle. More... | |
get_current_speed_km_hour | |
Returns the current speed in kilometers per hour. More... | |
get_forward_vector | |
Returns the forward vector representing the car's actual direction of movement. More... | |
get_num_wheels | |
Returns the number of wheels this vehicle has. More... | |
get_tuning | |
Returns a reference to the BulletVehicleTuning object of this vehicle which offers various vehicle-global tuning options. More... | |
get_wheel | |
Returns the BulletWheel with index idx. More... | |
![]() | |
get_type | |
![]() | |
get_ref_count | |
Returns the current reference count. More... | |
Simulates a raycast vehicle which casts a ray per wheel at the ground as a cheap replacement for complex suspension simulation.
The suspension can be tuned in various ways. It is possible to add a (probably) arbitrary number of wheels.
Definition at line 68 of file bulletVehicle.h.
BulletVehicle::BulletVehicle | ( | BulletWorld * | world, |
BulletRigidBodyNode * | chassis | ||
) |
Creates a new BulletVehicle instance in the given world and with a chassis node.
Definition at line 29 of file bulletVehicle.cxx.
References set_coordinate_system().
void BulletVehicle::apply_engine_force | ( | PN_stdfloat | force, |
int | idx | ||
) |
Applies force at the wheel with index idx for acceleration.
Definition at line 142 of file bulletVehicle.cxx.
BulletWheel BulletVehicle::create_wheel | ( | ) |
Factory method for creating wheels for this vehicle instance.
Definition at line 174 of file bulletVehicle.cxx.
BulletRigidBodyNode * BulletVehicle::do_get_chassis | ( | ) |
Returns the chassis of this vehicle.
The chassis is a rigid body node. Assumes the lock(bullet global lock) is held by the caller
Definition at line 79 of file bulletVehicle.cxx.
void BulletVehicle::do_sync_b2p | ( | ) |
Assumes the lock(bullet global lock) is held by the caller.
Definition at line 235 of file bulletVehicle.cxx.
PN_stdfloat BulletVehicle::get_steering_value | ( | int | idx | ) | const |
Returns the steering angle of the wheel with index idx in degrees.
Definition at line 120 of file bulletVehicle.cxx.
void BulletVehicle::reset_suspension | ( | ) |
Resets the vehicle's suspension.
Definition at line 110 of file bulletVehicle.cxx.
void BulletVehicle::set_brake | ( | PN_stdfloat | brake, |
int | idx | ||
) |
Applies braking force to the wheel with index idx.
Definition at line 153 of file bulletVehicle.cxx.
void BulletVehicle::set_coordinate_system | ( | BulletUpAxis | up | ) |
Specifies which axis is "up".
Nessecary for the vehicle's suspension to work properly!
Definition at line 44 of file bulletVehicle.cxx.
Referenced by BulletVehicle().
void BulletVehicle::set_steering_value | ( | PN_stdfloat | steering, |
int | idx | ||
) |
Sets the steering value (in degrees) of the wheel with index idx.
Definition at line 131 of file bulletVehicle.cxx.
BulletRigidBodyNode * BulletVehicle::get_chassis |
Returns the chassis of this vehicle.
The chassis is a rigid body node.
Definition at line 97 of file bulletVehicle.h.
PN_stdfloat BulletVehicle::get_current_speed_km_hour |
Returns the current speed in kilometers per hour.
Convert to miles using: km/h * 0.62 = mph
Definition at line 98 of file bulletVehicle.h.
LVector3 BulletVehicle::get_forward_vector |
Returns the forward vector representing the car's actual direction of movement.
The forward vetcor is given in global coordinates.
Definition at line 99 of file bulletVehicle.h.
int BulletVehicle::get_num_wheels |
Returns the number of wheels this vehicle has.
Definition at line 92 of file bulletVehicle.h.
BulletVehicleTuning & BulletVehicle::get_tuning |
Returns a reference to the BulletVehicleTuning object of this vehicle which offers various vehicle-global tuning options.
Make sure to configure this before adding wheels!
Definition at line 101 of file bulletVehicle.h.
BulletWheel BulletVehicle::get_wheel |
Returns the BulletWheel with index idx.
Causes an AssertionError if idx is equal or larger than the number of wheels.
Definition at line 92 of file bulletVehicle.h.