#include "Base.h" #include "ScriptController.h" #include "lua_PhysicsCollisionShape.h" #include "Base.h" #include "Game.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; 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*)((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."); ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata; if (object->owns) { PhysicsCollisionShape* instance = (PhysicsCollisionShape*)object->instance; SAFE_RELEASE(instance); } return 0; } else { 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; } else { 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; } else { 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; } else { 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; } else { 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) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(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: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL)) { // Get parameter 1 off the stack. Vector3* param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box(*param1)); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_PhysicsCollisionShape_static_box - 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. Vector3* param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); // Get parameter 2 off the stack. Vector3* param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box(*param1, *param2)); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_PhysicsCollisionShape_static_box - 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, 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. Vector3* param1 = ScriptUtil::getObjectPointer(1, "Vector3", true); // Get parameter 2 off the stack. Vector3* param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); // Get parameter 3 off the stack. bool param3 = ScriptUtil::luaCheckBool(state, 3); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box(*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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { 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) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(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: { 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) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_PhysicsCollisionShape_static_capsule - 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_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. Vector3* param3 = ScriptUtil::getObjectPointer(3, "Vector3", true); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_PhysicsCollisionShape_static_capsule - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 4: { 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. Vector3* param3 = ScriptUtil::getObjectPointer(3, "Vector3", true); // Get parameter 4 off the stack. bool param4 = ScriptUtil::luaCheckBool(state, 4); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule(param1, param2, *param3, param4)); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { 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 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. Image* param1 = ScriptUtil::getObjectPointer(1, "Image", false); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::heightfield(param1)); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { 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 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. Mesh* param1 = ScriptUtil::getObjectPointer(1, "Mesh", false); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::mesh(param1)); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { 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) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(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: { 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) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_PhysicsCollisionShape_static_sphere - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 2: { 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. Vector3* param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere(param1, *param2)); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_PhysicsCollisionShape_static_sphere - 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_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. Vector3* param2 = ScriptUtil::getObjectPointer(2, "Vector3", true); // Get parameter 3 off the stack. bool param3 = ScriptUtil::luaCheckBool(state, 3); void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere(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, "PhysicsCollisionShapeDefinition"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { 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; } }