Panda3D
|
00001 // Filename: physxWheelShape.h 00002 // Created by: enn0x (09Nov09) 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 #ifndef PHYSXWHEELSHAPE_H 00016 #define PHYSXWHEELSHAPE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "physxShape.h" 00021 #include "physx_includes.h" 00022 00023 class PhysxWheelShapeDesc; 00024 class PhysxSpringDesc; 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : PhysxWheelShape 00028 // Description : A special shape used for simulating a car wheel. 00029 // The -Y axis should be directed toward the ground. 00030 // 00031 // A ray is cast from the shape's origin along the -Y 00032 // axis. When the ray strikes something, and the 00033 // distance is: 00034 // 00035 // - less than wheelRadius from the shape origin: 00036 // a hard contact is created 00037 // - between wheelRadius and (suspensionTravel + 00038 // wheelRadius): a soft suspension contact is 00039 // created 00040 // - greater than (suspensionTravel + wheelRadius): 00041 // no contact is created. 00042 // 00043 // Thus at the point of greatest possible suspension 00044 // compression the wheel axle will pass through at 00045 // the shape's origin. At the point greatest 00046 // suspension extension the wheel axle will be a 00047 // distance of suspensionTravel from the shape's 00048 // origin. 00049 // 00050 // The suspension's targetValue is 0 for real cars, 00051 // which means that the suspension tries to extend 00052 // all the way. Otherwise one can specify values 00053 // [0,1] for suspensions which have a spring to 00054 // pull the wheel up when it is extended too far. 00055 // 0.5 will then fall halfway along suspensionTravel. 00056 // 00057 // The +Z axis is the 'forward' direction of travel 00058 // for the wheel. -Z is backwards. The wheel rolls 00059 // forward when rotating around the positive direction 00060 // around the X axis. 00061 // 00062 // A positive wheel steering angle corresponds to a 00063 // positive rotation around the shape's Y axis. 00064 // (Castor angles are not modeled.) 00065 // 00066 // The coordinate frame of the shape is rigidly fixed 00067 // on the car. 00068 //////////////////////////////////////////////////////////////////// 00069 class EXPCL_PANDAPHYSX PhysxWheelShape : public PhysxShape { 00070 00071 PUBLISHED: 00072 INLINE PhysxWheelShape(); 00073 INLINE ~PhysxWheelShape(); 00074 00075 void save_to_desc(PhysxWheelShapeDesc &shapeDesc) const; 00076 00077 void set_radius(float radius); 00078 void set_suspension_travel(float travel); 00079 void set_inverse_wheel_mass(float invMass); 00080 void set_motor_torque(float torque); 00081 void set_brake_torque(float torque); 00082 void set_steer_angle(float angle); 00083 void set_steer_angle_rad(float angle); 00084 void set_axle_speed(float speed); 00085 void set_wheel_flag(PhysxWheelShapeFlag flag, bool value); 00086 void set_suspension(const PhysxSpringDesc &spring); 00087 00088 float get_radius() const; 00089 float get_suspension_travel() const; 00090 float get_inverse_wheel_mass() const; 00091 float get_motor_torque() const; 00092 float get_brake_torque() const; 00093 float get_steer_angle() const; 00094 float get_steer_angle_rad() const; 00095 float get_axle_speed() const; 00096 bool get_wheel_flag(PhysxWheelShapeFlag flag) const; 00097 00098 //////////////////////////////////////////////////////////////////// 00099 public: 00100 INLINE NxShape *ptr() const { return (NxShape *)_ptr; }; 00101 00102 void link(NxShape *shapePtr); 00103 void unlink(); 00104 00105 private: 00106 NxWheelShape *_ptr; 00107 00108 //////////////////////////////////////////////////////////////////// 00109 public: 00110 static TypeHandle get_class_type() { 00111 return _type_handle; 00112 } 00113 static void init_type() { 00114 PhysxShape::init_type(); 00115 register_type(_type_handle, "PhysxWheelShape", 00116 PhysxShape::get_class_type()); 00117 } 00118 virtual TypeHandle get_type() const { 00119 return get_class_type(); 00120 } 00121 virtual TypeHandle force_init_type() { 00122 init_type(); 00123 return get_class_type(); 00124 } 00125 00126 private: 00127 static TypeHandle _type_handle; 00128 }; 00129 00130 #include "physxWheelShape.I" 00131 00132 #endif // PHYSXWHEELSHAPE_H