#include "Base.h" #include "ScriptController.h" #include "lua_Light.h" #include "Base.h" #include "Game.h" #include "Light.h" #include "Node.h" #include "Ref.h" #include "lua_LightType.h" namespace gameplay { void luaRegister_Light() { const luaL_Reg lua_members[] = { {"addRef", lua_Light_addRef}, {"getColor", lua_Light_getColor}, {"getInnerAngle", lua_Light_getInnerAngle}, {"getInnerAngleCos", lua_Light_getInnerAngleCos}, {"getLightType", lua_Light_getLightType}, {"getNode", lua_Light_getNode}, {"getOuterAngle", lua_Light_getOuterAngle}, {"getOuterAngleCos", lua_Light_getOuterAngleCos}, {"getRange", lua_Light_getRange}, {"getRangeInverse", lua_Light_getRangeInverse}, {"getRefCount", lua_Light_getRefCount}, {"release", lua_Light_release}, {"setColor", lua_Light_setColor}, {"setInnerAngle", lua_Light_setInnerAngle}, {"setOuterAngle", lua_Light_setOuterAngle}, {"setRange", lua_Light_setRange}, {NULL, NULL} }; const luaL_Reg lua_statics[] = { {"createDirectional", lua_Light_static_createDirectional}, {"createPoint", lua_Light_static_createPoint}, {"createSpot", lua_Light_static_createSpot}, {NULL, NULL} }; std::vector scopePath; gameplay::ScriptUtil::registerClass("Light", lua_members, NULL, lua_Light__gc, lua_statics, scopePath); } static Light* getInstance(lua_State* state) { void* userdata = luaL_checkudata(state, 1, "Light"); luaL_argcheck(state, userdata != NULL, 1, "'Light' expected."); return (Light*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance; } int lua_Light__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, "Light"); luaL_argcheck(state, userdata != NULL, 1, "'Light' expected."); gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata; if (object->owns) { Light* instance = (Light*)object->instance; SAFE_RELEASE(instance); } return 0; } lua_pushstring(state, "lua_Light__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_Light_addRef(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)) { Light* instance = getInstance(state); instance->addRef(); return 0; } lua_pushstring(state, "lua_Light_addRef - 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_Light_getColor(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)) { Light* instance = getInstance(state); void* returnPtr = (void*)&(instance->getColor()); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector3"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } lua_pushstring(state, "lua_Light_getColor - 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_Light_getInnerAngle(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)) { Light* instance = getInstance(state); float result = instance->getInnerAngle(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Light_getInnerAngle - 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_Light_getInnerAngleCos(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)) { Light* instance = getInstance(state); float result = instance->getInnerAngleCos(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Light_getInnerAngleCos - 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_Light_getLightType(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)) { Light* instance = getInstance(state); Light::Type result = instance->getLightType(); // Push the return value onto the stack. lua_pushstring(state, lua_stringFromEnum_LightType(result)); return 1; } lua_pushstring(state, "lua_Light_getLightType - 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_Light_getNode(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)) { Light* instance = getInstance(state); void* returnPtr = (void*)instance->getNode(); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Node"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } lua_pushstring(state, "lua_Light_getNode - 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_Light_getOuterAngle(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)) { Light* instance = getInstance(state); float result = instance->getOuterAngle(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Light_getOuterAngle - 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_Light_getOuterAngleCos(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)) { Light* instance = getInstance(state); float result = instance->getOuterAngleCos(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Light_getOuterAngleCos - 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_Light_getRange(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)) { Light* instance = getInstance(state); float result = instance->getRange(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Light_getRange - 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_Light_getRangeInverse(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)) { Light* instance = getInstance(state); float result = instance->getRangeInverse(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Light_getRangeInverse - 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_Light_getRefCount(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)) { Light* instance = getInstance(state); unsigned int result = instance->getRefCount(); // Push the return value onto the stack. lua_pushunsigned(state, result); return 1; } lua_pushstring(state, "lua_Light_getRefCount - 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_Light_release(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)) { Light* instance = getInstance(state); instance->release(); return 0; } lua_pushstring(state, "lua_Light_release - 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_Light_setColor(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: { do { 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. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector3", true, ¶m1Valid); if (!param1Valid) break; Light* instance = getInstance(state); instance->setColor(*param1); return 0; } } while (0); lua_pushstring(state, "lua_Light_setColor - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 4: { do { 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); Light* instance = getInstance(state); instance->setColor(param1, param2, param3); return 0; } } while (0); lua_pushstring(state, "lua_Light_setColor - 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 or 4)."); lua_error(state); break; } } return 0; } int lua_Light_setInnerAngle(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); Light* instance = getInstance(state); instance->setInnerAngle(param1); return 0; } lua_pushstring(state, "lua_Light_setInnerAngle - 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_Light_setOuterAngle(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); Light* instance = getInstance(state); instance->setOuterAngle(param1); return 0; } lua_pushstring(state, "lua_Light_setOuterAngle - 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_Light_setRange(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); Light* instance = getInstance(state); instance->setRange(param1); return 0; } lua_pushstring(state, "lua_Light_setRange - 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_Light_static_createDirectional(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: { do { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector3", true, ¶m1Valid); if (!param1Valid) break; void* returnPtr = (void*)Light::createDirectional(*param1); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Light"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_Light_static_createDirectional - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 3: { do { 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*)Light::createDirectional(param1, param2, param3); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Light"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_Light_static_createDirectional - 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 3)."); lua_error(state); break; } } return 0; } int lua_Light_static_createPoint(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: { do { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && lua_type(state, 2) == LUA_TNUMBER) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector3", true, ¶m1Valid); if (!param1Valid) break; // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 2); void* returnPtr = (void*)Light::createPoint(*param1, param2); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Light"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_Light_static_createPoint - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 4: { do { if (lua_type(state, 1) == LUA_TNUMBER && 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, 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); // Get parameter 4 off the stack. float param4 = (float)luaL_checknumber(state, 4); void* returnPtr = (void*)Light::createPoint(param1, param2, param3, param4); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Light"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_Light_static_createPoint - 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 or 4)."); lua_error(state); break; } } return 0; } int lua_Light_static_createSpot(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: { do { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && lua_type(state, 2) == LUA_TNUMBER && lua_type(state, 3) == LUA_TNUMBER && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector3", true, ¶m1Valid); if (!param1Valid) break; // 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); // Get parameter 4 off the stack. float param4 = (float)luaL_checknumber(state, 4); void* returnPtr = (void*)Light::createSpot(*param1, param2, param3, param4); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Light"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_Light_static_createSpot - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 6: { do { if (lua_type(state, 1) == LUA_TNUMBER && lua_type(state, 2) == LUA_TNUMBER && lua_type(state, 3) == LUA_TNUMBER && lua_type(state, 4) == LUA_TNUMBER && lua_type(state, 5) == LUA_TNUMBER && lua_type(state, 6) == 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); // Get parameter 4 off the stack. float param4 = (float)luaL_checknumber(state, 4); // Get parameter 5 off the stack. float param5 = (float)luaL_checknumber(state, 5); // Get parameter 6 off the stack. float param6 = (float)luaL_checknumber(state, 6); void* returnPtr = (void*)Light::createSpot(param1, param2, param3, param4, param5, param6); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Light"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_Light_static_createSpot - 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 or 6)."); lua_error(state); break; } } return 0; } }