Panda3D
bulletHingeConstraint.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 bulletHingeConstraint.h
10  * @author enn0x
11  * @date 2010-03-01
12  */
13 
14 #ifndef __BULLET_HINGE_CONSTRAINT_H__
15 #define __BULLET_HINGE_CONSTRAINT_H__
16 
17 #include "pandabase.h"
18 
19 #include "bullet_includes.h"
20 #include "bullet_utils.h"
21 #include "bulletConstraint.h"
22 
23 #include "luse.h"
24 
26 
27 /**
28  * The hinge constraint lets two bodies rotate around a given axis while
29  * adhering to specified limits. It's motor can apply angular force to them.
30  */
31 class EXPCL_PANDABULLET BulletHingeConstraint : public BulletConstraint {
32 PUBLISHED:
33  explicit BulletHingeConstraint(const BulletRigidBodyNode *node_a,
34  const LPoint3 &pivot_a,
35  const LVector3 &axis_a,
36  bool use_frame_a=false);
37  explicit BulletHingeConstraint(const BulletRigidBodyNode *node_a,
38  const BulletRigidBodyNode *node_b,
39  const LPoint3 &pivot_a,
40  const LPoint3 &pivot_b,
41  const LVector3 &axis_a,
42  const LVector3 &axis_b,
43  bool use_frame_a=false);
44 
45  explicit BulletHingeConstraint(const BulletRigidBodyNode *node_a,
46  const TransformState *ts_a,
47  bool use_frame_a=false);
48  explicit BulletHingeConstraint(const BulletRigidBodyNode *node_a,
49  const BulletRigidBodyNode *node_b,
50  const TransformState *ts_a,
51  const TransformState *ts_b,
52  bool use_frame_a=false);
53 
54  INLINE ~BulletHingeConstraint();
55 
56  PN_stdfloat get_hinge_angle();
57  PN_stdfloat get_lower_limit() const;
58  PN_stdfloat get_upper_limit() const;
59  bool get_angular_only() const;
60 
61  void set_angular_only(bool value);
62  void set_limit(PN_stdfloat low, PN_stdfloat high, PN_stdfloat softness=0.9f, PN_stdfloat bias=0.3f, PN_stdfloat relaxation=1.0f);
63  void set_axis(const LVector3 &axis);
64 
65  void enable_angular_motor(bool enable, PN_stdfloat target_velocity, PN_stdfloat max_impulse);
66  void enable_motor(bool enable);
67  void set_max_motor_impulse(PN_stdfloat max_impulse);
68  void set_motor_target(const LQuaternion &quat, PN_stdfloat dt);
69  void set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt);
70 
71  void set_frames(const TransformState *ts_a, const TransformState *ts_b);
72  CPT(TransformState) get_frame_a() const;
73  CPT(TransformState) get_frame_b() const;
74 
75  MAKE_PROPERTY(hinge_angle, get_hinge_angle);
76  MAKE_PROPERTY(lower_limit, get_lower_limit);
77  MAKE_PROPERTY(upper_limit, get_upper_limit);
78  MAKE_PROPERTY(angular_only, get_angular_only, set_angular_only);
79  MAKE_PROPERTY(frame_a, get_frame_a);
80  MAKE_PROPERTY(frame_b, get_frame_b);
81 
82 public:
83  virtual btTypedConstraint *ptr() const;
84 
85 private:
86  btHingeConstraint *_constraint;
87 
88 public:
89  static TypeHandle get_class_type() {
90  return _type_handle;
91  }
92  static void init_type() {
93  BulletConstraint::init_type();
94  register_type(_type_handle, "BulletHingeConstraint",
95  BulletConstraint::get_class_type());
96  }
97  virtual TypeHandle get_type() const {
98  return get_class_type();
99  }
100  virtual TypeHandle force_init_type() {
101  init_type();
102  return get_class_type();
103  }
104 
105 private:
106  static TypeHandle _type_handle;
107 };
108 
109 #include "bulletHingeConstraint.I"
110 
111 #endif // __BULLET_HINGE_CONSTRAINT_H__
Indicates a coordinate-system transform on vertices.
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
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.
The hinge constraint lets two bodies rotate around a given axis while adhering to specified limits.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81