diff --git a/Engine.cc b/Engine.cc index 29a9e2b..59f7482 100644 --- a/Engine.cc +++ b/Engine.cc @@ -678,8 +678,8 @@ void Engine::Object::createManagedObject() { switch (m_geom_type) { - case OdeWorld::CUBE: - m_ode_object->addCube(m_args); + case OdeWorld::BOX: + m_ode_object->addBox(m_args); break; case OdeWorld::SPHERE: m_ode_object->addSphere(m_args); @@ -704,7 +704,7 @@ void Engine::Object::render() bool valid = false; switch (m_geom_type) { - case OdeWorld::CUBE: + case OdeWorld::BOX: if (m_args->size() >= 3) valid = true; break; case OdeWorld::SPHERE: @@ -730,7 +730,7 @@ void Engine::Object::render() GLUquadric * quad = gluNewQuadric(); switch (m_geom_type) { - case OdeWorld::CUBE: { + case OdeWorld::BOX: { struct { float norm[3]; float verts[4][3]; } sides[] = { { {1, 0, 0}, /* right */ {{1, -1, -1}, {1, 1, -1}, {1, 1, 1}, {1, -1, 1}} }, @@ -880,7 +880,7 @@ void Engine::Object::loadPhy(const FileLoader::Path & path) } if (type == "cube") { - m_ode_object->addCube(args); + m_ode_object->addBox(args); } else if (type == "sphere") { diff --git a/ag.cc b/ag.cc index 138c83c..faa1184 100644 --- a/ag.cc +++ b/ag.cc @@ -286,7 +286,7 @@ namespace ag return g_engine->clearEventHandler(L); } - static int addManagedObject(lua_State * L, bool is_static, + static void addManagedObject(lua_State * L, bool is_static, OdeWorld::GeomType geom_type, refptr< vector > args) { int id = g_engine->addObject(is_static, geom_type, args); @@ -302,9 +302,8 @@ namespace ag lua_isnumber(L, 3)) { refptr< vector > args = new vector(); - args.push_back(lua_tonumber(L, 1)); - args.push_back(lua_tonumber(L, 2)); - args.push_back(lua_tonumber(L, 3)); + for (int i = 1; i <= 3; i++) + args->push_back(lua_tonumber(L, i)); addManagedObject(L, is_static, OdeWorld::BOX, args); } else @@ -328,7 +327,7 @@ namespace ag if (argc == 1 && lua_isnumber(L, 1)) { refptr< vector > args = new vector(); - args.push_back(lua_tonumber(L, 1)); + args->push_back(lua_tonumber(L, 1)); addManagedObject(L, is_static, OdeWorld::SPHERE, args); } else @@ -349,16 +348,18 @@ namespace ag static int createPlaneSpecify(lua_State * L, bool is_static) { int argc = lua_gettop(L); - if (argc == 3 && + if (argc == 6 && lua_isnumber(L, 1) && lua_isnumber(L, 2) && - lua_isnumber(L, 3)) + lua_isnumber(L, 3) && + lua_isnumber(L, 4) && + lua_isnumber(L, 5) && + lua_isnumber(L, 6)) { refptr< vector > args = new vector(); - args.push_back(lua_tonumber(L, 1)); - args.push_back(lua_tonumber(L, 2)); - args.push_back(lua_tonumber(L, 3)); - addManagedObject(L, is_static, OdeWorld::BOX, args); + for (int i = 1; i <= 6; i++) + args->push_back(lua_tonumber(L, i)); + addManagedObject(L, is_static, OdeWorld::PLANE, args); } else lua_pushnil(L); @@ -378,16 +379,12 @@ namespace ag static int createCylinderSpecify(lua_State * L, bool is_static) { int argc = lua_gettop(L); - if (argc == 3 && - lua_isnumber(L, 1) && - lua_isnumber(L, 2) && - lua_isnumber(L, 3)) + if (argc == 2 && lua_isnumber(L, 1) && lua_isnumber(L, 2)) { refptr< vector > args = new vector(); - args.push_back(lua_tonumber(L, 1)); - args.push_back(lua_tonumber(L, 2)); - args.push_back(lua_tonumber(L, 3)); - addManagedObject(L, is_static, OdeWorld::BOX, args); + args->push_back(lua_tonumber(L, 1)); + args->push_back(lua_tonumber(L, 2)); + addManagedObject(L, is_static, OdeWorld::CYLINDER, args); } else lua_pushnil(L); @@ -406,6 +403,17 @@ namespace ag static int createCCylinderSpecify(lua_State * L, bool is_static) { + int argc = lua_gettop(L); + if (argc == 2 && lua_isnumber(L, 1) && lua_isnumber(L, 2)) + { + refptr< vector > args = new vector(); + args->push_back(lua_tonumber(L, 1)); + args->push_back(lua_tonumber(L, 2)); + addManagedObject(L, is_static, OdeWorld::CCYLINDER, args); + } + else + lua_pushnil(L); + return 1; } int createCCylinder(lua_State * L)