1 //metadoc ODEJoint copyright Jonathan Wright, 2006
2 //metadoc ODEJoint license BSD revised
3 /*metadoc ODEJoint description
7 #include "IoODEJoint_internal.h"
8 #include "IoODEUniversal.h"
12 #include "IoVector_ode.h"
13 #include "GLIncludes.h"
15 /* ----------------------------------------------------------- */
17 IoTag
*IoODEUniversal_newTag(void *state
)
19 IoTag
*tag
= IoTag_newWithName_("ODEUniversal");
20 IoTag_state_(tag
, state
);
21 IoTag_freeFunc_(tag
, (IoTagFreeFunc
*)IoODEUniversal_free
);
22 IoTag_markFunc_(tag
, (IoTagMarkFunc
*)IoODEUniversal_mark
);
23 IoTag_cloneFunc_(tag
, (IoTagCloneFunc
*)IoODEUniversal_rawClone
);
27 IoODEUniversal
*IoODEUniversal_proto(void *state
)
29 IoObject
*self
= IoObject_new(state
);
30 IoObject_tag_(self
, IoODEUniversal_newTag(state
));
32 IoODEJoint_protoCommon(self
);
34 IoState_registerProtoWithFunc_(state
, self
, IoODEUniversal_proto
);
37 IoMethodTable methodTable
[] = {
38 ODE_COMMON_JOINT_METHODS
39 #define PARAM(X, _N, _SETN) \
40 {#_N, IoODEUniversal_##_N}, \
41 {#_SETN, IoODEUniversal_##_SETN},
45 {"anchor", IoODEUniversal_anchor
},
46 {"setAnchor", IoODEUniversal_setAnchor
},
47 {"anchor2", IoODEUniversal_anchor2
},
48 {"axis1", IoODEUniversal_axis1
},
49 {"setAxis1", IoODEUniversal_setAxis1
},
50 {"axis2", IoODEUniversal_axis2
},
51 {"setAxis2", IoODEUniversal_setAxis2
},
52 {"angle1", IoODEUniversal_angle1
},
53 {"angle2", IoODEUniversal_angle2
},
54 {"angle1Rate", IoODEUniversal_angle1Rate
},
55 {"angle2Rate", IoODEUniversal_angle2Rate
},
56 {"addTorques", IoODEUniversal_addTorques
},
60 IoObject_addMethodTable_(self
, methodTable
);
65 IoODEUniversal
*IoODEUniversal_rawClone(IoODEUniversal
*proto
)
67 IoObject
*self
= IoODEJoint_rawClone(proto
);
69 if(DATA(proto
)->jointGroup
)
71 IoODEJointGroup
*jointGroup
= DATA(proto
)->jointGroup
;
73 JOINTGROUP
= jointGroup
;
74 IoODEJointGroup_addJoint(jointGroup
, self
);
75 JOINTID
= dJointCreateUniversal(WORLDID
, JOINTGROUPID
);
80 void IoODEUniversal_free(IoODEUniversal
*self
)
82 IoODEJoint_free(self
);
85 void IoODEUniversal_mark(IoODEUniversal
*self
)
87 IoODEJoint_mark(self
);
90 IoODEJoint
*IoODEUniversal_newProto(void *state
, IoODEJointGroup
*jointGroup
)
92 return IoODEJoint_newProtoCommon(state
, IoODEUniversal_proto
, jointGroup
);
95 /* ----------------------------------------------------------- */
98 IoObject
*IoODEUniversal_getParam(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
, int parameter
)
100 return IoODEJoint_getParam(self
, locals
, m
, parameter
, dJointGetUniversalParam
);
103 IoObject
*IoODEUniversal_setParam(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
, int parameter
)
105 return IoODEJoint_setParam(self
, locals
, m
, parameter
, dJointSetUniversalParam
);
108 #define PARAM(X, _N, _SETN) \
109 IoObject *IoODEUniversal_##_N(IoODEUniversal *self, IoObject *locals, IoMessage *m) \
111 return IoODEUniversal_getParam(self, locals, m, X); \
114 IoObject *IoODEUniversal_##_SETN(IoODEUniversal *self, IoObject *locals, IoMessage *m) \
116 return IoODEUniversal_setParam(self, locals, m, X); \
121 IoObject
*IoODEUniversal_anchor(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
123 return IoODEJoint_getVector3(self
, locals
, m
, dJointGetUniversalAnchor
);
126 IoObject
*IoODEUniversal_anchor2(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
128 return IoODEJoint_getVector3(self
, locals
, m
, dJointGetUniversalAnchor2
);
131 IoObject
*IoODEUniversal_axis1(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
133 return IoODEJoint_getVector3(self
, locals
, m
, dJointGetUniversalAxis1
);
136 IoObject
*IoODEUniversal_axis2(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
138 return IoODEJoint_getVector3(self
, locals
, m
, dJointGetUniversalAxis2
);
141 IoObject
*IoODEUniversal_angle1(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
143 return IoODEJoint_getReal(self
, locals
, m
, dJointGetUniversalAngle1
);
146 IoObject
*IoODEUniversal_angle2(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
148 return IoODEJoint_getReal(self
, locals
, m
, dJointGetUniversalAngle2
);
151 IoObject
*IoODEUniversal_angle1Rate(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
153 return IoODEJoint_getReal(self
, locals
, m
, dJointGetUniversalAngle1Rate
);
156 IoObject
*IoODEUniversal_angle2Rate(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
158 return IoODEJoint_getReal(self
, locals
, m
, dJointGetUniversalAngle2Rate
);
162 IoObject
*IoODEUniversal_setAnchor(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
164 return IoODEJoint_setVector3(self
, locals
, m
, dJointSetUniversalAnchor
);
167 IoObject
*IoODEUniversal_setAxis1(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
169 return IoODEJoint_setVector3(self
, locals
, m
, dJointSetUniversalAxis1
);
172 IoObject
*IoODEUniversal_setAxis2(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
174 return IoODEJoint_setVector3(self
, locals
, m
, dJointSetUniversalAxis2
);
177 IoObject
*IoODEUniversal_addTorques(IoODEUniversal
*self
, IoObject
*locals
, IoMessage
*m
)
179 return IoODEJoint_setReal2(self
, locals
, m
, dJointAddUniversalTorques
);