#include "Base.h" #include "ScriptController.h" #include "lua_Scene.h" #include "AudioListener.h" #include "Base.h" #include "Game.h" #include "Joint.h" #include "MeshSkin.h" #include "Ref.h" #include "Scene.h" #include "SceneLoader.h" namespace gameplay { void luaRegister_Scene() { const luaL_Reg lua_members[] = { {"addNode", lua_Scene_addNode}, {"addRef", lua_Scene_addRef}, {"bindAudioListenerToCamera", lua_Scene_bindAudioListenerToCamera}, {"drawDebug", lua_Scene_drawDebug}, {"findNode", lua_Scene_findNode}, {"getActiveCamera", lua_Scene_getActiveCamera}, {"getAmbientColor", lua_Scene_getAmbientColor}, {"getFirstNode", lua_Scene_getFirstNode}, {"getId", lua_Scene_getId}, {"getNodeCount", lua_Scene_getNodeCount}, {"getRefCount", lua_Scene_getRefCount}, {"release", lua_Scene_release}, {"removeAllNodes", lua_Scene_removeAllNodes}, {"removeNode", lua_Scene_removeNode}, {"setActiveCamera", lua_Scene_setActiveCamera}, {"setAmbientColor", lua_Scene_setAmbientColor}, {"setId", lua_Scene_setId}, {"visit", lua_Scene_visit}, {NULL, NULL} }; const luaL_Reg lua_statics[] = { {"createScene", lua_Scene_static_createScene}, {"load", lua_Scene_static_load}, {NULL, NULL} }; std::vector scopePath; ScriptUtil::registerClass("Scene", lua_members, NULL, lua_Scene__gc, lua_statics, scopePath); } static Scene* getInstance(lua_State* state) { void* userdata = luaL_checkudata(state, 1, "Scene"); luaL_argcheck(state, userdata != NULL, 1, "'Scene' expected."); return (Scene*)((ScriptUtil::LuaObject*)userdata)->instance; } int lua_Scene__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, "Scene"); luaL_argcheck(state, userdata != NULL, 1, "'Scene' expected."); ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata; if (object->owns) { Scene* instance = (Scene*)object->instance; SAFE_RELEASE(instance); } return 0; } else { lua_pushstring(state, "lua_Scene__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_Scene_addNode(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)) { Scene* instance = getInstance(state); void* returnPtr = (void*)instance->addNode(); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Node"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Scene_addNode - 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_TSTRING || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. const char* param1 = ScriptUtil::getString(2, false); Scene* instance = getInstance(state); void* returnPtr = (void*)instance->addNode(param1); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Node"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else 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. Node* param1 = ScriptUtil::getObjectPointer(2, "Node", false); Scene* instance = getInstance(state); instance->addNode(param1); return 0; } else { lua_pushstring(state, "lua_Scene_addNode - 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_Scene_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)) { Scene* instance = getInstance(state); instance->addRef(); return 0; } else { lua_pushstring(state, "lua_Scene_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_Scene_bindAudioListenerToCamera(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_TBOOLEAN) { // Get parameter 1 off the stack. bool param1 = ScriptUtil::luaCheckBool(state, 2); Scene* instance = getInstance(state); instance->bindAudioListenerToCamera(param1); return 0; } else { lua_pushstring(state, "lua_Scene_bindAudioListenerToCamera - 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_Scene_drawDebug(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. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2); Scene* instance = getInstance(state); instance->drawDebug(param1); return 0; } else { lua_pushstring(state, "lua_Scene_drawDebug - 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_Scene_findNode(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_TSTRING || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. const char* param1 = ScriptUtil::getString(2, false); Scene* instance = getInstance(state); void* returnPtr = (void*)instance->findNode(param1); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Node"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Scene_findNode - 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_TSTRING || lua_type(state, 2) == LUA_TNIL) && lua_type(state, 3) == LUA_TBOOLEAN) { // Get parameter 1 off the stack. const char* param1 = ScriptUtil::getString(2, false); // Get parameter 2 off the stack. bool param2 = ScriptUtil::luaCheckBool(state, 3); Scene* instance = getInstance(state); void* returnPtr = (void*)instance->findNode(param1, param2); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Node"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Scene_findNode - 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_TSTRING || lua_type(state, 2) == LUA_TNIL) && lua_type(state, 3) == LUA_TBOOLEAN && lua_type(state, 4) == LUA_TBOOLEAN) { // Get parameter 1 off the stack. const char* param1 = ScriptUtil::getString(2, false); // Get parameter 2 off the stack. bool param2 = ScriptUtil::luaCheckBool(state, 3); // Get parameter 3 off the stack. bool param3 = ScriptUtil::luaCheckBool(state, 4); Scene* instance = getInstance(state); void* returnPtr = (void*)instance->findNode(param1, param2, param3); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Node"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Scene_findNode - 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_Scene_getActiveCamera(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)) { Scene* instance = getInstance(state); void* returnPtr = (void*)instance->getActiveCamera(); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Camera"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Scene_getActiveCamera - 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_Scene_getAmbientColor(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)) { Scene* instance = getInstance(state); void* returnPtr = (void*)&(instance->getAmbientColor()); 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_Scene_getAmbientColor - 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_Scene_getFirstNode(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)) { Scene* instance = getInstance(state); void* returnPtr = (void*)instance->getFirstNode(); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Node"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Scene_getFirstNode - 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_Scene_getId(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)) { Scene* instance = getInstance(state); const char* result = instance->getId(); // Push the return value onto the stack. lua_pushstring(state, result); return 1; } else { lua_pushstring(state, "lua_Scene_getId - 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_Scene_getNodeCount(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)) { Scene* instance = getInstance(state); unsigned int result = instance->getNodeCount(); // Push the return value onto the stack. lua_pushunsigned(state, result); return 1; } else { lua_pushstring(state, "lua_Scene_getNodeCount - 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_Scene_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)) { Scene* instance = getInstance(state); unsigned int result = instance->getRefCount(); // Push the return value onto the stack. lua_pushunsigned(state, result); return 1; } else { lua_pushstring(state, "lua_Scene_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_Scene_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)) { Scene* instance = getInstance(state); instance->release(); return 0; } else { lua_pushstring(state, "lua_Scene_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_Scene_removeAllNodes(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)) { Scene* instance = getInstance(state); instance->removeAllNodes(); return 0; } else { lua_pushstring(state, "lua_Scene_removeAllNodes - 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_Scene_removeNode(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_TTABLE || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. Node* param1 = ScriptUtil::getObjectPointer(2, "Node", false); Scene* instance = getInstance(state); instance->removeNode(param1); return 0; } else { lua_pushstring(state, "lua_Scene_removeNode - 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_Scene_setActiveCamera(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_TTABLE || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. Camera* param1 = ScriptUtil::getObjectPointer(2, "Camera", false); Scene* instance = getInstance(state); instance->setActiveCamera(param1); return 0; } else { lua_pushstring(state, "lua_Scene_setActiveCamera - 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_Scene_setAmbientColor(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_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); Scene* instance = getInstance(state); instance->setAmbientColor(param1, param2, param3); return 0; } else { lua_pushstring(state, "lua_Scene_setAmbientColor - 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_Scene_setId(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_TSTRING || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. const char* param1 = ScriptUtil::getString(2, false); Scene* instance = getInstance(state); instance->setId(param1); return 0; } else { lua_pushstring(state, "lua_Scene_setId - 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_Scene_static_createScene(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*)Scene::createScene(); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Scene"); 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_Scene_static_load(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_TSTRING || lua_type(state, 1) == LUA_TNIL)) { // Get parameter 1 off the stack. const char* param1 = ScriptUtil::getString(1, false); void* returnPtr = (void*)Scene::load(param1); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Scene"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Scene_static_load - 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_Scene_visit(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_TSTRING || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. const char* param1 = ScriptUtil::getString(2, false); Scene* instance = getInstance(state); instance->visit(param1); return 0; } else { lua_pushstring(state, "lua_Scene_visit - 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; } }