#include "Base.h" #include "ScriptController.h" #include "lua_Vector3.h" #include "Base.h" #include "MathUtil.h" #include "Vector3.h" namespace gameplay { void luaRegister_Vector3() { const luaL_Reg lua_members[] = { {"add", lua_Vector3_add}, {"clamp", lua_Vector3_clamp}, {"cross", lua_Vector3_cross}, {"distance", lua_Vector3_distance}, {"distanceSquared", lua_Vector3_distanceSquared}, {"dot", lua_Vector3_dot}, {"isOne", lua_Vector3_isOne}, {"isZero", lua_Vector3_isZero}, {"length", lua_Vector3_length}, {"lengthSquared", lua_Vector3_lengthSquared}, {"negate", lua_Vector3_negate}, {"normalize", lua_Vector3_normalize}, {"scale", lua_Vector3_scale}, {"set", lua_Vector3_set}, {"smooth", lua_Vector3_smooth}, {"subtract", lua_Vector3_subtract}, {"x", lua_Vector3_x}, {"y", lua_Vector3_y}, {"z", lua_Vector3_z}, {NULL, NULL} }; const luaL_Reg lua_statics[] = { {"add", lua_Vector3_static_add}, {"angle", lua_Vector3_static_angle}, {"clamp", lua_Vector3_static_clamp}, {"cross", lua_Vector3_static_cross}, {"dot", lua_Vector3_static_dot}, {"fromColor", lua_Vector3_static_fromColor}, {"one", lua_Vector3_static_one}, {"subtract", lua_Vector3_static_subtract}, {"unitX", lua_Vector3_static_unitX}, {"unitY", lua_Vector3_static_unitY}, {"unitZ", lua_Vector3_static_unitZ}, {"zero", lua_Vector3_static_zero}, {NULL, NULL} }; std::vector scopePath; ScriptUtil::registerClass("Vector3", lua_members, lua_Vector3__init, lua_Vector3__gc, lua_statics, scopePath); } static Vector3* getInstance(lua_State* state) { void* userdata = luaL_checkudata(state, 1, "Vector3"); luaL_argcheck(state, userdata != NULL, 1, "'Vector3' expected."); return (Vector3*)((ScriptUtil::LuaObject*)userdata)->instance; } int lua_Vector3__gc(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { void* userdata = luaL_checkudata(state, 1, "Vector3"); luaL_argcheck(state, userdata != NULL, 1, "'Vector3' expected."); ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata; if (object->owns) { Vector3* instance = (Vector3*)object->instance; SAFE_DELETE(instance); } return 0; } else { lua_pushstring(state, "lua_Vector3__gc - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector3__init(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)new Vector3(); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } case 1: { if ((lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TLIGHTUSERDATA)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getFloatPointer(1); void* returnPtr = (void*)new Vector3(param1); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); void* returnPtr = (void*)new Vector3(*param1); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Vector3__init - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); void* returnPtr = (void*)new Vector3(*param1, *param2); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Vector3__init - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 3: { if (lua_type(state, 1) == LUA_TNUMBER && lua_type(state, 2) == LUA_TNUMBER && lua_type(state, 3) == LUA_TNUMBER) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 1); // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 2); // Get parameter 3 off the stack. float param3 = (float)luaL_checknumber(state, 3); void* returnPtr = (void*)new Vector3(param1, param2, param3); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Vector3__init - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0, 1, 2 or 3)."); lua_error(state); break; } } return 0; } int lua_Vector3_add(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); Vector3* instance = getInstance(state); instance->add(*param1); return 0; } else { lua_pushstring(state, "lua_Vector3_add - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_clamp(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 3: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector3", true); Vector3* instance = getInstance(state); instance->clamp(*param1, *param2); return 0; } else { lua_pushstring(state, "lua_Vector3_clamp - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 3)."); lua_error(state); break; } } return 0; } int lua_Vector3_cross(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); Vector3* instance = getInstance(state); instance->cross(*param1); return 0; } else { lua_pushstring(state, "lua_Vector3_cross - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_distance(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); Vector3* instance = getInstance(state); float result = instance->distance(*param1); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } else { lua_pushstring(state, "lua_Vector3_distance - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_distanceSquared(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); Vector3* instance = getInstance(state); float result = instance->distanceSquared(*param1); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } else { lua_pushstring(state, "lua_Vector3_distanceSquared - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_dot(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); Vector3* instance = getInstance(state); float result = instance->dot(*param1); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } else { lua_pushstring(state, "lua_Vector3_dot - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_isOne(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector3* instance = getInstance(state); bool result = instance->isOne(); // Push the return value onto the stack. lua_pushboolean(state, result); return 1; } else { lua_pushstring(state, "lua_Vector3_isOne - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector3_isZero(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector3* instance = getInstance(state); bool result = instance->isZero(); // Push the return value onto the stack. lua_pushboolean(state, result); return 1; } else { lua_pushstring(state, "lua_Vector3_isZero - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector3_length(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector3* instance = getInstance(state); float result = instance->length(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } else { lua_pushstring(state, "lua_Vector3_length - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector3_lengthSquared(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector3* instance = getInstance(state); float result = instance->lengthSquared(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } else { lua_pushstring(state, "lua_Vector3_lengthSquared - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector3_negate(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector3* instance = getInstance(state); instance->negate(); return 0; } else { lua_pushstring(state, "lua_Vector3_negate - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector3_normalize(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector3* instance = getInstance(state); void* returnPtr = (void*)&(instance->normalize()); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Vector3_normalize - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", false); Vector3* instance = getInstance(state); instance->normalize(param1); return 0; } else { lua_pushstring(state, "lua_Vector3_normalize - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1 or 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_scale(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && lua_type(state, 2) == LUA_TNUMBER) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 2); Vector3* instance = getInstance(state); instance->scale(param1); return 0; } else { lua_pushstring(state, "lua_Vector3_scale - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_set(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getFloatPointer(2); Vector3* instance = getInstance(state); instance->set(param1); return 0; } else if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); Vector3* instance = getInstance(state); instance->set(*param1); return 0; } else { lua_pushstring(state, "lua_Vector3_set - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 3: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector3", true); Vector3* instance = getInstance(state); instance->set(*param1, *param2); return 0; } else { lua_pushstring(state, "lua_Vector3_set - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 4: { if ((lua_type(state, 1) == LUA_TUSERDATA) && lua_type(state, 2) == LUA_TNUMBER && lua_type(state, 3) == LUA_TNUMBER && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 2); // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 3); // Get parameter 3 off the stack. float param3 = (float)luaL_checknumber(state, 4); Vector3* instance = getInstance(state); instance->set(param1, param2, param3); return 0; } else { lua_pushstring(state, "lua_Vector3_set - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2, 3 or 4)."); lua_error(state); break; } } return 0; } int lua_Vector3_smooth(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 4: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && lua_type(state, 3) == LUA_TNUMBER && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 3); // Get parameter 3 off the stack. float param3 = (float)luaL_checknumber(state, 4); Vector3* instance = getInstance(state); instance->smooth(*param1, param2, param3); return 0; } else { lua_pushstring(state, "lua_Vector3_smooth - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 4)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_add(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 3: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); // Get parameter 3 off the stack. ScriptUtil::LuaArray param3 = ScriptUtil::getObjectPointer(3, "Vector3", false); Vector3::add(*param1, *param2, param3); return 0; } else { lua_pushstring(state, "lua_Vector3_static_add - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 3)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_angle(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); float result = Vector3::angle(*param1, *param2); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } else { lua_pushstring(state, "lua_Vector3_static_angle - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_clamp(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 4: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) && (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); // Get parameter 3 off the stack. ScriptUtil::LuaArray param3 = ScriptUtil::getObjectPointer(3, "Vector3", true); // Get parameter 4 off the stack. ScriptUtil::LuaArray param4 = ScriptUtil::getObjectPointer(4, "Vector3", false); Vector3::clamp(*param1, *param2, *param3, param4); return 0; } else { lua_pushstring(state, "lua_Vector3_static_clamp - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 4)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_cross(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 3: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); // Get parameter 3 off the stack. ScriptUtil::LuaArray param3 = ScriptUtil::getObjectPointer(3, "Vector3", false); Vector3::cross(*param1, *param2, param3); return 0; } else { lua_pushstring(state, "lua_Vector3_static_cross - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 3)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_dot(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); float result = Vector3::dot(*param1, *param2); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } else { lua_pushstring(state, "lua_Vector3_static_dot - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_fromColor(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if (lua_type(state, 1) == LUA_TNUMBER) { // Get parameter 1 off the stack. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 1); void* returnPtr = (void*)new Vector3(Vector3::fromColor(param1)); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Vector3_static_fromColor - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_one(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)&(Vector3::one()); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_subtract(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 3: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); // Get parameter 3 off the stack. ScriptUtil::LuaArray param3 = ScriptUtil::getObjectPointer(3, "Vector3", false); Vector3::subtract(*param1, *param2, param3); return 0; } else { lua_pushstring(state, "lua_Vector3_static_subtract - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 3)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_unitX(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)&(Vector3::unitX()); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_unitY(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)&(Vector3::unitY()); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_unitZ(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)&(Vector3::unitZ()); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0)."); lua_error(state); break; } } return 0; } int lua_Vector3_static_zero(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)&(Vector3::zero()); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0)."); lua_error(state); break; } } return 0; } int lua_Vector3_subtract(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Vector3", true); Vector3* instance = getInstance(state); instance->subtract(*param1); return 0; } else { lua_pushstring(state, "lua_Vector3_subtract - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector3_x(lua_State* state) { // Validate the number of parameters. if (lua_gettop(state) > 2) { lua_pushstring(state, "Invalid number of parameters (expected 1 or 2)."); lua_error(state); } Vector3* instance = getInstance(state); if (lua_gettop(state) == 2) { // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 2); instance->x = param2; return 0; } else { float result = instance->x; // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } } int lua_Vector3_y(lua_State* state) { // Validate the number of parameters. if (lua_gettop(state) > 2) { lua_pushstring(state, "Invalid number of parameters (expected 1 or 2)."); lua_error(state); } Vector3* instance = getInstance(state); if (lua_gettop(state) == 2) { // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 2); instance->y = param2; return 0; } else { float result = instance->y; // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } } int lua_Vector3_z(lua_State* state) { // Validate the number of parameters. if (lua_gettop(state) > 2) { lua_pushstring(state, "Invalid number of parameters (expected 1 or 2)."); lua_error(state); } Vector3* instance = getInstance(state); if (lua_gettop(state) == 2) { // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 2); instance->z = param2; return 0; } else { float result = instance->z; // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } } }