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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
#include <lua.h>
#include <lauxlib.h>
#include <cglm/cglm.h>
#include "glm.h"
int glm_quat_create(lua_State *L)
{
lua_newuserdata(L, sizeof(versor));
luaL_getmetatable(L, glm_versor_tname);
lua_setmetatable(L, -2);
return 1;
}
int glm_quat_identity_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
glm_quat_identity(*q);
return 0;
}
int glm_quat_init_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
float x = luaL_checknumber(L, 2);
float y = luaL_checknumber(L, 3);
float z = luaL_checknumber(L, 4);
float w = luaL_checknumber(L, 5);
glm_quat_init(*q, x, y, z, w);
return 0;
}
int glm_quat_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
float angle = luaL_checknumber(L, 2);
float x = luaL_checknumber(L, 3);
float y = luaL_checknumber(L, 4);
float z = luaL_checknumber(L, 5);
glm_quat(*q, angle, x, y, z);
return 0;
}
int glm_quatv_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
float angle = luaL_checknumber(L, 2);
vec3 *axis = luaL_checkudata(L, 3, glm_vec3_tname);
glm_quatv(*q, angle, *axis);
return 0;
}
int glm_quat_copy_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
versor *dest = luaL_checkudata(L, 2, glm_versor_tname);
glm_quat_copy(*q, *dest);
return 0;
}
int glm_quat_from_vecs_bind(lua_State *L)
{
vec3 *a = luaL_checkudata(L, 1, glm_vec3_tname);
vec3 *b = luaL_checkudata(L, 2, glm_vec3_tname);
versor *dest = luaL_checkudata(L, 3, glm_versor_tname);
glm_quat_from_vecs(*a, *b, *dest);
return 0;
}
int glm_quat_norm_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
float bind_result = glm_quat_norm(*q);
lua_pushnumber(L, bind_result);
return 1;
}
int glm_quat_normalize_to_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
versor *dest = luaL_checkudata(L, 2, glm_versor_tname);
glm_quat_normalize_to(*q, *dest);
return 0;
}
int glm_quat_normalize_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
glm_quat_normalize(*q);
return 0;
}
int glm_quat_dot_bind(lua_State *L)
{
versor *p = luaL_checkudata(L, 1, glm_versor_tname);
versor *q = luaL_checkudata(L, 2, glm_versor_tname);
float bind_result = glm_quat_dot(*p, *q);
lua_pushnumber(L, bind_result);
return 1;
}
int glm_quat_conjugate_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
versor *dest = luaL_checkudata(L, 2, glm_versor_tname);
glm_quat_conjugate(*q, *dest);
return 0;
}
int glm_quat_inv_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
versor *dest = luaL_checkudata(L, 2, glm_versor_tname);
glm_quat_inv(*q, *dest);
return 0;
}
int glm_quat_add_bind(lua_State *L)
{
versor *p = luaL_checkudata(L, 1, glm_versor_tname);
versor *q = luaL_checkudata(L, 2, glm_versor_tname);
versor *dest = luaL_checkudata(L, 3, glm_versor_tname);
glm_quat_add(*p, *q, *dest);
return 0;
}
int glm_quat_sub_bind(lua_State *L)
{
versor *p = luaL_checkudata(L, 1, glm_versor_tname);
versor *q = luaL_checkudata(L, 2, glm_versor_tname);
versor *dest = luaL_checkudata(L, 3, glm_versor_tname);
glm_quat_sub(*p, *q, *dest);
return 0;
}
int glm_quat_real_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
float bind_result = glm_quat_real(*q);
lua_pushnumber(L, bind_result);
return 1;
}
int glm_quat_imag_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
vec3 *dest = luaL_checkudata(L, 2, glm_vec3_tname);
glm_quat_imag(*q, *dest);
return 0;
}
int glm_quat_imagn_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
vec3 *dest = luaL_checkudata(L, 2, glm_vec3_tname);
glm_quat_imagn(*q, *dest);
return 0;
}
int glm_quat_imaglen_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
float bind_result = glm_quat_imaglen(*q);
lua_pushnumber(L, bind_result);
return 1;
}
int glm_quat_angle_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
float bind_result = glm_quat_angle(*q);
lua_pushnumber(L, bind_result);
return 1;
}
int glm_quat_axis_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
versor *dest = luaL_checkudata(L, 2, glm_versor_tname);
glm_quat_axis(*q, *dest);
return 0;
}
int glm_quat_mul_bind(lua_State *L)
{
versor *p = luaL_checkudata(L, 1, glm_versor_tname);
versor *q = luaL_checkudata(L, 2, glm_versor_tname);
versor *dest = luaL_checkudata(L, 3, glm_versor_tname);
glm_quat_mul(*p, *q, *dest);
return 0;
}
int glm_quat_mat4_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
mat4 *dest = luaL_checkudata(L, 2, glm_mat4_tname);
glm_quat_mat4(*q, *dest);
return 0;
}
int glm_quat_mat4t_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
mat4 *dest = luaL_checkudata(L, 2, glm_mat4_tname);
glm_quat_mat4t(*q, *dest);
return 0;
}
int glm_quat_mat3_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
mat3 *dest = luaL_checkudata(L, 2, glm_mat3_tname);
glm_quat_mat3(*q, *dest);
return 0;
}
int glm_quat_mat3t_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
mat3 *dest = luaL_checkudata(L, 2, glm_mat3_tname);
glm_quat_mat3t(*q, *dest);
return 0;
}
int glm_quat_lerp_bind(lua_State *L)
{
versor *from = luaL_checkudata(L, 1, glm_versor_tname);
versor *to = luaL_checkudata(L, 2, glm_versor_tname);
float t = luaL_checknumber(L, 3);
versor *dest = luaL_checkudata(L, 4, glm_versor_tname);
glm_quat_lerp(*from, *to, t, *dest);
return 0;
}
int glm_quat_nlerp_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
versor *r = luaL_checkudata(L, 2, glm_versor_tname);
float t = luaL_checknumber(L, 3);
versor *dest = luaL_checkudata(L, 4, glm_versor_tname);
glm_quat_nlerp(*q, *r, t, *dest);
return 0;
}
int glm_quat_slerp_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
versor *r = luaL_checkudata(L, 2, glm_versor_tname);
float t = luaL_checknumber(L, 3);
versor *dest = luaL_checkudata(L, 4, glm_versor_tname);
glm_quat_slerp(*q, *r, t, *dest);
return 0;
}
int glm_quat_look_bind(lua_State *L)
{
vec3 *eye = luaL_checkudata(L, 1, glm_vec3_tname);
versor *ori = luaL_checkudata(L, 2, glm_versor_tname);
mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
glm_quat_look(*eye, *ori, *dest);
return 0;
}
int glm_quat_for_bind(lua_State *L)
{
vec3 *dir = luaL_checkudata(L, 1, glm_vec3_tname);
vec3 *up = luaL_checkudata(L, 2, glm_vec3_tname);
versor *dest = luaL_checkudata(L, 3, glm_versor_tname);
glm_quat_for(*dir, *up, *dest);
return 0;
}
int glm_quat_forp_bind(lua_State *L)
{
vec3 *from = luaL_checkudata(L, 1, glm_vec3_tname);
vec3 *to = luaL_checkudata(L, 2, glm_vec3_tname);
vec3 *up = luaL_checkudata(L, 3, glm_vec3_tname);
versor *dest = luaL_checkudata(L, 4, glm_versor_tname);
glm_quat_forp(*from, *to, *up, *dest);
return 0;
}
int glm_quat_rotatev_bind(lua_State *L)
{
versor *q = luaL_checkudata(L, 1, glm_versor_tname);
vec3 *v = luaL_checkudata(L, 2, glm_vec3_tname);
vec3 *dest = luaL_checkudata(L, 3, glm_vec3_tname);
glm_quat_rotatev(*q, *v, *dest);
return 0;
}
int glm_quat_rotate_bind(lua_State *L)
{
mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
versor *q = luaL_checkudata(L, 2, glm_versor_tname);
mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
glm_quat_rotate(*m, *q, *dest);
return 0;
}
int glm_quat_rotate_at_bind(lua_State *L)
{
mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
versor *q = luaL_checkudata(L, 2, glm_versor_tname);
vec3 *pivot = luaL_checkudata(L, 3, glm_vec3_tname);
glm_quat_rotate_at(*m, *q, *pivot);
return 0;
}
int glm_quat_rotate_atm_bind(lua_State *L)
{
mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
versor *q = luaL_checkudata(L, 2, glm_versor_tname);
vec3 *pivot = luaL_checkudata(L, 3, glm_vec3_tname);
glm_quat_rotate_atm(*m, *q, *pivot);
return 0;
}
|