Panda3D
bulletHingeConstraint.h
1 // Filename: bulletHingeConstraint.h
2 // Created by: enn0x (01Mar10)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef __BULLET_HINGE_CONSTRAINT_H__
16 #define __BULLET_HINGE_CONSTRAINT_H__
17 
18 #include "pandabase.h"
19 
20 #include "bullet_includes.h"
21 #include "bullet_utils.h"
22 #include "bulletConstraint.h"
23 
24 #include "luse.h"
25 
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : BulletHingeConstraint
30 // Description : The hinge constraint lets two bodies rotate around
31 // a given axis while adhering to specified limits.
32 // It's motor can apply angular force to them.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDABULLET BulletHingeConstraint : public BulletConstraint {
35 
36 PUBLISHED:
38  const LPoint3 &pivot_a,
39  const LVector3 &axis_a,
40  bool use_frame_a=false);
42  const BulletRigidBodyNode *node_b,
43  const LPoint3 &pivot_a,
44  const LPoint3 &pivot_b,
45  const LVector3 &axis_a,
46  const LVector3 &axis_b,
47  bool use_frame_a=false);
48 
50  const TransformState *ts_a,
51  bool use_frame_a=false);
53  const BulletRigidBodyNode *node_b,
54  const TransformState *ts_a,
55  const TransformState *ts_b,
56  bool use_frame_a=false);
57 
58  INLINE ~BulletHingeConstraint();
59 
60  PN_stdfloat get_hinge_angle();
61  PN_stdfloat get_lower_limit() const;
62  PN_stdfloat get_upper_limit() const;
63  bool get_angular_only() const;
64 
65  void set_angular_only(bool value);
66  void set_limit(PN_stdfloat low, PN_stdfloat high, PN_stdfloat softness=0.9f, PN_stdfloat bias=0.3f, PN_stdfloat relaxation=1.0f);
67  void set_axis(const LVector3 &axis);
68 
69  void enable_angular_motor(bool enable, PN_stdfloat target_velocity, PN_stdfloat max_impulse);
70  void enable_motor(bool enable);
71  void set_max_motor_impulse(PN_stdfloat max_impulse);
72  void set_motor_target(const LQuaternion &quat, PN_stdfloat dt);
73  void set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt);
74 
75  void set_frames(const TransformState *ts_a, const TransformState *ts_b);
76  INLINE CPT(TransformState) get_frame_a() const;
77  INLINE CPT(TransformState) get_frame_b() const;
78 
79 public:
80  virtual btTypedConstraint *ptr() const;
81 
82 private:
83  btHingeConstraint *_constraint;
84 
85 ////////////////////////////////////////////////////////////////////
86 public:
87  static TypeHandle get_class_type() {
88  return _type_handle;
89  }
90  static void init_type() {
91  BulletConstraint::init_type();
92  register_type(_type_handle, "BulletHingeConstraint",
93  BulletConstraint::get_class_type());
94  }
95  virtual TypeHandle get_type() const {
96  return get_class_type();
97  }
98  virtual TypeHandle force_init_type() {
99  init_type();
100  return get_class_type();
101  }
102 
103 private:
104  static TypeHandle _type_handle;
105 };
106 
107 #include "bulletHingeConstraint.I"
108 
109 #endif // __BULLET_HINGE_CONSTRAINT_H__
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
The hinge constraint lets two bodies rotate around a given axis while adhering to specified limits...
This is the base quaternion class.
Definition: lquaternion.h:96
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85