int MeshBinder::getVertexArraySize(lua_State *L) { Binder binder(L); GMesh *mesh = static_cast<GMesh*>(binder.getInstance("Mesh", 1)); lua_pushinteger(L, mesh->getVertexArraySize()); return 1; }
int MeshBinder::getIndex(lua_State *L) { Binder binder(L); GMesh *mesh = static_cast<GMesh*>(binder.getInstance("Mesh", 1)); int i = luaL_checkinteger(L, 2) - 1; if (i < 0 || i >= mesh->getVertexArraySize()) return luaL_error(L, "The supplied index is out of bounds."); unsigned short index; mesh->getIndex(i, &index); lua_pushinteger(L, (int)index + 1); return 1; }
int MeshBinder::getTextureCoordinate(lua_State *L) { Binder binder(L); GMesh *mesh = static_cast<GMesh*>(binder.getInstance("Mesh", 1)); int i = luaL_checkinteger(L, 2) - 1; if (i < 0 || i >= mesh->getVertexArraySize()) return luaL_error(L, "The supplied index is out of bounds."); float u, v; mesh->getTextureCoordinate(i, &u, &v); lua_pushnumber(L, u); lua_pushnumber(L, v); return 2; }
int MeshBinder::getColor(lua_State *L) { Binder binder(L); GMesh *mesh = static_cast<GMesh*>(binder.getInstance("Mesh", 1)); int i = luaL_checkinteger(L, 2) - 1; if (i < 0 || i >= mesh->getVertexArraySize()) return luaL_error(L, "The supplied index is out of bounds."); unsigned int color; float alpha; mesh->getColor(i, &color, &alpha); lua_pushinteger(L, color); lua_pushnumber(L, alpha); return 2; }
int MeshBinder::getVertex(lua_State *L) { Binder binder(L); GMesh *mesh = static_cast<GMesh*>(binder.getInstance("Mesh", 1)); int i = luaL_checkinteger(L, 2) - 1; if (i < 0 || i >= mesh->getVertexArraySize()) return luaL_error(L, "The supplied index is out of bounds."); int order=mesh->is3d()?3:2; float x, y, z; mesh->getVertex(i, &x, &y, &z); lua_pushnumber(L, x); lua_pushnumber(L, y); if (order==3) lua_pushnumber(L, z); return order; }