Panda3D
 All Classes Functions Variables Enumerations
odeJoint.h
1 // Filename: odeJoint.h
2 // Created by: joswilso (27Dec06)
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 ODEJOINT_H
16 #define ODEJOINT_H
17 
18 #include "pandabase.h"
19 #include "typedObject.h"
20 #include "luse.h"
21 
22 #include "ode_includes.h"
23 #include "odeWorld.h" // Needed for derived classes
24 #include "odeJointGroup.h"
25 
26 class EXPCL_PANDAODE OdeJointFeedback : public dJointFeedback {
27 PUBLISHED:
28  INLINE const LVector3f get_force1() const { return LVector3f(f1[0], f1[1], f1[2]); };
29  INLINE const LVector3f get_force2() const { return LVector3f(f2[0], f2[1], f2[2]); };
30  INLINE const LVector3f get_torque1() const { return LVector3f(t1[0], t1[1], t1[2]); };
31  INLINE const LVector3f get_torque2() const { return LVector3f(t2[0], t2[1], t2[2]); };
32 };
33 
34 // Strange, we should be forced to include this by get_body()
35 class OdeBody;
36 
37 class OdeBallJoint;
38 class OdeHingeJoint;
39 class OdeSliderJoint;
40 class OdeContactJoint;
41 class OdeUniversalJoint;
42 class OdeHinge2Joint;
43 class OdeFixedJoint;
44 class OdeNullJoint;
45 class OdeAMotorJoint;
46 class OdeLMotorJoint;
47 class OdePlane2dJoint;
48 
49 ////////////////////////////////////////////////////////////////////
50 // Class : OdeJoint
51 // Description :
52 ////////////////////////////////////////////////////////////////////
53 class EXPCL_PANDAODE OdeJoint : public TypedObject {
54  friend class OdeBody;
55  friend class OdeUtil;
56 
57 public:
58  OdeJoint();
59  OdeJoint(dJointID id);
60 
61 PUBLISHED:
62  enum JointType { JT_none = 0, /* or "unknown" */
63  JT_ball,
64  JT_hinge,
65  JT_slider,
66  JT_contact,
67  JT_universal,
68  JT_hinge2,
69  JT_fixed,
70  JT_null,
71  JT_a_motor,
72  JT_l_motor,
73  JT_plane2d };
74 
75  virtual ~OdeJoint();
76  void destroy();
77  INLINE bool is_empty() const;
78  INLINE dJointID get_id() const;
79 
80  /* INLINE void set_data(void *data); */
81  /* INLINE void *get_data(); */
82  INLINE int get_joint_type() const;
83  OdeBody get_body(int index) const;
84  INLINE void set_feedback(OdeJointFeedback *);
85  INLINE void set_feedback(bool flag = true);
86  INLINE OdeJointFeedback *get_feedback();
87 
88  EXTENSION(void attach(const OdeBody *body1, const OdeBody *body2));
89  void attach_bodies(const OdeBody &body1, const OdeBody &body2);
90  void attach_body(const OdeBody &body, int index);
91  void detach();
92 
93  virtual void write(ostream &out = cout, unsigned int indent=0) const;
94  INLINE int compare_to(const OdeJoint &other) const;
95  INLINE bool operator == (const OdeJoint &other) const;
96  operator bool () const;
97 
98  EXTENSION(PyObject *convert() const);
99  OdeBallJoint convert_to_ball() const;
100  OdeHingeJoint convert_to_hinge() const;
101  OdeSliderJoint convert_to_slider() const;
102  OdeContactJoint convert_to_contact() const;
103  OdeUniversalJoint convert_to_universal() const;
104  OdeHinge2Joint convert_to_hinge2() const;
105  OdeFixedJoint convert_to_fixed() const;
106  OdeNullJoint convert_to_null() const;
107  OdeAMotorJoint convert_to_a_motor() const;
108  OdeLMotorJoint convert_to_l_motor() const;
109  OdePlane2dJoint convert_to_plane2d() const;
110 
111 protected:
112  dJointID _id;
113 
114 public:
115  static TypeHandle get_class_type() {
116  return _type_handle;
117  }
118  static void init_type() {
120  register_type(_type_handle, "OdeJoint",
121  TypedObject::get_class_type());
122  }
123  virtual TypeHandle get_type() const {
124  return get_class_type();
125  }
126  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
127 
128 private:
129  static TypeHandle _type_handle;
130 };
131 
132 #include "odeJoint.I"
133 
134 #endif
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:52
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:79
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85