3 docCopyright("Jonathan Wright", 2006)
4 docLicense("BSD revised")
5 docDescription("ODEJoint binding")
8 #include "IoODEJoint_internal.h"
9 #include "IoODEHinge.h"
10 #include "IoODEBody.h"
13 #include "IoVector_ode.h"
14 #include "GLIncludes.h"
16 /* ----------------------------------------------------------- */
18 IoTag
*IoODEHinge_newTag(void *state
)
20 IoTag
*tag
= IoTag_newWithName_("ODEHinge");
21 IoTag_state_(tag
, state
);
22 IoTag_freeFunc_(tag
, (IoTagFreeFunc
*)IoODEHinge_free
);
23 IoTag_markFunc_(tag
, (IoTagMarkFunc
*)IoODEHinge_mark
);
24 IoTag_cloneFunc_(tag
, (IoTagCloneFunc
*)IoODEHinge_rawClone
);
28 IoODEHinge
*IoODEHinge_proto(void *state
)
30 IoObject
*self
= IoObject_new(state
);
31 IoObject_tag_(self
, IoODEHinge_newTag(state
));
33 IoODEJoint_protoCommon(self
);
35 IoState_registerProtoWithFunc_(state
, self
, IoODEHinge_proto
);
38 IoMethodTable methodTable
[] = {
39 ODE_COMMON_JOINT_METHODS
40 #define PARAM(X, _N, _SETN) \
41 {#_N, IoODEHinge_##_N}, \
42 {#_SETN, IoODEHinge_##_SETN},
46 {"anchor", IoODEHinge_anchor
},
47 {"setAnchor", IoODEHinge_setAnchor
},
48 {"anchor2", IoODEHinge_anchor2
},
49 {"axis", IoODEHinge_axis
},
50 {"setAxis", IoODEHinge_setAxis
},
51 {"angle", IoODEHinge_angle
},
52 {"angleRate", IoODEHinge_angleRate
},
53 {"addTorque", IoODEHinge_addTorque
},
57 IoObject_addMethodTable_(self
, methodTable
);
62 IoODEHinge
*IoODEHinge_rawClone(IoODEHinge
*proto
)
64 IoObject
*self
= IoODEJoint_rawClone(proto
);
66 if(DATA(proto
)->jointGroup
)
68 IoODEJointGroup
*jointGroup
= DATA(proto
)->jointGroup
;
70 JOINTGROUP
= jointGroup
;
71 IoODEJointGroup_addJoint(jointGroup
, self
);
72 JOINTID
= dJointCreateHinge(WORLDID
, JOINTGROUPID
);
77 void IoODEHinge_free(IoODEHinge
*self
)
79 IoODEJoint_free(self
);
82 void IoODEHinge_mark(IoODEHinge
*self
)
84 IoODEJoint_mark(self
);
87 IoODEJoint
*IoODEHinge_newProto(void *state
, IoODEJointGroup
*jointGroup
)
89 return IoODEJoint_newProtoCommon(state
, IoODEHinge_proto
, jointGroup
);
92 /* ----------------------------------------------------------- */
95 IoObject
*IoODEHinge_getParam(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
, int parameter
)
97 return IoODEJoint_getParam(self
, locals
, m
, parameter
, dJointGetHingeParam
);
100 IoObject
*IoODEHinge_setParam(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
, int parameter
)
102 return IoODEJoint_setParam(self
, locals
, m
, parameter
, dJointSetHingeParam
);
105 #define PARAM(X, _N, _SETN) \
106 IoObject *IoODEHinge_##_N(IoODEHinge *self, IoObject *locals, IoMessage *m) \
108 return IoODEHinge_getParam(self, locals, m, X); \
111 IoObject *IoODEHinge_##_SETN(IoODEHinge *self, IoObject *locals, IoMessage *m) \
113 return IoODEHinge_setParam(self, locals, m, X); \
118 IoObject
*IoODEHinge_anchor(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
)
120 return IoODEJoint_getVector3(self
, locals
, m
, dJointGetHingeAnchor
);
123 IoObject
*IoODEHinge_anchor2(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
)
125 return IoODEJoint_getVector3(self
, locals
, m
, dJointGetHingeAnchor2
);
128 IoObject
*IoODEHinge_axis(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
)
130 return IoODEJoint_getVector3(self
, locals
, m
, dJointGetHingeAxis
);
133 IoObject
*IoODEHinge_angle(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
)
135 return IoODEJoint_getReal(self
, locals
, m
, dJointGetHingeAngle
);
138 IoObject
*IoODEHinge_angleRate(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
)
140 return IoODEJoint_getReal(self
, locals
, m
, dJointGetHingeAngleRate
);
144 IoObject
*IoODEHinge_setAnchor(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
)
146 return IoODEJoint_setVector3(self
, locals
, m
, dJointSetHingeAnchor
);
149 IoObject
*IoODEHinge_setAxis(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
)
151 return IoODEJoint_setVector3(self
, locals
, m
, dJointSetHingeAxis
);
154 IoObject
*IoODEHinge_addTorque(IoODEHinge
*self
, IoObject
*locals
, IoMessage
*m
)
156 return IoODEJoint_setReal(self
, locals
, m
, dJointAddHingeTorque
);