#include "Base.h" #include "ScriptController.h" #include "lua_PhysicsCollisionShape.h" #include "Base.h" #include "FileSystem.h" #include "Game.h" #include "HeightField.h" #include "Image.h" #include "Node.h" #include "PhysicsCollisionShape.h" #include "Properties.h" #include "Ref.h" #include "lua_PhysicsCollisionShapeType.h" namespace gameplay { void luaRegister_PhysicsCollisionShape() { const luaL_Reg lua_members[] = { {"addRef", lua_PhysicsCollisionShape_addRef}, {"getRefCount", lua_PhysicsCollisionShape_getRefCount}, {"getType", lua_PhysicsCollisionShape_getType}, {"release", lua_PhysicsCollisionShape_release}, {NULL, NULL} }; const luaL_Reg lua_statics[] = { {"box", lua_PhysicsCollisionShape_static_box}, {"capsule", lua_PhysicsCollisionShape_static_capsule}, {"heightfield", lua_PhysicsCollisionShape_static_heightfield}, {"mesh", lua_PhysicsCollisionShape_static_mesh}, {"sphere", lua_PhysicsCollisionShape_static_sphere}, {NULL, NULL} }; std::vector scopePath; gameplay::ScriptUtil::registerClass("PhysicsCollisionShape", lua_members, NULL, lua_PhysicsCollisionShape__gc, lua_statics, scopePath); } static PhysicsCollisionShape* getInstance(lua_State* state) { void* userdata = luaL_checkudata(state, 1, "PhysicsCollisionShape"); luaL_argcheck(state, userdata != NULL, 1, "'PhysicsCollisionShape' expected."); return (PhysicsCollisionShape*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance; } int lua_PhysicsCollisionShape__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, "PhysicsCollisionShape"); luaL_argcheck(state, userdata != NULL, 1, "'PhysicsCollisionShape' expected."); gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata; if (object->owns) { PhysicsCollisionShape* instance = (PhysicsCollisionShape*)object->instance; SAFE_RELEASE(instance); } return 0; } lua_pushstring(state, "lua_PhysicsCollisionShape__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_PhysicsCollisionShape_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)) { PhysicsCollisionShape* instance = getInstance(state); instance->addRef(); return 0; } lua_pushstring(state, "lua_PhysicsCollisionShape_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_PhysicsCollisionShape_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)) { PhysicsCollisionShape* 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_PhysicsCollisionShape_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_PhysicsCollisionShape_getType(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)) { PhysicsCollisionShape* instance = getInstance(state); PhysicsCollisionShape::Type result = instance->getType(); // Push the return value onto the stack. lua_pushstring(state, lua_stringFromEnum_PhysicsCollisionShapeType(result)); return 1; } lua_pushstring(state, "lua_PhysicsCollisionShape_getType - 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_PhysicsCollisionShape_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)) { PhysicsCollisionShape* instance = getInstance(state); instance->release(); return 0; } lua_pushstring(state, "lua_PhysicsCollisionShape_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_PhysicsCollisionShape_static_box(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 PhysicsCollisionShape::Definition(PhysicsCollisionShape::box()); 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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } 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*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box(*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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_box - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 2: { do { 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. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector3", true, ¶m1Valid); if (!param1Valid) break; // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector3", true, ¶m2Valid); if (!param2Valid) break; void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box(*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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_box - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 3: { do { 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_TBOOLEAN) { // 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. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector3", true, ¶m2Valid); if (!param2Valid) break; // Get parameter 3 off the stack. bool param3 = gameplay::ScriptUtil::luaCheckBool(state, 3); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box(*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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_box - 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_PhysicsCollisionShape_static_capsule(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 PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule()); 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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } case 2: { do { if (lua_type(state, 1) == LUA_TNUMBER && lua_type(state, 2) == 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); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_capsule - 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_TUSERDATA || lua_type(state, 3) == LUA_TNIL)) { // 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. bool param3Valid; gameplay::ScriptUtil::LuaArray param3 = gameplay::ScriptUtil::getObjectPointer(3, "Vector3", true, ¶m3Valid); if (!param3Valid) break; void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_capsule - 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_TUSERDATA || lua_type(state, 3) == LUA_TNIL) && lua_type(state, 4) == LUA_TBOOLEAN) { // 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. bool param3Valid; gameplay::ScriptUtil::LuaArray param3 = gameplay::ScriptUtil::getObjectPointer(3, "Vector3", true, ¶m3Valid); if (!param3Valid) break; // Get parameter 4 off the stack. bool param4 = gameplay::ScriptUtil::luaCheckBool(state, 4); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_capsule - 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, 2, 3 or 4)."); lua_error(state); break; } } return 0; } int lua_PhysicsCollisionShape_static_heightfield(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 PhysicsCollisionShape::Definition(PhysicsCollisionShape::heightfield()); 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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } case 1: { do { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "HeightField", false, ¶m1Valid); if (!param1Valid) break; void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::heightfield(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_heightfield - 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 or 1)."); lua_error(state); break; } } return 0; } int lua_PhysicsCollisionShape_static_mesh(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 || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Mesh", false, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Mesh'."); lua_error(state); } void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::mesh(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } lua_pushstring(state, "lua_PhysicsCollisionShape_static_mesh - 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_PhysicsCollisionShape_static_sphere(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 PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere()); 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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } case 1: { do { if (lua_type(state, 1) == LUA_TNUMBER) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 1); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_sphere - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 2: { do { if (lua_type(state, 1) == LUA_TNUMBER && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 1); // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector3", true, ¶m2Valid); if (!param2Valid) break; void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_sphere - 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_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && lua_type(state, 3) == LUA_TBOOLEAN) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 1); // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector3", true, ¶m2Valid); if (!param2Valid) break; // Get parameter 3 off the stack. bool param3 = gameplay::ScriptUtil::luaCheckBool(state, 3); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_PhysicsCollisionShape_static_sphere - 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; } }