00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ODEBODY_H
00016 #define ODEBODY_H
00017
00018 #include "pandabase.h"
00019 #include "typedObject.h"
00020 #include "luse.h"
00021
00022 #include "ode_includes.h"
00023 #include "odeWorld.h"
00024 #include "odeMass.h"
00025 #ifdef HAVE_PYTHON
00026 #include "Python.h"
00027 #endif
00028
00029 class OdeJoint;
00030 class OdeGeom;
00031 class OdeCollisionEntry;
00032
00033
00034
00035
00036
00037 class EXPCL_PANDAODE OdeBody : public TypedObject {
00038 friend class OdeJoint;
00039 friend class OdeGeom;
00040 friend class OdeCollisionEntry;
00041
00042 protected:
00043 OdeBody(dBodyID id);
00044
00045 PUBLISHED:
00046 OdeBody(OdeWorld &world);
00047 virtual ~OdeBody();
00048 void destroy();
00049 INLINE bool is_empty() const;
00050 INLINE dBodyID get_id() const;
00051
00052 INLINE void set_auto_disable_linear_threshold(dReal linear_threshold);
00053 INLINE void set_auto_disable_angular_threshold(dReal angular_threshold);
00054 INLINE void set_auto_disable_steps(int steps);
00055 INLINE void set_auto_disable_time(dReal time);
00056 INLINE void set_auto_disable_flag(int do_auto_disable);
00057 INLINE void set_auto_disable_defaults();
00058 INLINE void set_data(void *data);
00059 #ifdef HAVE_PYTHON
00060 INLINE void set_data(PyObject *data);
00061 #endif
00062
00063 INLINE void set_position(dReal x, dReal y, dReal z);
00064 INLINE void set_position(const LVecBase3f &pos);
00065 INLINE void set_rotation(const LMatrix3f &r);
00066 INLINE void set_quaternion(const LQuaternionf &q);
00067 INLINE void set_linear_vel(dReal x, dReal y, dReal z);
00068 INLINE void set_linear_vel(const LVecBase3f &vel);
00069 INLINE void set_angular_vel(dReal x, dReal y, dReal z);
00070 INLINE void set_angular_vel(const LVecBase3f &vel);
00071 INLINE void set_mass(OdeMass &mass);
00072
00073
00074 INLINE dReal get_auto_disable_linear_threshold() const;
00075 INLINE dReal get_auto_disable_angular_threshold() const;
00076 INLINE int get_auto_disable_steps() const;
00077 INLINE dReal get_auto_disable_time() const;
00078 INLINE int get_auto_disable_flag() const;
00079 #ifdef HAVE_PYTHON
00080 INLINE PyObject* get_data() const;
00081 #else
00082 INLINE void* get_data() const;
00083 #endif
00084
00085 INLINE LVecBase3f get_position() const;
00086 INLINE LMatrix3f get_rotation() const;
00087 INLINE LVecBase4f get_quaternion() const;
00088 INLINE LVecBase3f get_linear_vel() const;
00089 INLINE LVecBase3f get_angular_vel() const;
00090 INLINE OdeMass get_mass() const;
00091
00092 INLINE void add_force(dReal fx, dReal fy, dReal fz);
00093 INLINE void add_force(const LVecBase3f &f);
00094 INLINE void add_torque(dReal fx, dReal fy, dReal fz);
00095 INLINE void add_torque(const LVecBase3f &f);
00096 INLINE void add_rel_force(dReal fx, dReal fy, dReal fz);
00097 INLINE void add_rel_force(const LVecBase3f &f);
00098 INLINE void add_rel_torque(dReal fx, dReal fy, dReal fz);
00099 INLINE void add_rel_torque(const LVecBase3f &f);
00100 INLINE void add_force_at_pos(dReal fx, dReal fy, dReal fz,
00101 dReal px, dReal py, dReal pz);
00102 INLINE void add_force_at_pos(const LVecBase3f &f,
00103 const LVecBase3f &pos);
00104 INLINE void add_force_at_rel_pos(dReal fx, dReal fy, dReal fz,
00105 dReal px, dReal py, dReal pz);
00106 INLINE void add_force_at_rel_pos(const LVecBase3f &f,
00107 const LVecBase3f &pos);
00108 INLINE void add_rel_force_at_pos(dReal fx, dReal fy, dReal fz,
00109 dReal px, dReal py, dReal pz);
00110 INLINE void add_rel_force_at_pos(const LVecBase3f &f,
00111 const LVecBase3f &pos);
00112 INLINE void add_rel_force_at_rel_pos(dReal fx, dReal fy, dReal fz,
00113 dReal px, dReal py, dReal pz);
00114 INLINE void add_rel_force_at_rel_pos(const LVecBase3f &f,
00115 const LVecBase3f &pos);
00116 INLINE void set_force(dReal x, dReal y, dReal z);
00117 INLINE void set_force(const LVecBase3f &f);
00118 INLINE void set_torque(dReal x, dReal y, dReal z);
00119 INLINE void set_torque(const LVecBase3f &f);
00120
00121 INLINE LPoint3f get_rel_point_pos(dReal px, dReal py, dReal pz) const;
00122 INLINE LPoint3f get_rel_point_pos(const LVecBase3f &pos) const;
00123 INLINE LPoint3f get_rel_point_vel(dReal px, dReal py, dReal pz) const;
00124 INLINE LPoint3f get_rel_point_vel(const LVecBase3f &pos) const;
00125 INLINE LPoint3f get_point_vel(dReal px, dReal py, dReal pz) const;
00126 INLINE LPoint3f get_point_vel(const LVecBase3f &pos) const;
00127 INLINE LPoint3f get_pos_rel_point(dReal px, dReal py, dReal pz) const;
00128 INLINE LPoint3f get_pos_rel_point(const LVecBase3f &pos) const;
00129 INLINE LVecBase3f vector_to_world(dReal px, dReal py, dReal pz) const;
00130 INLINE LVecBase3f vector_to_world(const LVecBase3f &pos) const;
00131 INLINE LVecBase3f vector_from_world(dReal px, dReal py, dReal pz) const;
00132 INLINE LVecBase3f vector_from_world(const LVecBase3f &pos) const;
00133
00134 INLINE void set_finite_rotation_mode(int mode);
00135 INLINE void set_finite_rotation_axis(dReal x, dReal y, dReal z);
00136 INLINE void set_finite_rotation_axis(const LVecBase3f &axis);
00137 INLINE int get_finite_rotation_mode() const;
00138 INLINE LVecBase3f get_finite_rotation_axis() const;
00139
00140 INLINE int get_num_joints() const;
00141 OdeJoint get_joint(int index) const;
00142 MAKE_SEQ(get_joints, get_num_joints, get_joint);
00143 INLINE void enable();
00144 INLINE void disable();
00145 INLINE int is_enabled() const;
00146 INLINE void set_gravity_mode(int mode);
00147 INLINE int get_gravity_mode() const;
00148
00149 virtual void write(ostream &out = cout, unsigned int indent=0) const;
00150 operator bool () const;
00151 INLINE int compare_to(const OdeBody &other) const;
00152
00153 private:
00154 dBodyID _id;
00155
00156 public:
00157 static TypeHandle get_class_type() {
00158 return _type_handle;
00159 }
00160 static void init_type() {
00161 TypedObject::init_type();
00162 register_type(_type_handle, "OdeBody",
00163 TypedObject::get_class_type());
00164 }
00165 virtual TypeHandle get_type() const {
00166 return get_class_type();
00167 }
00168 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00169
00170 private:
00171 static TypeHandle _type_handle;
00172 };
00173
00174 #include "odeBody.I"
00175
00176 #endif