Panda3D
odeBody.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 odeBody.h
10  * @author joswilso
11  * @date 2006-12-27
12  */
13 
14 #ifndef ODEBODY_H
15 #define ODEBODY_H
16 
17 #include "pandabase.h"
18 #include "typedObject.h"
19 #include "luse.h"
20 
21 #include "ode_includes.h"
22 #include "odeWorld.h"
23 #include "odeMass.h"
24 
25 class OdeJoint;
26 class OdeGeom;
27 class OdeCollisionEntry;
28 
29 /**
30  *
31  */
32 class EXPCL_PANDAODE OdeBody : public TypedObject {
33  friend class OdeJoint;
34  friend class OdeGeom;
35  friend class OdeCollisionEntry;
36 
37 public:
38  OdeBody(dBodyID id);
39 
40 PUBLISHED:
41  OdeBody(OdeWorld &world);
42  virtual ~OdeBody();
43  void destroy();
44  INLINE bool is_empty() const;
45  INLINE dBodyID get_id() const;
46 
47  INLINE void set_auto_disable_linear_threshold(dReal linear_threshold);
48  INLINE void set_auto_disable_angular_threshold(dReal angular_threshold);
49  INLINE void set_auto_disable_steps(int steps);
50  INLINE void set_auto_disable_time(dReal time);
51  INLINE void set_auto_disable_flag(int do_auto_disable);
52  INLINE void set_auto_disable_defaults();
53  INLINE void set_data(void *data);
54  EXTENSION(void set_data(PyObject *data));
55 
56  INLINE void set_position(dReal x, dReal y, dReal z);
57  INLINE void set_position(const LVecBase3f &pos);
58  INLINE void set_rotation(const LMatrix3f &r);
59  INLINE void set_quaternion(const LQuaternionf &q);
60  INLINE void set_linear_vel(dReal x, dReal y, dReal z);
61  INLINE void set_linear_vel(const LVecBase3f &vel);
62  INLINE void set_angular_vel(dReal x, dReal y, dReal z);
63  INLINE void set_angular_vel(const LVecBase3f &vel);
64  INLINE void set_mass(OdeMass &mass);
65 
66 
67  INLINE dReal get_auto_disable_linear_threshold() const;
68  INLINE dReal get_auto_disable_angular_threshold() const;
69  INLINE int get_auto_disable_steps() const;
70  INLINE dReal get_auto_disable_time() const;
71  INLINE int get_auto_disable_flag() const;
72 #ifndef CPPPARSER
73  INLINE void *get_data() const;
74 #endif
75  EXTENSION(PyObject *get_data() const);
76 
77  INLINE LVecBase3f get_position() const;
78  INLINE LMatrix3f get_rotation() const;
79  INLINE LVecBase4f get_quaternion() const;
80  INLINE LVecBase3f get_linear_vel() const;
81  INLINE LVecBase3f get_angular_vel() const;
82  INLINE OdeMass get_mass() const;
83 
84  INLINE void add_force(dReal fx, dReal fy, dReal fz);
85  INLINE void add_force(const LVecBase3f &f);
86  INLINE void add_torque(dReal fx, dReal fy, dReal fz);
87  INLINE void add_torque(const LVecBase3f &f);
88  INLINE void add_rel_force(dReal fx, dReal fy, dReal fz);
89  INLINE void add_rel_force(const LVecBase3f &f);
90  INLINE void add_rel_torque(dReal fx, dReal fy, dReal fz);
91  INLINE void add_rel_torque(const LVecBase3f &f);
92  INLINE void add_force_at_pos(dReal fx, dReal fy, dReal fz,
93  dReal px, dReal py, dReal pz);
94  INLINE void add_force_at_pos(const LVecBase3f &f,
95  const LVecBase3f &pos);
96  INLINE void add_force_at_rel_pos(dReal fx, dReal fy, dReal fz,
97  dReal px, dReal py, dReal pz);
98  INLINE void add_force_at_rel_pos(const LVecBase3f &f,
99  const LVecBase3f &pos);
100  INLINE void add_rel_force_at_pos(dReal fx, dReal fy, dReal fz,
101  dReal px, dReal py, dReal pz);
102  INLINE void add_rel_force_at_pos(const LVecBase3f &f,
103  const LVecBase3f &pos);
104  INLINE void add_rel_force_at_rel_pos(dReal fx, dReal fy, dReal fz,
105  dReal px, dReal py, dReal pz);
106  INLINE void add_rel_force_at_rel_pos(const LVecBase3f &f,
107  const LVecBase3f &pos);
108  INLINE void set_force(dReal x, dReal y, dReal z);
109  INLINE void set_force(const LVecBase3f &f);
110  INLINE void set_torque(dReal x, dReal y, dReal z);
111  INLINE void set_torque(const LVecBase3f &f);
112 
113  INLINE LPoint3f get_rel_point_pos(dReal px, dReal py, dReal pz) const;
114  INLINE LPoint3f get_rel_point_pos(const LVecBase3f &pos) const;
115  INLINE LPoint3f get_rel_point_vel(dReal px, dReal py, dReal pz) const;
116  INLINE LPoint3f get_rel_point_vel(const LVecBase3f &pos) const;
117  INLINE LPoint3f get_point_vel(dReal px, dReal py, dReal pz) const;
118  INLINE LPoint3f get_point_vel(const LVecBase3f &pos) const;
119  INLINE LPoint3f get_pos_rel_point(dReal px, dReal py, dReal pz) const;
120  INLINE LPoint3f get_pos_rel_point(const LVecBase3f &pos) const;
121  INLINE LVecBase3f vector_to_world(dReal px, dReal py, dReal pz) const;
122  INLINE LVecBase3f vector_to_world(const LVecBase3f &pos) const;
123  INLINE LVecBase3f vector_from_world(dReal px, dReal py, dReal pz) const;
124  INLINE LVecBase3f vector_from_world(const LVecBase3f &pos) const;
125 
126  INLINE void set_finite_rotation_mode(int mode);
127  INLINE void set_finite_rotation_axis(dReal x, dReal y, dReal z);
128  INLINE void set_finite_rotation_axis(const LVecBase3f &axis);
129  INLINE int get_finite_rotation_mode() const;
130  INLINE LVecBase3f get_finite_rotation_axis() const;
131 
132  INLINE int get_num_joints() const;
133  OdeJoint get_joint(int index) const;
134  MAKE_SEQ(get_joints, get_num_joints, get_joint);
135  EXTENSION(INLINE PyObject *get_converted_joint(int i) const);
136 
137  INLINE void enable();
138  INLINE void disable();
139  INLINE int is_enabled() const;
140  INLINE void set_gravity_mode(int mode);
141  INLINE int get_gravity_mode() const;
142 
143  virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const;
144  operator bool () const;
145  INLINE int compare_to(const OdeBody &other) const;
146 
147 private:
148  dBodyID _id;
149 
150 public:
151  typedef void (*DestroyCallback)(OdeBody &body);
152  DestroyCallback _destroy_callback = nullptr;
153 
154 public:
155  static TypeHandle get_class_type() {
156  return _type_handle;
157  }
158  static void init_type() {
160  register_type(_type_handle, "OdeBody",
161  TypedObject::get_class_type());
162  }
163  virtual TypeHandle get_type() const {
164  return get_class_type();
165  }
166  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
167 
168 private:
169  static TypeHandle _type_handle;
170 };
171 
172 #include "odeBody.I"
173 
174 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:44
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.
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:88
A class used to hold information about a collision that has occurred.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:73
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:81