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