31 btRigidBody *body = btRigidBody::upcast(chassis->get_object());
33 _raycaster =
new btDefaultVehicleRaycaster(world->get_world());
34 _vehicle =
new btRaycastVehicle(_tuning._, body, _raycaster);
49 _vehicle->setCoordinateSystem(1, 0, 2);
52 _vehicle->setCoordinateSystem(0, 1, 2);
55 _vehicle->setCoordinateSystem(0, 2, 1);
58 bullet_cat.error() <<
"invalid up axis:" << up << std::endl;
71 return btVector3_to_LVector3(_vehicle->getForwardVector());
81 btRigidBody *bodyPtr = _vehicle->getRigidBody();
103 return (PN_stdfloat)_vehicle->getCurrentSpeedKmHour();
113 _vehicle->resetSuspension();
123 nassertr(idx < _vehicle->getNumWheels(), 0.0f);
124 return rad_2_deg(_vehicle->getSteeringValue(idx));
134 nassertv(idx < _vehicle->getNumWheels());
135 _vehicle->setSteeringValue(deg_2_rad(steering), idx);
145 nassertv(idx < _vehicle->getNumWheels());
146 _vehicle->applyEngineForce(force, idx);
156 nassertv(idx < _vehicle->getNumWheels());
157 _vehicle->setBrake(brake, idx);
164set_pitch_control(PN_stdfloat pitch) {
167 _vehicle->setPitchControl(pitch);
177 btVector3 pos(0.0, 0.0, 0.0);
178 btVector3 direction = get_axis(_vehicle->getUpAxis());
179 btVector3 axle = get_axis(_vehicle->getRightAxis());
181 btScalar suspension(0.4);
182 btScalar radius(0.3);
184 btWheelInfo &info = _vehicle->addWheel(pos, direction, axle, suspension, radius, _tuning._,
false);
186 info.m_clientInfo =
nullptr;
194btVector3 BulletVehicle::
199 return btVector3(1.0, 0.0, 0.0);
201 return btVector3(0.0, 1.0, 0.0);
203 return btVector3(0.0, 0.0, 1.0);
205 return btVector3(0.0, 0.0, 0.0);
216 return _vehicle->getNumWheels();
237 for (
int i=0; i < _vehicle->getNumWheels(); i++) {
238 btWheelInfo &info = _vehicle->getWheelInfo(i);
242 bool in_contact = info.m_raycastInfo.m_isInContact;
243 _vehicle->updateWheelTransform(i,
true);
244 info.m_raycastInfo.m_isInContact = in_contact;
249 CPT(
TransformState) ts = btTrans_to_TransformState(info.m_worldTransform);
264void BulletVehicleTuning::
265set_suspension_stiffness(PN_stdfloat value) {
268 _.m_suspensionStiffness = (btScalar)value;
274void BulletVehicleTuning::
275set_suspension_compression(PN_stdfloat value) {
278 _.m_suspensionCompression = (btScalar)value;
284void BulletVehicleTuning::
285set_suspension_damping(PN_stdfloat value) {
288 _.m_suspensionDamping = (btScalar)value;
294void BulletVehicleTuning::
295set_max_suspension_travel_cm(PN_stdfloat value) {
298 _.m_maxSuspensionTravelCm = (btScalar)value;
304void BulletVehicleTuning::
305set_friction_slip(PN_stdfloat value) {
308 _.m_frictionSlip = (btScalar)value;
314void BulletVehicleTuning::
315set_max_suspension_force(PN_stdfloat value) {
318 _.m_maxSuspensionForce = (btScalar)value;
324PN_stdfloat BulletVehicleTuning::
325get_suspension_stiffness()
const {
328 return (PN_stdfloat)_.m_suspensionStiffness;
334PN_stdfloat BulletVehicleTuning::
335get_suspension_compression()
const {
338 return (PN_stdfloat)_.m_suspensionCompression;
344PN_stdfloat BulletVehicleTuning::
345get_suspension_damping()
const {
348 return (PN_stdfloat)_.m_suspensionDamping;
354PN_stdfloat BulletVehicleTuning::
355get_max_suspension_travel_cm()
const {
358 return (PN_stdfloat)_.m_maxSuspensionTravelCm;
364PN_stdfloat BulletVehicleTuning::
365get_friction_slip()
const {
368 return (PN_stdfloat)_.m_frictionSlip;
374PN_stdfloat BulletVehicleTuning::
375get_max_suspension_force()
const {
378 return (PN_stdfloat)_.m_maxSuspensionForce;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void do_sync_b2p()
Assumes the lock(bullet global lock) is held by the caller.
void set_steering_value(PN_stdfloat steering, int idx)
Sets the steering value (in degrees) of the wheel with index idx.
get_wheel
Returns the BulletWheel with index idx.
get_forward_vector
Returns the forward vector representing the car's actual direction of movement.
PN_stdfloat get_steering_value(int idx) const
Returns the steering angle of the wheel with index idx in degrees.
BulletRigidBodyNode * do_get_chassis()
Returns the chassis of this vehicle.
get_num_wheels
Returns the number of wheels this vehicle has.
void apply_engine_force(PN_stdfloat force, int idx)
Applies force at the wheel with index idx for acceleration.
get_chassis
Returns the chassis of this vehicle.
void reset_suspension()
Resets the vehicle's suspension.
get_current_speed_km_hour
Returns the current speed in kilometers per hour.
BulletVehicle(BulletWorld *world, BulletRigidBodyNode *chassis)
Creates a new BulletVehicle instance in the given world and with a chassis node.
void set_brake(PN_stdfloat brake, int idx)
Applies braking force to the wheel with index idx.
void set_coordinate_system(BulletUpAxis up)
Specifies which axis is "up".
BulletWheel create_wheel()
Factory method for creating wheels for this vehicle instance.
One wheel of a BulletVehicle.
static BulletWheel empty()
Named constructor intended to be used for asserts with have to return a concrete value.
Similar to MutexHolder, but for a light mutex.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
static NodePath any_path(PandaNode *node, Thread *current_thread=Thread::get_current_thread())
Returns a new NodePath that represents any arbitrary path from the root to the indicated node.
NodePath get_top(Thread *current_thread=Thread::get_current_thread()) const
Returns a singleton NodePath that represents the top of the path, or empty NodePath if this path is e...
void set_transform(const TransformState *transform, Thread *current_thread=Thread::get_current_thread())
Changes the complete transform object on this node.
A basic node of the scene graph or data graph.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.