00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ODEJOINT_H
00016 #define ODEJOINT_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 "odeJointGroup.h"
00025
00026 class EXPCL_PANDAODE OdeJointFeedback : public dJointFeedback {
00027 PUBLISHED:
00028 INLINE const LVector3f get_force1() const { return LVector3f(f1[0], f1[1], f1[2]); };
00029 INLINE const LVector3f get_force2() const { return LVector3f(f2[0], f2[1], f2[2]); };
00030 INLINE const LVector3f get_torque1() const { return LVector3f(t1[0], t1[1], t1[2]); };
00031 INLINE const LVector3f get_torque2() const { return LVector3f(t2[0], t2[1], t2[2]); };
00032 };
00033
00034
00035 class OdeBody;
00036
00037 class OdeBallJoint;
00038 class OdeHingeJoint;
00039 class OdeSliderJoint;
00040 class OdeContactJoint;
00041 class OdeUniversalJoint;
00042 class OdeHinge2Joint;
00043 class OdeFixedJoint;
00044 class OdeNullJoint;
00045 class OdeAMotorJoint;
00046 class OdeLMotorJoint;
00047 class OdePlane2dJoint;
00048
00049
00050
00051
00052
00053 class EXPCL_PANDAODE OdeJoint : public TypedObject {
00054 friend class OdeBody;
00055 friend class OdeUtil;
00056
00057 public:
00058 OdeJoint();
00059
00060 protected:
00061 OdeJoint(dJointID id);
00062
00063 PUBLISHED:
00064 enum JointType { JT_none = 0,
00065 JT_ball,
00066 JT_hinge,
00067 JT_slider,
00068 JT_contact,
00069 JT_universal,
00070 JT_hinge2,
00071 JT_fixed,
00072 JT_null,
00073 JT_a_motor,
00074 JT_l_motor,
00075 JT_plane2d };
00076
00077 virtual ~OdeJoint();
00078 void destroy();
00079 INLINE bool is_empty() const;
00080 INLINE dJointID get_id() const;
00081
00082
00083
00084 INLINE int get_joint_type() const;
00085 OdeBody get_body(int index) const;
00086 INLINE void set_feedback(OdeJointFeedback *);
00087 INLINE void set_feedback(bool flag = true);
00088 INLINE OdeJointFeedback *get_feedback();
00089
00090 void attach_bodies(const OdeBody &body1, const OdeBody &body2);
00091 void attach_body(const OdeBody &body, int index);
00092 void detach();
00093
00094 virtual void write(ostream &out = cout, unsigned int indent=0) const;
00095 INLINE int compare_to(const OdeJoint &other) const;
00096 INLINE bool operator == (const OdeJoint &other) const;
00097 operator bool () const;
00098
00099 OdeBallJoint convert_to_ball() const;
00100 OdeHingeJoint convert_to_hinge() const;
00101 OdeSliderJoint convert_to_slider() const;
00102 OdeContactJoint convert_to_contact() const;
00103 OdeUniversalJoint convert_to_universal() const;
00104 OdeHinge2Joint convert_to_hinge2() const;
00105 OdeFixedJoint convert_to_fixed() const;
00106 OdeNullJoint convert_to_null() const;
00107 OdeAMotorJoint convert_to_a_motor() const;
00108 OdeLMotorJoint convert_to_l_motor() const;
00109 OdePlane2dJoint convert_to_plane2d() const;
00110
00111 protected:
00112 dJointID _id;
00113
00114 public:
00115 static TypeHandle get_class_type() {
00116 return _type_handle;
00117 }
00118 static void init_type() {
00119 TypedObject::init_type();
00120 register_type(_type_handle, "OdeJoint",
00121 TypedObject::get_class_type());
00122 }
00123 virtual TypeHandle get_type() const {
00124 return get_class_type();
00125 }
00126 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00127
00128 private:
00129 static TypeHandle _type_handle;
00130 };
00131
00132 #include "odeJoint.I"
00133
00134 #endif