Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
BulletVehicle Class Reference

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"

Inheritance diagram for BulletVehicle:
TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase

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...
 
BulletRigidBodyNodedo_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 ()
 
BulletRigidBodyNodeget_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...
 
BulletVehicleTuningget_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...
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_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...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_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...
 
WeakReferenceListweak_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 Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
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 Public Member Functions inherited from ReferenceCount
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...
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BulletVehicle()

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().

Member Function Documentation

◆ apply_engine_force()

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.

◆ create_wheel()

BulletWheel BulletVehicle::create_wheel ( )

Factory method for creating wheels for this vehicle instance.

Definition at line 174 of file bulletVehicle.cxx.

◆ do_get_chassis()

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.

◆ do_sync_b2p()

void BulletVehicle::do_sync_b2p ( )

Assumes the lock(bullet global lock) is held by the caller.

Definition at line 235 of file bulletVehicle.cxx.

◆ get_steering_value()

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.

◆ reset_suspension()

void BulletVehicle::reset_suspension ( )

Resets the vehicle's suspension.

Definition at line 110 of file bulletVehicle.cxx.

◆ set_brake()

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.

◆ set_coordinate_system()

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().

◆ set_steering_value()

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.

Member Data Documentation

◆ get_chassis

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.

◆ get_current_speed_km_hour

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.

◆ get_forward_vector

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.

◆ get_num_wheels

int BulletVehicle::get_num_wheels

Returns the number of wheels this vehicle has.

Definition at line 92 of file bulletVehicle.h.

◆ get_tuning

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.

◆ get_wheel

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.


The documentation for this class was generated from the following files: