summaryrefslogtreecommitdiff
path: root/src/ode/mass.c
blob: fb90d655fb61b17b2215e4cea48f4b66346aa402 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include <lua.h>
#include <lauxlib.h>
#include <ode/ode.h>
#include "ode_bindings.h"


int MassCreate_bind(lua_State *L)
{
	dMass *m = lua_newuserdata(L, sizeof(dMass));
	luaL_getmetatable(L, ode_mass_tname);
	lua_setmetatable(L, -2);
	return 1;
}


int dMassSetZero_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dMassSetZero(m);
	return 0;
}


int dMassSetParameters_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal themass = luaL_checknumber(L, 2);
	dReal cgx = luaL_checknumber(L, 3);
	dReal cgy = luaL_checknumber(L, 4);
	dReal cgz = luaL_checknumber(L, 5);
	dReal I11 = luaL_checknumber(L, 6);
	dReal I22 = luaL_checknumber(L, 7);
	dReal I33 = luaL_checknumber(L, 8);
	dReal I12 = luaL_checknumber(L, 9);
	dReal I13 = luaL_checknumber(L, 10);
	dReal I23 = luaL_checknumber(L, 11);
	dMassSetParameters(m, themass, cgx, cgy, cgz, I11, I22, I33, I12, I13, I23);
	return 0;
}


int dMassSetSphere_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal density = luaL_checknumber(L, 2);
	dReal radius = luaL_checknumber(L, 3);
	dMassSetSphere(m, density, radius);
	return 0;
}


int dMassSetSphereTotal_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal total_mass = luaL_checknumber(L, 2);
	dReal radius = luaL_checknumber(L, 3);
	dMassSetSphereTotal(m, total_mass, radius);
	return 0;
}


int dMassSetCapsule_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal density = luaL_checknumber(L, 2);
	int direction = luaL_checkinteger(L, 3);
	dReal radius = luaL_checknumber(L, 4);
	dReal length = luaL_checknumber(L, 5);
	dMassSetCapsule(m, density, direction, radius, length);
	return 0;
}


int dMassSetCapsuleTotal_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal total_mass = luaL_checknumber(L, 2);
	int direction = luaL_checkinteger(L, 3);
	dReal radius = luaL_checknumber(L, 4);
	dReal length = luaL_checknumber(L, 5);
	dMassSetCapsuleTotal(m, total_mass, direction, radius, length);
	return 0;
}


int dMassSetCylinder_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal density = luaL_checknumber(L, 2);
	int direction = luaL_checkinteger(L, 3);
	dReal radius = luaL_checknumber(L, 4);
	dReal length = luaL_checknumber(L, 5);
	dMassSetCylinder(m, density, direction, radius, length);
	return 0;
}


int dMassSetCylinderTotal_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal total_mass = luaL_checknumber(L, 2);
	int direction = luaL_checkinteger(L, 3);
	dReal radius = luaL_checknumber(L, 4);
	dReal length = luaL_checknumber(L, 5);
	dMassSetCylinderTotal(m, total_mass, direction, radius, length);
	return 0;
}


int dMassSetBox_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal density = luaL_checknumber(L, 2);
	dReal lx = luaL_checknumber(L, 3);
	dReal ly = luaL_checknumber(L, 4);
	dReal lz = luaL_checknumber(L, 5);
	dMassSetBox(m, density, lx, ly, lz);
	return 0;
}


int dMassSetBoxTotal_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal total_mass = luaL_checknumber(L, 2);
	dReal lx = luaL_checknumber(L, 3);
	dReal ly = luaL_checknumber(L, 4);
	dReal lz = luaL_checknumber(L, 5);
	dMassSetBoxTotal(m, total_mass, lx, ly, lz);
	return 0;
}


int dMassSetTrimesh_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal density = luaL_checknumber(L, 2);
	dGeomID g = luaL_checkudata(L, 3, ode_geom_tname);
	dMassSetTrimesh(m, density, g);
	return 0;
}


int dMassAdjust_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal newmass = luaL_checknumber(L, 2);
	dMassAdjust(m, newmass);
	return 0;
}


int dMassTranslate_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dReal x = luaL_checknumber(L, 2);
	dReal y = luaL_checknumber(L, 3);
	dReal z = luaL_checknumber(L, 4);
	dMassTranslate(m, x, y, z);
	return 0;
}


int dMassRotate_bind(lua_State *L)
{
	dMass * m = luaL_checkudata(L, 1, ode_mass_tname);
	dMatrix3 R;
	R[0] = luaL_checknumber(L, 2);
	R[1] = luaL_checknumber(L, 3);
	R[2] = luaL_checknumber(L, 4);

	R[4] = luaL_checknumber(L, 5);
	R[5] = luaL_checknumber(L, 6);
	R[6] = luaL_checknumber(L, 7);

	R[8] = luaL_checknumber(L, 8);
	R[9] = luaL_checknumber(L, 9);
	R[10] = luaL_checknumber(L, 10);
	dMassRotate(m, R);
	return 0;
}


int dMassAdd_bind(lua_State *L)
{
	dMass * ma = luaL_checkudata(L, 1, ode_mass_tname);
	const dMass * mb = luaL_checkudata(L, 2, ode_mass_tname);
	dMassAdd(ma, mb);
	return 0;
}