more SystemCall fixes
[io/quag.git] / addons / ODE / source / IoODEUniversal.c
blob5623137b4b6dae9e4a5510dfcc5189ce499ce213
1 /*#io
2 ODEJoint ioDoc(
3 docCopyright("Jonathan Wright", 2006)
4 docLicense("BSD revised")
5 docDescription("ODEJoint binding")
6 */
8 #include "IoODEJoint_internal.h"
9 #include "IoODEUniversal.h"
10 #include "IoODEBody.h"
11 #include "IoState.h"
12 #include "IoSeq.h"
13 #include "IoVector_ode.h"
14 #include "GLIncludes.h"
16 /* ----------------------------------------------------------- */
18 IoTag *IoODEUniversal_newTag(void *state)
20 IoTag *tag = IoTag_newWithName_("ODEUniversal");
21 IoTag_state_(tag, state);
22 IoTag_freeFunc_(tag, (IoTagFreeFunc *)IoODEUniversal_free);
23 IoTag_markFunc_(tag, (IoTagMarkFunc *)IoODEUniversal_mark);
24 IoTag_cloneFunc_(tag, (IoTagCloneFunc *)IoODEUniversal_rawClone);
25 return tag;
28 IoODEUniversal *IoODEUniversal_proto(void *state)
30 IoObject *self = IoObject_new(state);
31 IoObject_tag_(self, IoODEUniversal_newTag(state));
33 IoODEJoint_protoCommon(self);
35 IoState_registerProtoWithFunc_(state, self, IoODEUniversal_proto);
38 IoMethodTable methodTable[] = {
39 ODE_COMMON_JOINT_METHODS
40 #define PARAM(X, _N, _SETN) \
41 {#_N, IoODEUniversal_##_N}, \
42 {#_SETN, IoODEUniversal_##_SETN},
43 PARAMS
44 #undef PARAM
46 {"anchor", IoODEUniversal_anchor},
47 {"setAnchor", IoODEUniversal_setAnchor},
48 {"anchor2", IoODEUniversal_anchor2},
49 {"axis1", IoODEUniversal_axis1},
50 {"setAxis1", IoODEUniversal_setAxis1},
51 {"axis2", IoODEUniversal_axis2},
52 {"setAxis2", IoODEUniversal_setAxis2},
53 {"angle1", IoODEUniversal_angle1},
54 {"angle2", IoODEUniversal_angle2},
55 {"angle1Rate", IoODEUniversal_angle1Rate},
56 {"angle2Rate", IoODEUniversal_angle2Rate},
57 {"addTorques", IoODEUniversal_addTorques},
59 {NULL, NULL},
61 IoObject_addMethodTable_(self, methodTable);
63 return self;
66 IoODEUniversal *IoODEUniversal_rawClone(IoODEUniversal *proto)
68 IoObject *self = IoODEJoint_rawClone(proto);
70 if(DATA(proto)->jointGroup)
72 IoODEJointGroup *jointGroup = DATA(proto)->jointGroup;
74 JOINTGROUP = jointGroup;
75 IoODEJointGroup_addJoint(jointGroup, self);
76 JOINTID = dJointCreateUniversal(WORLDID, JOINTGROUPID);
78 return self;
81 void IoODEUniversal_free(IoODEUniversal *self)
83 IoODEJoint_free(self);
86 void IoODEUniversal_mark(IoODEUniversal *self)
88 IoODEJoint_mark(self);
91 IoODEJoint *IoODEUniversal_newProto(void *state, IoODEJointGroup *jointGroup)
93 return IoODEJoint_newProtoCommon(state, IoODEUniversal_proto, jointGroup);
96 /* ----------------------------------------------------------- */
99 IoObject *IoODEUniversal_getParam(IoODEUniversal *self, IoObject *locals, IoMessage *m, int parameter)
101 return IoODEJoint_getParam(self, locals, m, parameter, dJointGetUniversalParam);
104 IoObject *IoODEUniversal_setParam(IoODEUniversal *self, IoObject *locals, IoMessage *m, int parameter)
106 return IoODEJoint_setParam(self, locals, m, parameter, dJointSetUniversalParam);
109 #define PARAM(X, _N, _SETN) \
110 IoObject *IoODEUniversal_##_N(IoODEUniversal *self, IoObject *locals, IoMessage *m) \
112 return IoODEUniversal_getParam(self, locals, m, X); \
115 IoObject *IoODEUniversal_##_SETN(IoODEUniversal *self, IoObject *locals, IoMessage *m) \
117 return IoODEUniversal_setParam(self, locals, m, X); \
119 PARAMS
120 #undef PARAM
122 IoObject *IoODEUniversal_anchor(IoODEUniversal *self, IoObject *locals, IoMessage *m)
124 return IoODEJoint_getVector3(self, locals, m, dJointGetUniversalAnchor);
127 IoObject *IoODEUniversal_anchor2(IoODEUniversal *self, IoObject *locals, IoMessage *m)
129 return IoODEJoint_getVector3(self, locals, m, dJointGetUniversalAnchor2);
132 IoObject *IoODEUniversal_axis1(IoODEUniversal *self, IoObject *locals, IoMessage *m)
134 return IoODEJoint_getVector3(self, locals, m, dJointGetUniversalAxis1);
137 IoObject *IoODEUniversal_axis2(IoODEUniversal *self, IoObject *locals, IoMessage *m)
139 return IoODEJoint_getVector3(self, locals, m, dJointGetUniversalAxis2);
142 IoObject *IoODEUniversal_angle1(IoODEUniversal *self, IoObject *locals, IoMessage *m)
144 return IoODEJoint_getReal(self, locals, m, dJointGetUniversalAngle1);
147 IoObject *IoODEUniversal_angle2(IoODEUniversal *self, IoObject *locals, IoMessage *m)
149 return IoODEJoint_getReal(self, locals, m, dJointGetUniversalAngle2);
152 IoObject *IoODEUniversal_angle1Rate(IoODEUniversal *self, IoObject *locals, IoMessage *m)
154 return IoODEJoint_getReal(self, locals, m, dJointGetUniversalAngle1Rate);
157 IoObject *IoODEUniversal_angle2Rate(IoODEUniversal *self, IoObject *locals, IoMessage *m)
159 return IoODEJoint_getReal(self, locals, m, dJointGetUniversalAngle2Rate);
163 IoObject *IoODEUniversal_setAnchor(IoODEUniversal *self, IoObject *locals, IoMessage *m)
165 return IoODEJoint_setVector3(self, locals, m, dJointSetUniversalAnchor);
168 IoObject *IoODEUniversal_setAxis1(IoODEUniversal *self, IoObject *locals, IoMessage *m)
170 return IoODEJoint_setVector3(self, locals, m, dJointSetUniversalAxis1);
173 IoObject *IoODEUniversal_setAxis2(IoODEUniversal *self, IoObject *locals, IoMessage *m)
175 return IoODEJoint_setVector3(self, locals, m, dJointSetUniversalAxis2);
178 IoObject *IoODEUniversal_addTorques(IoODEUniversal *self, IoObject *locals, IoMessage *m)
180 return IoODEJoint_setReal2(self, locals, m, dJointAddUniversalTorques);