Panda3D
 All Classes Functions Variables Enumerations
odeBody.h
1 // Filename: odeBody.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 ODEBODY_H
16 #define ODEBODY_H
17 
18 #include "pandabase.h"
19 #include "typedObject.h"
20 #include "luse.h"
21 
22 #include "ode_includes.h"
23 #include "odeWorld.h"
24 #include "odeMass.h"
25 #ifdef HAVE_PYTHON
26 #include "Python.h"
27 #endif
28 
29 class OdeJoint;
30 class OdeGeom;
31 class OdeCollisionEntry;
32 
33 ////////////////////////////////////////////////////////////////////
34 // Class : OdeBody
35 // Description :
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_PANDAODE OdeBody : public TypedObject {
38  friend class OdeJoint;
39  friend class OdeGeom;
40  friend class OdeCollisionEntry;
41 
42 public:
43  OdeBody(dBodyID id);
44 
45 PUBLISHED:
46  OdeBody(OdeWorld &world);
47  virtual ~OdeBody();
48  void destroy();
49  INLINE bool is_empty() const;
50  INLINE dBodyID get_id() const;
51 
52  INLINE void set_auto_disable_linear_threshold(dReal linear_threshold);
53  INLINE void set_auto_disable_angular_threshold(dReal angular_threshold);
54  INLINE void set_auto_disable_steps(int steps);
55  INLINE void set_auto_disable_time(dReal time);
56  INLINE void set_auto_disable_flag(int do_auto_disable);
57  INLINE void set_auto_disable_defaults();
58  INLINE void set_data(void *data);
59 #ifdef HAVE_PYTHON
60  INLINE void set_data(PyObject *data);
61 #endif
62 
63  INLINE void set_position(dReal x, dReal y, dReal z);
64  INLINE void set_position(const LVecBase3f &pos);
65  INLINE void set_rotation(const LMatrix3f &r);
66  INLINE void set_quaternion(const LQuaternionf &q);
67  INLINE void set_linear_vel(dReal x, dReal y, dReal z);
68  INLINE void set_linear_vel(const LVecBase3f &vel);
69  INLINE void set_angular_vel(dReal x, dReal y, dReal z);
70  INLINE void set_angular_vel(const LVecBase3f &vel);
71  INLINE void set_mass(OdeMass &mass);
72 
73 
74  INLINE dReal get_auto_disable_linear_threshold() const;
75  INLINE dReal get_auto_disable_angular_threshold() const;
76  INLINE int get_auto_disable_steps() const;
77  INLINE dReal get_auto_disable_time() const;
78  INLINE int get_auto_disable_flag() const;
79 #ifdef HAVE_PYTHON
80  INLINE PyObject* get_data() const;
81 #else
82  INLINE void* get_data() const;
83 #endif
84 
85  INLINE LVecBase3f get_position() const;
86  INLINE LMatrix3f get_rotation() const;
87  INLINE LVecBase4f get_quaternion() const;
88  INLINE LVecBase3f get_linear_vel() const;
89  INLINE LVecBase3f get_angular_vel() const;
90  INLINE OdeMass get_mass() const;
91 
92  INLINE void add_force(dReal fx, dReal fy, dReal fz);
93  INLINE void add_force(const LVecBase3f &f);
94  INLINE void add_torque(dReal fx, dReal fy, dReal fz);
95  INLINE void add_torque(const LVecBase3f &f);
96  INLINE void add_rel_force(dReal fx, dReal fy, dReal fz);
97  INLINE void add_rel_force(const LVecBase3f &f);
98  INLINE void add_rel_torque(dReal fx, dReal fy, dReal fz);
99  INLINE void add_rel_torque(const LVecBase3f &f);
100  INLINE void add_force_at_pos(dReal fx, dReal fy, dReal fz,
101  dReal px, dReal py, dReal pz);
102  INLINE void add_force_at_pos(const LVecBase3f &f,
103  const LVecBase3f &pos);
104  INLINE void add_force_at_rel_pos(dReal fx, dReal fy, dReal fz,
105  dReal px, dReal py, dReal pz);
106  INLINE void add_force_at_rel_pos(const LVecBase3f &f,
107  const LVecBase3f &pos);
108  INLINE void add_rel_force_at_pos(dReal fx, dReal fy, dReal fz,
109  dReal px, dReal py, dReal pz);
110  INLINE void add_rel_force_at_pos(const LVecBase3f &f,
111  const LVecBase3f &pos);
112  INLINE void add_rel_force_at_rel_pos(dReal fx, dReal fy, dReal fz,
113  dReal px, dReal py, dReal pz);
114  INLINE void add_rel_force_at_rel_pos(const LVecBase3f &f,
115  const LVecBase3f &pos);
116  INLINE void set_force(dReal x, dReal y, dReal z);
117  INLINE void set_force(const LVecBase3f &f);
118  INLINE void set_torque(dReal x, dReal y, dReal z);
119  INLINE void set_torque(const LVecBase3f &f);
120 
121  INLINE LPoint3f get_rel_point_pos(dReal px, dReal py, dReal pz) const;
122  INLINE LPoint3f get_rel_point_pos(const LVecBase3f &pos) const;
123  INLINE LPoint3f get_rel_point_vel(dReal px, dReal py, dReal pz) const;
124  INLINE LPoint3f get_rel_point_vel(const LVecBase3f &pos) const;
125  INLINE LPoint3f get_point_vel(dReal px, dReal py, dReal pz) const;
126  INLINE LPoint3f get_point_vel(const LVecBase3f &pos) const;
127  INLINE LPoint3f get_pos_rel_point(dReal px, dReal py, dReal pz) const;
128  INLINE LPoint3f get_pos_rel_point(const LVecBase3f &pos) const;
129  INLINE LVecBase3f vector_to_world(dReal px, dReal py, dReal pz) const;
130  INLINE LVecBase3f vector_to_world(const LVecBase3f &pos) const;
131  INLINE LVecBase3f vector_from_world(dReal px, dReal py, dReal pz) const;
132  INLINE LVecBase3f vector_from_world(const LVecBase3f &pos) const;
133 
134  INLINE void set_finite_rotation_mode(int mode);
135  INLINE void set_finite_rotation_axis(dReal x, dReal y, dReal z);
136  INLINE void set_finite_rotation_axis(const LVecBase3f &axis);
137  INLINE int get_finite_rotation_mode() const;
138  INLINE LVecBase3f get_finite_rotation_axis() const;
139 
140  INLINE int get_num_joints() const;
141  OdeJoint get_joint(int index) const;
142  MAKE_SEQ(get_joints, get_num_joints, get_joint);
143  EXTENSION(INLINE PyObject *get_converted_joint(int i) const);
144 
145  INLINE void enable();
146  INLINE void disable();
147  INLINE int is_enabled() const;
148  INLINE void set_gravity_mode(int mode);
149  INLINE int get_gravity_mode() const;
150 
151  virtual void write(ostream &out = cout, unsigned int indent=0) const;
152  operator bool () const;
153  INLINE int compare_to(const OdeBody &other) const;
154 
155 private:
156  dBodyID _id;
157 
158 public:
159  static TypeHandle get_class_type() {
160  return _type_handle;
161  }
162  static void init_type() {
164  register_type(_type_handle, "OdeBody",
165  TypedObject::get_class_type());
166  }
167  virtual TypeHandle get_type() const {
168  return get_class_type();
169  }
170  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
171 
172 private:
173  static TypeHandle _type_handle;
174 };
175 
176 #include "odeBody.I"
177 
178 #endif
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
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 point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
A class used to hold information about a collision that has occurred.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:79
This is the base quaternion class.
Definition: lquaternion.h:96
bool is_empty() const
Returns true if the entry holds no contacts.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:110