15 #include "bulletVehicle.h"
16 #include "bulletWorld.h"
17 #include "bulletRigidBodyNode.h"
18 #include "bulletWheel.h"
31 btRigidBody *body = btRigidBody::upcast(chassis->get_object());
33 _raycaster =
new btDefaultVehicleRaycaster(world->get_world());
34 _vehicle =
new btRaycastVehicle(_tuning._, body, _raycaster);
50 _vehicle->setCoordinateSystem(1, 0, 2);
53 _vehicle->setCoordinateSystem(0, 1, 2);
56 _vehicle->setCoordinateSystem(0, 2, 1);
59 bullet_cat.error() <<
"invalid up axis:" << up << endl;
74 return btVector3_to_LVector3(_vehicle->getForwardVector());
86 btRigidBody *bodyPtr = _vehicle->getRigidBody();
99 return (PN_stdfloat)_vehicle->getCurrentSpeedKmHour();
110 _vehicle->resetSuspension();
123 return rad_2_deg(_vehicle->getSteeringValue(idx));
136 _vehicle->setSteeringValue(deg_2_rad(steering), idx);
149 _vehicle->applyEngineForce(force, idx);
161 _vehicle->setBrake(brake, idx);
170 set_pitch_control(PN_stdfloat pitch) {
172 _vehicle->setPitchControl(pitch);
184 btVector3 pos(0.0, 0.0, 0.0);
185 btVector3 direction = get_axis(_vehicle->getUpAxis());
186 btVector3 axle = get_axis(_vehicle->getRightAxis());
188 btScalar suspension(0.4);
189 btScalar radius(0.3);
191 btWheelInfo &info = _vehicle->addWheel(pos, direction, axle, suspension, radius, _tuning._,
false);
193 info.m_clientInfo = NULL;
203 btVector3 BulletVehicle::
208 return btVector3(1.0, 0.0, 0.0);
210 return btVector3(0.0, 1.0, 0.0);
212 return btVector3(0.0, 0.0, 1.0);
214 return btVector3(0.0, 0.0, 0.0);
241 btWheelInfo info = _vehicle->getWheelInfo(i);
246 CPT(TransformState) ts = btTrans_to_TransformState(info.m_worldTransform);
253 np.set_transform(np.get_top(), ts);
void reset_suspension()
Resets the vehicle's suspension.
A basic node of the scene graph or data graph.
void set_coordinate_system(BulletUpAxis up)
Specifies which axis is "up".
BulletWheel create_wheel()
Factory method for creating wheels for this vehicle instance.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
BulletVehicle(BulletWorld *world, BulletRigidBodyNode *chassis)
Creates a new BulletVehicle instance in the given world and with a chassis node.
static BulletWheel empty()
Named constructor intended to be used for asserts with have to return a concrete value.
PN_stdfloat get_steering_value(int idx) const
Returns the steering angle of the wheel with index idx in degrees.
PN_stdfloat get_current_speed_km_hour() const
Returns the current speed in kilometers per hour.
void set_brake(PN_stdfloat brake, int idx)
Applies braking force to the wheel with index idx.
LVector3 get_forward_vector() const
Returns the forward vector representing the car's actual direction of movement.
int get_num_wheels() const
Returns the number of wheels this vehicle has.
void set_steering_value(PN_stdfloat steering, int idx)
Sets the steering value (in degrees) of the wheel with index idx.
BulletRigidBodyNode * get_chassis()
Returns the chassis of this vehicle.
BulletWheel get_wheel(int idx) const
Returns the BulletWheel with index idx.
void apply_engine_force(PN_stdfloat force, int idx)
Applies force at the wheel with index idx for acceleration.
TypeHandle is the identifier used to differentiate C++ class types.
One wheel of a BulletVehicle.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...