Panda3D
physxWheelShape.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file physxWheelShape.h
10  * @author enn0x
11  * @date 2009-11-09
12  */
13 
14 #ifndef PHYSXWHEELSHAPE_H
15 #define PHYSXWHEELSHAPE_H
16 
17 #include "pandabase.h"
18 
19 #include "physxShape.h"
20 #include "physx_includes.h"
21 
23 class PhysxSpringDesc;
24 
25 /**
26  * A special shape used for simulating a car wheel. The -Y axis should be
27  * directed toward the ground.
28  *
29  * A ray is cast from the shape's origin along the -Y axis. When the ray
30  * strikes something, and the distance is:
31  *
32  * - less than wheelRadius from the shape origin: a hard contact is created -
33  * between wheelRadius and (suspensionTravel + wheelRadius): a soft suspension
34  * contact is created - greater than (suspensionTravel + wheelRadius): no
35  * contact is created.
36  *
37  * Thus at the point of greatest possible suspension compression the wheel
38  * axle will pass through at the shape's origin. At the point greatest
39  * suspension extension the wheel axle will be a distance of suspensionTravel
40  * from the shape's origin.
41  *
42  * The suspension's targetValue is 0 for real cars, which means that the
43  * suspension tries to extend all the way. Otherwise one can specify values
44  * [0,1] for suspensions which have a spring to pull the wheel up when it is
45  * extended too far. 0.5 will then fall halfway along suspensionTravel.
46  *
47  * The +Z axis is the 'forward' direction of travel for the wheel. -Z is
48  * backwards. The wheel rolls forward when rotating around the positive
49  * direction around the X axis.
50  *
51  * A positive wheel steering angle corresponds to a positive rotation around
52  * the shape's Y axis. (Castor angles are not modeled.)
53  *
54  * The coordinate frame of the shape is rigidly fixed on the car.
55  */
56 class EXPCL_PANDAPHYSX PhysxWheelShape : public PhysxShape {
57 PUBLISHED:
58  INLINE PhysxWheelShape();
59  INLINE ~PhysxWheelShape();
60 
61  void save_to_desc(PhysxWheelShapeDesc &shapeDesc) const;
62 
63  void set_radius(float radius);
64  void set_suspension_travel(float travel);
65  void set_inverse_wheel_mass(float invMass);
66  void set_motor_torque(float torque);
67  void set_brake_torque(float torque);
68  void set_steer_angle(float angle);
69  void set_steer_angle_rad(float angle);
70  void set_axle_speed(float speed);
71  void set_wheel_flag(PhysxWheelShapeFlag flag, bool value);
72  void set_suspension(const PhysxSpringDesc &spring);
73 
74  float get_radius() const;
75  float get_suspension_travel() const;
76  float get_inverse_wheel_mass() const;
77  float get_motor_torque() const;
78  float get_brake_torque() const;
79  float get_steer_angle() const;
80  float get_steer_angle_rad() const;
81  float get_axle_speed() const;
82  bool get_wheel_flag(PhysxWheelShapeFlag flag) const;
83 
84 public:
85  INLINE NxShape *ptr() const { return (NxShape *)_ptr; };
86 
87  void link(NxShape *shapePtr);
88  void unlink();
89 
90 private:
91  NxWheelShape *_ptr;
92 
93 public:
94  static TypeHandle get_class_type() {
95  return _type_handle;
96  }
97  static void init_type() {
98  PhysxShape::init_type();
99  register_type(_type_handle, "PhysxWheelShape",
100  PhysxShape::get_class_type());
101  }
102  virtual TypeHandle get_type() const {
103  return get_class_type();
104  }
105  virtual TypeHandle force_init_type() {
106  init_type();
107  return get_class_type();
108  }
109 
110 private:
111  static TypeHandle _type_handle;
112 };
113 
114 #include "physxWheelShape.I"
115 
116 #endif // PHYSXWHEELSHAPE_H
Abstract base class for shapes.
Definition: physxShape.h:39
Describes a joint spring.
Descriptor class for PhysxWheelShape.
A special shape used for simulating a car wheel.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
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 register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22