int MeshBinder::setTextureCoordinates(lua_State *L) { Binder binder(L); GMesh *mesh = static_cast<GMesh*>(binder.getInstance("Mesh", 1)); if (lua_type(L, 2) == LUA_TTABLE) { int n = lua_objlen(L, 2); for (int k = 0; k < n/3; ++k) { lua_rawgeti(L, 2, k * 3 + 1); int i = luaL_checkinteger(L, -1) - 1; lua_pop(L, 1); lua_rawgeti(L, 2, k * 3 + 2); float u = luaL_checknumber(L, -1); lua_pop(L, 1); lua_rawgeti(L, 2, k * 3 + 3); float v = luaL_checknumber(L, -1); lua_pop(L, 1); mesh->setTextureCoordinate(i, u, v); } } else { int n = lua_gettop(L) - 1; for (int k = 0; k < n/3; ++k) { int i = luaL_checkinteger(L, k * 3 + 2) - 1; float u = luaL_checknumber(L, k * 3 + 3); float v = luaL_checknumber(L, k * 3 + 4); mesh->setTextureCoordinate(i, u, v); } } return 0; }
int MeshBinder::setTextureCoordinate(lua_State *L) { Binder binder(L); GMesh *mesh = static_cast<GMesh*>(binder.getInstance("Mesh", 1)); int i = luaL_checkinteger(L, 2) - 1; float u = luaL_checknumber(L, 3); float v = luaL_checknumber(L, 4); mesh->setTextureCoordinate(i, u, v); return 0; }