summaryrefslogtreecommitdiff
path: root/src/ode/geom.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ode/geom.c')
-rw-r--r--src/ode/geom.c1109
1 files changed, 1109 insertions, 0 deletions
diff --git a/src/ode/geom.c b/src/ode/geom.c
new file mode 100644
index 0000000..b7694ad
--- /dev/null
+++ b/src/ode/geom.c
@@ -0,0 +1,1109 @@
+#include <lua.h>
+#include <lauxlib.h>
+#include <ode/ode.h>
+#include "ode_bindings.h"
+
+
+void ode_push_geom(lua_State *L, dGeomID g)
+{
+ dGeomID *gu = lua_newuserdata(L, sizeof(dGeomID));
+ *gu = g;
+ luaL_getmetatable(L, ode_geom_tname);
+ lua_setmetatable(L, -2);
+}
+
+
+void ode_push_space(lua_State *L, dSpaceID s)
+{
+ dSpaceID *su = lua_newuserdata(L, sizeof(dSpaceID));
+ *su = s;
+ luaL_getmetatable(L, ode_space_tname);
+ lua_setmetatable(L, -2);
+}
+
+
+void ode_push_contactgeom(lua_State *L, dContactGeom cg)
+{
+ dContactGeom *cgu = lua_newuserdata(L, sizeof(dContactGeom));
+ *cgu = cg;
+}
+
+
+int dGeomDestroy_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dGeomDestroy(*g);
+ return 0;
+}
+
+
+int dGeomSetBody_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dBodyID *b = luaL_checkudata(L, 2, ode_body_tname);
+ dGeomSetBody(*g, *b);
+ return 0;
+}
+
+
+int dGeomGetBody_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dBodyID bind_result = dGeomGetBody(*g);
+ ode_push_body(L, bind_result);
+ return 1;
+}
+
+
+int dGeomSetPosition_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal x = luaL_checknumber(L, 2);
+ dReal y = luaL_checknumber(L, 3);
+ dReal z = luaL_checknumber(L, 4);
+ dGeomSetPosition(*g, x, y, z);
+ return 0;
+}
+
+
+int dGeomSetRotation_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_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);
+ dGeomSetRotation(*g, R);
+ return 0;
+}
+
+
+int dGeomSetQuaternion_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dQuaternion q;
+ q[0] = luaL_checknumber(L, 2);
+ q[1] = luaL_checknumber(L, 3);
+ q[2] = luaL_checknumber(L, 4);
+ q[3] = luaL_checknumber(L, 5);
+ dGeomSetQuaternion(*g, q);
+ return 0;
+}
+
+
+int dGeomGetPosition_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ const dReal * bind_result = dGeomGetPosition(*g);
+ lua_pushnumber(L, bind_result[0]);
+ lua_pushnumber(L, bind_result[1]);
+ lua_pushnumber(L, bind_result[2]);
+ return 3;
+}
+
+
+int dGeomGetRotation_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ const dReal * bind_result = dGeomGetRotation(*g);
+ lua_pushnumber(L, bind_result[0]);
+ lua_pushnumber(L, bind_result[1]);
+ lua_pushnumber(L, bind_result[2]);
+ lua_pushnumber(L, bind_result[4]);
+ lua_pushnumber(L, bind_result[5]);
+ lua_pushnumber(L, bind_result[6]);
+ lua_pushnumber(L, bind_result[8]);
+ lua_pushnumber(L, bind_result[9]);
+ lua_pushnumber(L, bind_result[10]);
+ return 9;
+}
+
+
+int dGeomGetQuaternion_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dQuaternion result;
+ dGeomGetQuaternion(*g, result);
+ lua_pushnumber(L, result[0]);
+ lua_pushnumber(L, result[1]);
+ lua_pushnumber(L, result[2]);
+ lua_pushnumber(L, result[3]);
+ return 4;
+}
+
+
+int dGeomSetOffsetPosition_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal x = luaL_checknumber(L, 2);
+ dReal y = luaL_checknumber(L, 3);
+ dReal z = luaL_checknumber(L, 4);
+ dGeomSetOffsetPosition(*g, x, y, z);
+ return 0;
+}
+
+
+int dGeomSetOffsetRotation_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_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);
+ dGeomSetOffsetRotation(*g, R);
+ return 0;
+}
+
+
+int dGeomSetOffsetQuaternion_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dQuaternion Q;
+ Q[0] = luaL_checknumber(L, 2);
+ Q[1] = luaL_checknumber(L, 3);
+ Q[2] = luaL_checknumber(L, 4);
+ Q[3] = luaL_checknumber(L, 5);
+ dGeomSetOffsetQuaternion(*g, Q);
+ return 0;
+}
+
+
+int dGeomSetOffsetWorldPosition_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal x = luaL_checknumber(L, 2);
+ dReal y = luaL_checknumber(L, 3);
+ dReal z = luaL_checknumber(L, 4);
+ dGeomSetOffsetWorldPosition(*g, x, y, z);
+ return 0;
+}
+
+
+int dGeomSetOffsetWorldRotation_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_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);
+ dGeomSetOffsetWorldRotation(*g, R);
+ return 0;
+}
+
+
+int dGeomSetOffsetWorldQuaternion_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dQuaternion Q;
+ Q[0] = luaL_checknumber(L, 2);
+ Q[1] = luaL_checknumber(L, 3);
+ Q[2] = luaL_checknumber(L, 4);
+ Q[3] = luaL_checknumber(L, 5);
+ dGeomSetOffsetWorldQuaternion(*g, Q);
+ return 0;
+}
+
+
+int dGeomGetOffsetPosition_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ const dReal * bind_result = dGeomGetOffsetPosition(*g);
+ lua_pushnumber(L, bind_result[0]);
+ lua_pushnumber(L, bind_result[1]);
+ lua_pushnumber(L, bind_result[2]);
+ return 3;
+}
+
+
+int dGeomGetOffsetRotation_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ const dReal * bind_result = dGeomGetOffsetRotation(*g);
+ lua_pushnumber(L, bind_result[0]);
+ lua_pushnumber(L, bind_result[1]);
+ lua_pushnumber(L, bind_result[2]);
+ lua_pushnumber(L, bind_result[4]);
+ lua_pushnumber(L, bind_result[5]);
+ lua_pushnumber(L, bind_result[6]);
+ lua_pushnumber(L, bind_result[8]);
+ lua_pushnumber(L, bind_result[9]);
+ lua_pushnumber(L, bind_result[10]);
+ return 9;
+}
+
+
+int dGeomGetOffsetQuaternion_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dQuaternion result;
+ dGeomGetOffsetQuaternion(*g, result);
+ lua_pushnumber(L, result[0]);
+ lua_pushnumber(L, result[1]);
+ lua_pushnumber(L, result[2]);
+ lua_pushnumber(L, result[3]);
+ return 4;
+}
+
+
+int dGeomClearOffset_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dGeomClearOffset(*g);
+ return 0;
+}
+
+
+int dGeomGetAABB_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal aabb[6];
+ dGeomGetAABB(*g, aabb);
+ lua_pushnumber(L, aabb[0]);
+ lua_pushnumber(L, aabb[1]);
+ lua_pushnumber(L, aabb[2]);
+ lua_pushnumber(L, aabb[3]);
+ lua_pushnumber(L, aabb[4]);
+ lua_pushnumber(L, aabb[5]);
+ return 6;
+}
+
+
+int dGeomIsSpace_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ int bind_result = dGeomIsSpace(*g);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int dGeomGetSpace_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dSpaceID bind_result = dGeomGetSpace(*g);
+ ode_push_space(L, bind_result);
+ return 1;
+}
+
+
+int dGeomGetClass_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ int bind_result = dGeomGetClass(*g);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int dGeomSetCategoryBits_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ unsigned long bits = luaL_checkinteger(L, 2);
+ dGeomSetCategoryBits(*g, bits);
+ return 0;
+}
+
+
+int dGeomSetCollideBits_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ unsigned long bits = luaL_checkinteger(L, 2);
+ dGeomSetCollideBits(*g, bits);
+ return 0;
+}
+
+
+int dGeomGetCategoryBits_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ unsigned long bind_result = dGeomGetCategoryBits(*g);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int dGeomGetCollideBits_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ unsigned long bind_result = dGeomGetCollideBits(*g);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int dGeomEnable_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dGeomEnable(*g);
+ return 0;
+}
+
+
+int dGeomDisable_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dGeomDisable(*g);
+ return 0;
+}
+
+
+int dGeomIsEnabled_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ int bind_result = dGeomIsEnabled(*g);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int dCollide_bind(lua_State *L)
+{
+ dGeomID *o1 = luaL_checkudata(L, 1, ode_geom_tname);
+ dGeomID *o2 = luaL_checkudata(L, 2, ode_geom_tname);
+ int flags = luaL_checkinteger(L, 3);
+ size_t count = flags & 0xff; /* lower 16 bits for flags are the number of contacts requested */
+ dContactGeom *contacts = malloc(count * sizeof(dContactGeom));
+ if (contacts == NULL) {
+ return luaL_error(L, "failed to allocate %lu bytes for contacts buffer", count * sizeof(dContactGeom));
+ }
+ count = dCollide(*o1, *o2, flags, contacts, sizeof(dContactGeom));
+
+ lua_createtable(L, count, 0);
+ int tbl = lua_gettop(L);
+ for (int i=0; i<count; i++) {
+ ode_push_contactgeom(L, contacts[i]);
+ lua_rawseti(L, tbl, i+1);
+ }
+ return 1;
+}
+
+
+struct near_data_t {
+ lua_State *L;
+ int ref;
+};
+
+static void near(void *data, dGeomID o1, dGeomID o2)
+{
+ struct near_data_t *d = data;
+ lua_State *L = d->L;
+
+ lua_rawgeti(L, LUA_REGISTRYINDEX, d->ref);
+ ode_push_geom(L, o1);
+ ode_push_geom(L, o2);
+ lua_call(L, 2, 0);
+}
+
+int dSpaceCollide_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ luaL_checktype(L, 2, LUA_TFUNCTION);
+ lua_pushvalue(L, 2);
+ int ref = luaL_ref(L, LUA_REGISTRYINDEX);
+ struct near_data_t data = { L, ref };
+ dSpaceCollide(*space, &data, near);
+ luaL_unref(L, LUA_REGISTRYINDEX, ref);
+ return 0;
+}
+
+
+int dSpaceCollide2_bind(lua_State *L)
+{
+ dGeomID *o1 = luaL_checkudata(L, 1, ode_geom_tname);
+ dGeomID *o2 = luaL_checkudata(L, 2, ode_geom_tname);
+ luaL_checktype(L, 3, LUA_TFUNCTION);
+ lua_pushvalue(L, 3);
+ int ref = luaL_ref(L, LUA_REGISTRYINDEX);
+ struct near_data_t data = { L, ref };
+ dSpaceCollide2(*o1, *o2, &data, near);
+ luaL_unref(L, LUA_REGISTRYINDEX, ref);
+ return 0;
+}
+
+
+int dSimpleSpaceCreate_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dSpaceID bind_result = dSimpleSpaceCreate(*space);
+ ode_push_space(L, bind_result);
+ return 1;
+}
+
+
+int dHashSpaceCreate_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dSpaceID bind_result = dHashSpaceCreate(*space);
+ ode_push_space(L, bind_result);
+ return 1;
+}
+
+
+int dQuadTreeSpaceCreate_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dVector3 Center;
+ Center[0] = luaL_checknumber(L, 2);
+ Center[1] = luaL_checknumber(L, 3);
+ Center[2] = luaL_checknumber(L, 4);
+ dVector3 Extents;
+ Extents[0] = luaL_checknumber(L, 5);
+ Extents[1] = luaL_checknumber(L, 6);
+ Extents[2] = luaL_checknumber(L, 7);
+ int Depth = luaL_checkinteger(L, 8);
+ dSpaceID bind_result = dQuadTreeSpaceCreate(*space, Center, Extents, Depth);
+ ode_push_space(L, bind_result);
+ return 1;
+}
+
+
+int dSpaceDestroy_bind(lua_State *L)
+{
+ dSpaceID *s = luaL_checkudata(L, 1, ode_space_tname);
+ dSpaceDestroy(*s);
+ return 0;
+}
+
+
+int dHashSpaceSetLevels_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ int minlevel = luaL_checkinteger(L, 2);
+ int maxlevel = luaL_checkinteger(L, 3);
+ dHashSpaceSetLevels(*space, minlevel, maxlevel);
+ return 0;
+}
+
+
+int dHashSpaceGetLevels_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ int minlevel, maxlevel;
+ dHashSpaceGetLevels(*space, &minlevel, &maxlevel);
+ lua_pushinteger(L, minlevel);
+ lua_pushinteger(L, maxlevel);
+ return 2;
+}
+
+
+int dSpaceSetCleanup_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ int mode = luaL_checkinteger(L, 2);
+ dSpaceSetCleanup(*space, mode);
+ return 0;
+}
+
+
+int dSpaceGetCleanup_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ int bind_result = dSpaceGetCleanup(*space);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int dSpaceSetSublevel_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ int sublevel = luaL_checkinteger(L, 2);
+ dSpaceSetSublevel(*space, sublevel);
+ return 0;
+}
+
+
+int dSpaceGetSublevel_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ int bind_result = dSpaceGetSublevel(*space);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int dSpaceAdd_bind(lua_State *L)
+{
+ dSpaceID *s = luaL_checkudata(L, 1, ode_space_tname);
+ dGeomID *g = luaL_checkudata(L, 2, ode_geom_tname);
+ dSpaceAdd(*s, *g);
+ return 0;
+}
+
+
+int dSpaceRemove_bind(lua_State *L)
+{
+ dSpaceID *s = luaL_checkudata(L, 1, ode_space_tname);
+ dGeomID *g = luaL_checkudata(L, 2, ode_geom_tname);
+ dSpaceRemove(*s, *g);
+ return 0;
+}
+
+
+int dSpaceQuery_bind(lua_State *L)
+{
+ dSpaceID *s = luaL_checkudata(L, 1, ode_space_tname);
+ dGeomID *g = luaL_checkudata(L, 2, ode_geom_tname);
+ int bind_result = dSpaceQuery(*s, *g);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int dSpaceGetNumGeoms_bind(lua_State *L)
+{
+ dSpaceID *s = luaL_checkudata(L, 1, ode_space_tname);
+ int bind_result = dSpaceGetNumGeoms(*s);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int dSpaceGetGeom_bind(lua_State *L)
+{
+ dSpaceID *s = luaL_checkudata(L, 1, ode_space_tname);
+ int i = luaL_checkinteger(L, 2);
+ dGeomID bind_result = dSpaceGetGeom(*s, i);
+ ode_push_geom(L, bind_result);
+ return 1;
+}
+
+
+int dCreateSphere_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dReal radius = luaL_checknumber(L, 2);
+ dGeomID bind_result = dCreateSphere(*space, radius);
+ ode_push_geom(L, bind_result);
+ return 1;
+}
+
+
+int dGeomSphereSetRadius_bind(lua_State *L)
+{
+ dGeomID *sphere = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal radius = luaL_checknumber(L, 2);
+ dGeomSphereSetRadius(*sphere, radius);
+ return 0;
+}
+
+
+int dGeomSphereGetRadius_bind(lua_State *L)
+{
+ dGeomID *sphere = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal bind_result = dGeomSphereGetRadius(*sphere);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int dGeomSpherePointDepth_bind(lua_State *L)
+{
+ dGeomID *sphere = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal x = luaL_checknumber(L, 2);
+ dReal y = luaL_checknumber(L, 3);
+ dReal z = luaL_checknumber(L, 4);
+ dReal bind_result = dGeomSpherePointDepth(*sphere, x, y, z);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int dCreateBox_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dReal lx = luaL_checknumber(L, 2);
+ dReal ly = luaL_checknumber(L, 3);
+ dReal lz = luaL_checknumber(L, 4);
+ dGeomID bind_result = dCreateBox(*space, lx, ly, lz);
+ ode_push_geom(L, bind_result);
+ return 1;
+}
+
+
+int dGeomBoxSetLengths_bind(lua_State *L)
+{
+ dGeomID *box = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal lx = luaL_checknumber(L, 2);
+ dReal ly = luaL_checknumber(L, 3);
+ dReal lz = luaL_checknumber(L, 4);
+ dGeomBoxSetLengths(*box, lx, ly, lz);
+ return 0;
+}
+
+
+int dGeomBoxGetLengths_bind(lua_State *L)
+{
+ dGeomID *box = luaL_checkudata(L, 1, ode_geom_tname);
+ dVector3 result;
+ dGeomBoxGetLengths(*box, result);
+ lua_pushnumber(L, result[0]);
+ lua_pushnumber(L, result[1]);
+ lua_pushnumber(L, result[2]);
+ return 3;
+}
+
+
+int dGeomBoxPointDepth_bind(lua_State *L)
+{
+ dGeomID *box = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal x = luaL_checknumber(L, 2);
+ dReal y = luaL_checknumber(L, 3);
+ dReal z = luaL_checknumber(L, 4);
+ dReal bind_result = dGeomBoxPointDepth(*box, x, y, z);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int dCreatePlane_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dReal a = luaL_checknumber(L, 2);
+ dReal b = luaL_checknumber(L, 3);
+ dReal c = luaL_checknumber(L, 4);
+ dReal d = luaL_checknumber(L, 5);
+ dGeomID bind_result = dCreatePlane(*space, a, b, c, d);
+ ode_push_geom(L, bind_result);
+ return 1;
+}
+
+
+int dGeomPlaneSetParams_bind(lua_State *L)
+{
+ dGeomID *plane = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal a = luaL_checknumber(L, 2);
+ dReal b = luaL_checknumber(L, 3);
+ dReal c = luaL_checknumber(L, 4);
+ dReal d = luaL_checknumber(L, 5);
+ dGeomPlaneSetParams(*plane, a, b, c, d);
+ return 0;
+}
+
+
+int dGeomPlaneGetParams_bind(lua_State *L)
+{
+ dGeomID *plane = luaL_checkudata(L, 1, ode_geom_tname);
+ dVector4 result;
+ dGeomPlaneGetParams(*plane, result);
+ lua_pushnumber(L, result[0]);
+ lua_pushnumber(L, result[1]);
+ lua_pushnumber(L, result[2]);
+ lua_pushnumber(L, result[3]);
+ return 4;
+}
+
+
+int dGeomPlanePointDepth_bind(lua_State *L)
+{
+ dGeomID *plane = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal x = luaL_checknumber(L, 2);
+ dReal y = luaL_checknumber(L, 3);
+ dReal z = luaL_checknumber(L, 4);
+ dReal bind_result = dGeomPlanePointDepth(*plane, x, y, z);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int dCreateCapsule_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dReal radius = luaL_checknumber(L, 2);
+ dReal length = luaL_checknumber(L, 3);
+ dGeomID bind_result = dCreateCapsule(*space, radius, length);
+ ode_push_geom(L, bind_result);
+ return 1;
+}
+
+
+int dGeomCapsuleSetParams_bind(lua_State *L)
+{
+ dGeomID *capsule = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal radius = luaL_checknumber(L, 2);
+ dReal length = luaL_checknumber(L, 3);
+ dGeomCapsuleSetParams(*capsule, radius, length);
+ return 0;
+}
+
+
+int dGeomCapsuleGetParams_bind(lua_State *L)
+{
+ dGeomID *capsule = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal radius, length;
+ dGeomCapsuleGetParams(*capsule, &radius, &length);
+ lua_pushnumber(L, radius);
+ lua_pushnumber(L, length);
+ return 2;
+}
+
+
+int dGeomCapsulePointDepth_bind(lua_State *L)
+{
+ dGeomID *capsule = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal x = luaL_checknumber(L, 2);
+ dReal y = luaL_checknumber(L, 3);
+ dReal z = luaL_checknumber(L, 4);
+ dReal bind_result = dGeomCapsulePointDepth(*capsule, x, y, z);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int dCreateCylinder_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dReal radius = luaL_checknumber(L, 2);
+ dReal length = luaL_checknumber(L, 3);
+ dGeomID bind_result = dCreateCylinder(*space, radius, length);
+ ode_push_geom(L, bind_result);
+ return 1;
+}
+
+
+int dGeomCylinderSetParams_bind(lua_State *L)
+{
+ dGeomID *cylinder = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal radius = luaL_checknumber(L, 2);
+ dReal length = luaL_checknumber(L, 3);
+ dGeomCylinderSetParams(*cylinder, radius, length);
+ return 0;
+}
+
+
+int dGeomCylinderGetParams_bind(lua_State *L)
+{
+ dGeomID *cylinder = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal radius, length;
+ dGeomCylinderGetParams(*cylinder, &radius, &length);
+ lua_pushnumber(L, radius);
+ lua_pushnumber(L, length);
+ return 2;
+}
+
+
+int dCreateRay_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dReal length = luaL_checknumber(L, 2);
+ dGeomID bind_result = dCreateRay(*space, length);
+ ode_push_geom(L, bind_result);
+ return 1;
+}
+
+
+int dGeomRaySetLength_bind(lua_State *L)
+{
+ dGeomID *ray = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal length = luaL_checknumber(L, 2);
+ dGeomRaySetLength(*ray, length);
+ return 0;
+}
+
+
+int dGeomRayGetLength_bind(lua_State *L)
+{
+ dGeomID *ray = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal bind_result = dGeomRayGetLength(*ray);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int dGeomRaySet_bind(lua_State *L)
+{
+ dGeomID *ray = luaL_checkudata(L, 1, ode_geom_tname);
+ dReal px = luaL_checknumber(L, 2);
+ dReal py = luaL_checknumber(L, 3);
+ dReal pz = luaL_checknumber(L, 4);
+ dReal dx = luaL_checknumber(L, 5);
+ dReal dy = luaL_checknumber(L, 6);
+ dReal dz = luaL_checknumber(L, 7);
+ dGeomRaySet(*ray, px, py, pz, dx, dy, dz);
+ return 0;
+}
+
+
+int dGeomRayGet_bind(lua_State *L)
+{
+ dGeomID *ray = luaL_checkudata(L, 1, ode_geom_tname);
+ dVector3 start;
+ dVector3 dir;
+ dGeomRayGet(*ray, start, dir);
+ lua_pushnumber(L, start[0]);
+ lua_pushnumber(L, start[1]);
+ lua_pushnumber(L, start[2]);
+ lua_pushnumber(L, dir[0]);
+ lua_pushnumber(L, dir[1]);
+ lua_pushnumber(L, dir[2]);
+ return 6;
+}
+
+
+int dGeomRaySetParams_bind(lua_State *L)
+{
+ dGeomID *ray = luaL_checkudata(L, 1, ode_geom_tname);
+ int FirstContact = luaL_checkinteger(L, 2);
+ int BackfaceCull = luaL_checkinteger(L, 3);
+ dGeomRaySetParams(*ray, FirstContact, BackfaceCull);
+ return 0;
+}
+
+
+int dGeomRayGetParams_bind(lua_State *L)
+{
+ dGeomID *ray = luaL_checkudata(L, 1, ode_geom_tname);
+ int FirstContact, BackfaceCull;
+ dGeomRayGetParams(*ray, &FirstContact, &BackfaceCull);
+ lua_pushnumber(L, FirstContact);
+ lua_pushnumber(L, BackfaceCull);
+ return 2;
+}
+
+
+int dGeomRaySetClosestHit_bind(lua_State *L)
+{
+ dGeomID *ray = luaL_checkudata(L, 1, ode_geom_tname);
+ int ClosestHit = luaL_checkinteger(L, 2);
+ dGeomRaySetClosestHit(*ray, ClosestHit);
+ return 0;
+}
+
+
+int dGeomRayGetClosestHit_bind(lua_State *L)
+{
+ dGeomID *ray = luaL_checkudata(L, 1, ode_geom_tname);
+ int bind_result = dGeomRayGetClosestHit(*ray);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+/*int dGeomTriMeshDataCreate_bind(lua_State *L)
+{
+ dTriMeshDataID bind_result = dGeomTriMeshDataCreate();
+ /* push result /
+ return /* count /;
+}
+
+
+int dGeomTriMeshDataDestroy_bind(lua_State *L)
+{
+ dTriMeshDataID g = get: dTriMeshDataID
+ dGeomTriMeshDataDestroy(*g);
+ return 0;
+}
+
+
+int dGeomTriMeshDataBuild_bind(lua_State *L)
+{
+ dTriMeshDataID g = get: dTriMeshDataID
+ const void * Vertices = get: const void *
+ int VertexStride = luaL_checkinteger(L, 3);
+ int VertexCount = luaL_checkinteger(L, 4);
+ const void * Indices = get: const void *
+ int IndexCount = luaL_checkinteger(L, 6);
+ int TriStride = luaL_checkinteger(L, 7);
+ const void * Normals = get: const void *
+ dGeomTriMeshDataBuild(*g, Vertices, VertexStride, VertexCount, Indices, IndexCount, TriStride, Normals);
+ return 0;
+}
+
+
+int dGeomTriMeshDataBuildSimple_bind(lua_State *L)
+{
+ dTriMeshDataID g = get: dTriMeshDataID
+ const dVector3 * Vertices = get: const dVector3 *
+ int VertexCount = luaL_checkinteger(L, 3);
+ const int * Indices = get: const int *
+ int IndexCount = luaL_checkinteger(L, 5);
+ dGeomTriMeshDataBuildSimple(*g, Vertices, VertexCount, Indices, IndexCount);
+ return 0;
+}
+
+
+int dCreateTriMesh_bind(lua_State *L)
+{
+ dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+ dTriMeshDataID Data = get: dTriMeshDataID
+ dTriCallback * Callback = get: dTriCallback *
+ dTriArrayCallback * ArrayCallback = get: dTriArrayCallback *
+ dTriRayCallback * RayCallback = get: dTriRayCallback *
+ dGeomID *bind_result = dCreateTriMesh(*space, Data, Callback, ArrayCallback, RayCallback);
+ /* push result /
+ return /* count /;
+}
+
+
+int dGeomTriMeshSetData_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dTriMeshDataID Data = get: dTriMeshDataID
+ dGeomTriMeshSetData(*g, Data);
+ return 0;
+}
+
+
+int dGeomTriMeshClearTCCache_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ dGeomTriMeshClearTCCache(*g);
+ return 0;
+}
+
+
+int dGeomTriMeshGetTriangle_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ int Index = luaL_checkinteger(L, 2);
+ dVector3 * v0 = get: dVector3 *
+ dVector3 * v1 = get: dVector3 *
+ dVector3 * v2 = get: dVector3 *
+ dGeomTriMeshGetTriangle(*g, Index, v0, v1, v2);
+ return 0;
+}
+
+
+int dGeomTriMeshGetPoint_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ int Index = luaL_checkinteger(L, 2);
+ dReal u = luaL_checknumber(L, 3);
+ dReal v = luaL_checknumber(L, 4);
+ dVector3 Out = get: dVector3
+ dGeomTriMeshGetPoint(*g, Index, u, v, Out);
+ return 0;
+}
+
+
+int dGeomTriMeshEnableTC_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ int geomClass = luaL_checkinteger(L, 2);
+ int enable = luaL_checkinteger(L, 3);
+ dGeomTriMeshEnableTC(*g, geomClass, enable);
+ return 0;
+}
+
+
+int dGeomTriMeshIsTCEnabled_bind(lua_State *L)
+{
+ dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+ int geomClass = luaL_checkinteger(L, 2);
+ int bind_result = dGeomTriMeshIsTCEnabled(*g, geomClass);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}*/
+
+
+//int dGeomHeightfieldDataCreate_bind(lua_State *L)
+//{
+// dHeightfieldDataID bind_result = dGeomHeightfieldDataCreate();
+// /* push result */
+// return /* count */;
+//}
+//
+//
+//int dGeomHeightfieldDataDestroy_bind(lua_State *L)
+//{
+// dHeightfieldDataID d = get: dHeightfieldDataID
+// dGeomHeightfieldDataDestroy(d);
+// return 0;
+//}
+//
+//
+//int dGeomHeightfieldDataBuildDouble_bind(lua_State *L)
+//{
+// dHeightfieldDataID d = get: dHeightfieldDataID
+// const double * pHeightData = get: const double *
+// int bCopyHeightData = luaL_checkinteger(L, 3);
+// dReal width = luaL_checknumber(L, 4);
+// dReal depth = luaL_checknumber(L, 5);
+// int widthSamples = luaL_checkinteger(L, 6);
+// int depthSamples = luaL_checkinteger(L, 7);
+// dReal scale = luaL_checknumber(L, 8);
+// dReal offset = luaL_checknumber(L, 9);
+// dReal thickness = luaL_checknumber(L, 10);
+// int bWrap = luaL_checkinteger(L, 11);
+// dGeomHeightfieldDataBuildDouble(d, pHeightData, bCopyHeightData, width, depth, widthSamples, depthSamples, scale, offset, thickness, bWrap);
+// return 0;
+//}
+//
+//
+//int dGeomHeightfieldDataBuildCallback_bind(lua_State *L)
+//{
+// dHeightfieldDataID d = get: dHeightfieldDataID
+// void * pUserData = get: void *
+// dHeightfieldGetHeight * pCallback = get: dHeightfieldGetHeight *
+// dReal width = luaL_checknumber(L, 4);
+// dReal depth = luaL_checknumber(L, 5);
+// int widthSamples = luaL_checkinteger(L, 6);
+// int depthSamples = luaL_checkinteger(L, 7);
+// dReal scale = luaL_checknumber(L, 8);
+// dReal offset = luaL_checknumber(L, 9);
+// dReal thickness = luaL_checknumber(L, 10);
+// int bWrap = luaL_checkinteger(L, 11);
+// dGeomHeightfieldDataBuildCallback(d, pUserData, pCallback, width, depth, widthSamples, depthSamples, scale, offset, thickness, bWrap);
+// return 0;
+//}
+//
+//
+//int dGeomHeightfieldDataSetBounds_bind(lua_State *L)
+//{
+// dHeightfieldDataID d = get: dHeightfieldDataID
+// dReal min_height = luaL_checknumber(L, 2);
+// dReal max_height = luaL_checknumber(L, 3);
+// dGeomHeightfieldDataSetBounds(d, min_height, max_height);
+// return 0;
+//}
+//
+//
+//int dCreateHeightfield_bind(lua_State *L)
+//{
+// dSpaceID *space = luaL_checkudata(L, 1, ode_space_tname);
+// dHeightfieldDataID data = get: dHeightfieldDataID
+// int bPlaceable = luaL_checkinteger(L, 3);
+// dGeomID *bind_result = dCreateHeightfield(*space, data, bPlaceable);
+// /* push result */
+// return /* count */;
+//}
+//
+//
+//int dGeomHeightfieldSetHeightfieldData_bind(lua_State *L)
+//{
+// dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+// dHeightfieldDataID Data = get: dHeightfieldDataID
+// dGeomHeightfieldSetHeightfieldData(*g, Data);
+// return 0;
+//}
+//
+//
+//int dGeomHeightfieldGetHeightfieldData_bind(lua_State *L)
+//{
+// dGeomID *g = luaL_checkudata(L, 1, ode_geom_tname);
+// dHeightfieldDataID bind_result = dGeomHeightfieldGetHeightfieldData(*g);
+// /* push result */
+// return /* count */;
+//}
+
+