Panda3D
 All Classes Functions Variables Enumerations
bulletWheel.cxx
00001 // Filename: bulletWheel.cxx
00002 // Created by:  enn0x (17Feb10)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "bulletWheel.h"
00016 
00017 ////////////////////////////////////////////////////////////////////
00018 //     Function: BulletWheel::Constructor
00019 //       Access: Public
00020 //  Description:
00021 ////////////////////////////////////////////////////////////////////
00022 BulletWheel::
00023 BulletWheel(btWheelInfo &info) : _info(info) {
00024 
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: BulletWheel::get_suspension_rest_length
00029 //       Access: Published
00030 //  Description: Returns the length of the suspension when the
00031 //               vehicle is standing still.
00032 ////////////////////////////////////////////////////////////////////
00033 PN_stdfloat BulletWheel::
00034 get_suspension_rest_length() const {
00035 
00036   return (PN_stdfloat)_info.getSuspensionRestLength();
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: BulletWheel::set_suspension_stiffness
00041 //       Access: Published
00042 //  Description: Sets how stiff the suspension shall be.
00043 ////////////////////////////////////////////////////////////////////
00044 void BulletWheel::
00045 set_suspension_stiffness(PN_stdfloat value) {
00046 
00047   _info.m_suspensionStiffness = (btScalar)value;
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: BulletWheel::get_suspension_stiffness
00052 //       Access: Published
00053 //  Description: Returns the stiffness of the suspension.
00054 ////////////////////////////////////////////////////////////////////
00055 PN_stdfloat BulletWheel::
00056 get_suspension_stiffness() const {
00057 
00058   return (PN_stdfloat)_info.m_suspensionStiffness;
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: BulletWheel::set_max_suspension_travel_cm
00063 //       Access: Published
00064 //  Description: Sets the maximum distance the suspension can travel
00065 //               out of the resting position in centimeters.
00066 ////////////////////////////////////////////////////////////////////
00067 void BulletWheel::
00068 set_max_suspension_travel_cm(PN_stdfloat value) {
00069 
00070   _info.m_maxSuspensionTravelCm = (btScalar)value;
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: BulletWheel::get_max_suspension_travel_cm
00075 //       Access: Published
00076 //  Description:
00077 ////////////////////////////////////////////////////////////////////
00078 PN_stdfloat BulletWheel::
00079 get_max_suspension_travel_cm() const {
00080 
00081   return (PN_stdfloat)_info.m_maxSuspensionTravelCm;
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: BulletWheel::set_friction_slip
00086 //       Access: Published
00087 //  Description: Sets the slipperyness of the tyre.
00088 ////////////////////////////////////////////////////////////////////
00089 void BulletWheel::
00090 set_friction_slip(PN_stdfloat value) {
00091 
00092   _info.m_frictionSlip = (btScalar)value;
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: BulletWheel::get_friction_slip
00097 //       Access: Published
00098 //  Description: Returns how slippery the tyres are.
00099 ////////////////////////////////////////////////////////////////////
00100 PN_stdfloat BulletWheel::
00101 get_friction_slip() const {
00102 
00103   return (PN_stdfloat)_info.m_frictionSlip;
00104 }
00105 
00106 ////////////////////////////////////////////////////////////////////
00107 //     Function: BulletWheel::set_max_suspension_force
00108 //       Access: Published
00109 //  Description: Sets the maximum suspension force the wheel can
00110 //               handle.
00111 ////////////////////////////////////////////////////////////////////
00112 void BulletWheel::
00113 set_max_suspension_force(PN_stdfloat value) {
00114 
00115   _info.m_maxSuspensionForce = (btScalar)value;
00116 }
00117 
00118 ////////////////////////////////////////////////////////////////////
00119 //     Function: BulletWheel::get_max_suspension_force
00120 //       Access: Published
00121 //  Description: Returns the maximum force (weight) the suspension
00122 //               can handle.
00123 ////////////////////////////////////////////////////////////////////
00124 PN_stdfloat BulletWheel::
00125 get_max_suspension_force() const {
00126 
00127   return (PN_stdfloat)_info.m_maxSuspensionForce;
00128 }
00129 
00130 ////////////////////////////////////////////////////////////////////
00131 //     Function: BulletWheel::set_wheels_damping_compression
00132 //       Access: Published
00133 //  Description: Sets the damping forces applied when the suspension
00134 //               gets compressed.
00135 ////////////////////////////////////////////////////////////////////
00136 void BulletWheel::
00137 set_wheels_damping_compression(PN_stdfloat value) {
00138 
00139   _info.m_wheelsDampingCompression = (btScalar)value;
00140 }
00141 
00142 ////////////////////////////////////////////////////////////////////
00143 //     Function: BulletWheel::get_wheels_damping_compression
00144 //       Access: Published
00145 //  Description: Returns the  damping applied to the compressing
00146 //               suspension.
00147 ////////////////////////////////////////////////////////////////////
00148 PN_stdfloat BulletWheel::
00149 get_wheels_damping_compression() const {
00150 
00151   return (PN_stdfloat)_info.m_wheelsDampingCompression;
00152 }
00153 
00154 ////////////////////////////////////////////////////////////////////
00155 //     Function: BulletWheel::set_wheels_damping_relaxation
00156 //       Access: Published
00157 //  Description: Sets the damping forces applied when the suspension
00158 //               relaxes.
00159 ////////////////////////////////////////////////////////////////////
00160 void BulletWheel::
00161 set_wheels_damping_relaxation(PN_stdfloat value) {
00162 
00163   _info.m_wheelsDampingRelaxation = (btScalar)value;
00164 }
00165 
00166 ////////////////////////////////////////////////////////////////////
00167 //     Function: BulletWheel::get_wheels_damping_relaxation
00168 //       Access: Published
00169 //  Description: Returns the damping applied to the relaxing
00170 //               suspension.
00171 ////////////////////////////////////////////////////////////////////
00172 PN_stdfloat BulletWheel::
00173 get_wheels_damping_relaxation() const {
00174 
00175   return (PN_stdfloat)_info.m_wheelsDampingRelaxation;
00176 }
00177 
00178 ////////////////////////////////////////////////////////////////////
00179 //     Function: BulletWheel::set_roll_influence
00180 //       Access: Published
00181 //  Description: Defines a scaling factor for roll forces that affect
00182 //               the chassis. 0.0 means no roll - the chassis won't
00183 //               ever flip over - while 1.0 means original physical
00184 //               behaviour. Basically, this allows moving the center
00185 //               of mass up and down.
00186 ////////////////////////////////////////////////////////////////////
00187 void BulletWheel::
00188 set_roll_influence(PN_stdfloat value) {
00189 
00190   _info.m_rollInfluence = (btScalar)value;
00191 }
00192 
00193 ////////////////////////////////////////////////////////////////////
00194 //     Function: BulletWheel::get_roll_influence
00195 //       Access: Published
00196 //  Description: Returns the factor by which roll forces are scaled.
00197 //               See set_roll_influence.
00198 ////////////////////////////////////////////////////////////////////
00199 PN_stdfloat BulletWheel::
00200 get_roll_influence() const {
00201 
00202   return (PN_stdfloat)_info.m_rollInfluence;
00203 }
00204 
00205 ////////////////////////////////////////////////////////////////////
00206 //     Function: BulletWheel::set_wheel_radius
00207 //       Access: Published
00208 //  Description: Sets the wheel radius.
00209 ////////////////////////////////////////////////////////////////////
00210 void BulletWheel::
00211 set_wheel_radius(PN_stdfloat value) {
00212 
00213   _info.m_wheelsRadius = (btScalar)value;
00214 }
00215 
00216 ////////////////////////////////////////////////////////////////////
00217 //     Function: BulletWheel::get_wheel_radius
00218 //       Access: Published
00219 //  Description: Returns the wheel radius.
00220 ////////////////////////////////////////////////////////////////////
00221 PN_stdfloat BulletWheel::
00222 get_wheel_radius() const {
00223 
00224   return (PN_stdfloat)_info.m_wheelsRadius;
00225 }
00226 
00227 ////////////////////////////////////////////////////////////////////
00228 //     Function: BulletWheel::set_steering
00229 //       Access: Published
00230 //  Description: Sets the steering angle.
00231 ////////////////////////////////////////////////////////////////////
00232 void BulletWheel::
00233 set_steering(PN_stdfloat value) {
00234 
00235   _info.m_steering = (btScalar)value;
00236 }
00237 
00238 ////////////////////////////////////////////////////////////////////
00239 //     Function: BulletWheel::get_steering
00240 //       Access: Published
00241 //  Description: Returns the steering angle in degrees.
00242 ////////////////////////////////////////////////////////////////////
00243 PN_stdfloat BulletWheel::
00244 get_steering() const {
00245 
00246   return (PN_stdfloat)_info.m_steering;
00247 }
00248 
00249 ////////////////////////////////////////////////////////////////////
00250 //     Function: BulletWheel::set_rotation
00251 //       Access: Published
00252 //  Description:
00253 ////////////////////////////////////////////////////////////////////
00254 void BulletWheel::
00255 set_rotation(PN_stdfloat value) {
00256 
00257   _info.m_rotation = (btScalar)value;
00258 }
00259 
00260 ////////////////////////////////////////////////////////////////////
00261 //     Function: BulletWheel::get_rotation
00262 //       Access: Published
00263 //  Description:
00264 ////////////////////////////////////////////////////////////////////
00265 PN_stdfloat BulletWheel::
00266 get_rotation() const {
00267 
00268   return (PN_stdfloat)_info.m_rotation;
00269 }
00270 
00271 ////////////////////////////////////////////////////////////////////
00272 //     Function: BulletWheel::set_delta_rotation
00273 //       Access: Published
00274 //  Description:
00275 ////////////////////////////////////////////////////////////////////
00276 void BulletWheel::
00277 set_delta_rotation(PN_stdfloat value) {
00278 
00279   _info.m_deltaRotation = (btScalar)value;
00280 }
00281 
00282 ////////////////////////////////////////////////////////////////////
00283 //     Function: BulletWheel::get_delta_rotation
00284 //       Access: Published
00285 //  Description:
00286 ////////////////////////////////////////////////////////////////////
00287 PN_stdfloat BulletWheel::
00288 get_delta_rotation() const {
00289 
00290   return (PN_stdfloat)_info.m_deltaRotation;
00291 }
00292 
00293 ////////////////////////////////////////////////////////////////////
00294 //     Function: BulletWheel::set_engine_force
00295 //       Access: Published
00296 //  Description: Defines how much force should be used to rotate the
00297 //               wheel.
00298 ////////////////////////////////////////////////////////////////////
00299 void BulletWheel::
00300 set_engine_force(PN_stdfloat value) {
00301 
00302   _info.m_engineForce = (btScalar)value;
00303 }
00304 
00305 ////////////////////////////////////////////////////////////////////
00306 //     Function: BulletWheel::get_engine_force
00307 //       Access: Published
00308 //  Description: Returns the amount of accelleration force currently
00309 //               applied.
00310 ////////////////////////////////////////////////////////////////////
00311 PN_stdfloat BulletWheel::
00312 get_engine_force() const {
00313 
00314   return (PN_stdfloat)_info.m_engineForce;
00315 }
00316 
00317 ////////////////////////////////////////////////////////////////////
00318 //     Function: BulletWheel::set_brake
00319 //       Access: Published
00320 //  Description:
00321 ////////////////////////////////////////////////////////////////////
00322 void BulletWheel::
00323 set_brake(PN_stdfloat value) {
00324 
00325   _info.m_brake = (btScalar)value;
00326 }
00327 
00328 ////////////////////////////////////////////////////////////////////
00329 //     Function: BulletWheel::get_brake
00330 //       Access: Published
00331 //  Description: Returns the amount of braking force currently
00332 //               applied.
00333 ////////////////////////////////////////////////////////////////////
00334 PN_stdfloat BulletWheel::
00335 get_brake() const {
00336 
00337   return (PN_stdfloat)_info.m_brake;
00338 }
00339 
00340 ////////////////////////////////////////////////////////////////////
00341 //     Function: BulletWheel::set_skid_info
00342 //       Access: Published
00343 //  Description:
00344 ////////////////////////////////////////////////////////////////////
00345 void BulletWheel::
00346 set_skid_info(PN_stdfloat value) {
00347 
00348   _info.m_skidInfo = (btScalar)value;
00349 }
00350 
00351 ////////////////////////////////////////////////////////////////////
00352 //     Function: BulletWheel::get_skid_info
00353 //       Access: Published
00354 //  Description:
00355 ////////////////////////////////////////////////////////////////////
00356 PN_stdfloat BulletWheel::
00357 get_skid_info() const {
00358 
00359   return (PN_stdfloat)_info.m_skidInfo;
00360 }
00361 
00362 ////////////////////////////////////////////////////////////////////
00363 //     Function: BulletWheel::set_wheels_suspension_force
00364 //       Access: Published
00365 //  Description:
00366 ////////////////////////////////////////////////////////////////////
00367 void BulletWheel::
00368 set_wheels_suspension_force(PN_stdfloat value) {
00369 
00370   _info.m_wheelsSuspensionForce = (btScalar)value;
00371 }
00372 
00373 ////////////////////////////////////////////////////////////////////
00374 //     Function: BulletWheel::get_wheels_suspension_force
00375 //       Access: Published
00376 //  Description:
00377 ////////////////////////////////////////////////////////////////////
00378 PN_stdfloat BulletWheel::
00379 get_wheels_suspension_force() const {
00380 
00381   return (PN_stdfloat)_info.m_wheelsSuspensionForce;
00382 }
00383 
00384 ////////////////////////////////////////////////////////////////////
00385 //     Function: BulletWheel::set_suspension_relative_velocity
00386 //       Access: Published
00387 //  Description:
00388 ////////////////////////////////////////////////////////////////////
00389 void BulletWheel::
00390 set_suspension_relative_velocity(PN_stdfloat value) {
00391 
00392   _info.m_suspensionRelativeVelocity = (btScalar)value;
00393 }
00394 
00395 ////////////////////////////////////////////////////////////////////
00396 //     Function: BulletWheel::get_suspension_relative_velocity
00397 //       Access: Published
00398 //  Description:
00399 ////////////////////////////////////////////////////////////////////
00400 PN_stdfloat BulletWheel::
00401 get_suspension_relative_velocity() const {
00402 
00403   return (PN_stdfloat)_info.m_suspensionRelativeVelocity;
00404 }
00405 
00406 ////////////////////////////////////////////////////////////////////
00407 //     Function: BulletWheel::set_clipped_inv_connection_point_cs
00408 //       Access: Published
00409 //  Description: 
00410 ////////////////////////////////////////////////////////////////////
00411 void BulletWheel::
00412 set_clipped_inv_connection_point_cs(PN_stdfloat value) {
00413 
00414   _info.m_clippedInvContactDotSuspension = (btScalar)value;
00415 }
00416 
00417 ////////////////////////////////////////////////////////////////////
00418 //     Function: BulletWheel::get_clipped_inv_connection_point_cs
00419 //       Access: Published
00420 //  Description:
00421 ////////////////////////////////////////////////////////////////////
00422 PN_stdfloat BulletWheel::
00423 get_clipped_inv_connection_point_cs() const {
00424 
00425   return (PN_stdfloat)_info.m_clippedInvContactDotSuspension;
00426 }
00427 
00428 ////////////////////////////////////////////////////////////////////
00429 //     Function: BulletWheel::set_chassis_connection_point_cs
00430 //       Access: Published
00431 //  Description: Sets the point where the wheel is connected to the
00432 //               chassis.
00433 ////////////////////////////////////////////////////////////////////
00434 void BulletWheel::
00435 set_chassis_connection_point_cs(const LPoint3 &pos) {
00436 
00437   nassertv(!pos.is_nan());
00438   _info.m_chassisConnectionPointCS = LVecBase3_to_btVector3(pos);
00439 }
00440 
00441 ////////////////////////////////////////////////////////////////////
00442 //     Function: BulletWheel::get_chassis_connection_point_cs
00443 //       Access: Published
00444 //  Description: Returns the point where the wheel is connected to
00445 //               the chassis.
00446 ////////////////////////////////////////////////////////////////////
00447 LPoint3 BulletWheel::
00448 get_chassis_connection_point_cs() const {
00449 
00450   return btVector3_to_LPoint3(_info.m_chassisConnectionPointCS);
00451 }
00452 
00453 ////////////////////////////////////////////////////////////////////
00454 //     Function: BulletWheel::set_wheel_direction_cs
00455 //       Access: Published
00456 //  Description: Sets the wheel's forward vector. (Most likely
00457 //               orthogonal to the axle vector.)
00458 ////////////////////////////////////////////////////////////////////
00459 void BulletWheel::
00460 set_wheel_direction_cs(const LVector3 &dir) {
00461 
00462   nassertv(!dir.is_nan());
00463   _info.m_wheelDirectionCS = LVecBase3_to_btVector3(dir);
00464 }
00465 
00466 ////////////////////////////////////////////////////////////////////
00467 //     Function: BulletWheel::get_wheel_direction_cs
00468 //       Access: Published
00469 //  Description: Returns the wheel's forward vector relative to the
00470 //               chassis.
00471 ////////////////////////////////////////////////////////////////////
00472 LVector3 BulletWheel::
00473 get_wheel_direction_cs() const {
00474 
00475   return btVector3_to_LVector3(_info.m_wheelDirectionCS);
00476 }
00477 
00478 ////////////////////////////////////////////////////////////////////
00479 //     Function: BulletWheel::set_wheel_axle_cs
00480 //       Access: Published
00481 //  Description: Determines the wheel axle normal vector.
00482 ////////////////////////////////////////////////////////////////////
00483 void BulletWheel::
00484 set_wheel_axle_cs(const LVector3 &axle) {
00485 
00486   nassertv(!axle.is_nan());
00487   _info.m_wheelAxleCS = LVecBase3_to_btVector3(axle);
00488 }
00489 
00490 ////////////////////////////////////////////////////////////////////
00491 //     Function: BulletWheel::get_wheel_axle_cs
00492 //       Access: Published
00493 //  Description: Returns the normal vector of the wheel axle.
00494 ////////////////////////////////////////////////////////////////////
00495 LVector3 BulletWheel::
00496 get_wheel_axle_cs() const {
00497 
00498   return btVector3_to_LVector3(_info.m_wheelAxleCS);
00499 }
00500 
00501 ////////////////////////////////////////////////////////////////////
00502 //     Function: BulletWheel::set_world_transform
00503 //       Access: Published
00504 //  Description:
00505 ////////////////////////////////////////////////////////////////////
00506 void BulletWheel::
00507 set_world_transform(const LMatrix4 &mat) {
00508 
00509   nassertv(!mat.is_nan());
00510   _info.m_worldTransform = LMatrix4_to_btTrans(mat);
00511 }
00512 
00513 ////////////////////////////////////////////////////////////////////
00514 //     Function: BulletWheel::get_world_transform
00515 //       Access: Published
00516 //  Description:
00517 ////////////////////////////////////////////////////////////////////
00518 LMatrix4 BulletWheel::
00519 get_world_transform() const {
00520 
00521   return btTrans_to_LMatrix4(_info.m_worldTransform);
00522 }
00523 
00524 ////////////////////////////////////////////////////////////////////
00525 //     Function: BulletWheel::set_front_wheel
00526 //       Access: Published
00527 //  Description: Sets if the wheel is steerable.
00528 ////////////////////////////////////////////////////////////////////
00529 void BulletWheel::
00530 set_front_wheel(bool value) {
00531 
00532   _info.m_bIsFrontWheel = value;
00533 }
00534 
00535 ////////////////////////////////////////////////////////////////////
00536 //     Function: BulletWheel::is_front_wheel
00537 //       Access: Published
00538 //  Description: Determines if a wheel is steerable.
00539 ////////////////////////////////////////////////////////////////////
00540 bool BulletWheel::
00541 is_front_wheel() const {
00542 
00543   return _info.m_bIsFrontWheel;
00544 }
00545 
00546 ////////////////////////////////////////////////////////////////////
00547 //     Function: BulletWheel::set_node
00548 //       Access: Published
00549 //  Description: Sets the PandaNode which representates the visual
00550 //               appearance of this wheel.
00551 ////////////////////////////////////////////////////////////////////
00552 void BulletWheel::
00553 set_node(PandaNode *node) {
00554 
00555   _info.m_clientInfo = (void *)node;
00556 }
00557 
00558 ////////////////////////////////////////////////////////////////////
00559 //     Function: BulletWheel::get_node
00560 //       Access: Published
00561 //  Description: Returns the PandaNode which representates the
00562 //               visual appearance of this wheel, if such a
00563 //               representation has been set previously.
00564 ////////////////////////////////////////////////////////////////////
00565 PandaNode *BulletWheel::
00566 get_node() const {
00567 
00568   return (_info.m_clientInfo == NULL) ? NULL : (PandaNode *)_info.m_clientInfo;
00569 }
00570 
 All Classes Functions Variables Enumerations