diff --git a/Engine.cc b/Engine.cc index 0cc7f79..bf0a436 100644 --- a/Engine.cc +++ b/Engine.cc @@ -312,6 +312,15 @@ int Engine::addAMotor(Object * o1, Object * o2) return id; } +void Engine::setAMotorAxis(int jid, int anum, int rel, + dReal x, dReal y, dReal z) +{ + if (m_joints.find(jid) != m_joints.end()) + { + m_world.setAMotorAxis(m_joints[jid], anum, rel, x, y, z); + } +} + void Engine::setAMotorNumAxes(int jid, int num_axes) { if (m_joints.find(jid) != m_joints.end()) diff --git a/Engine.h b/Engine.h index a39f386..2aa6a30 100644 --- a/Engine.h +++ b/Engine.h @@ -125,6 +125,8 @@ class Engine int addObject(bool is_static, OdeWorld::GeomType geom_type, refptr< std::vector > args); int addAMotor(Object * o1, Object * o2); + void setAMotorAxis(int jid, int anum, int rel, + dReal x, dReal y, dReal z); void setAMotorNumAxes(int jid, int num_axes); void setAMotorLoStop(int jid, dReal val); void setAMotorHiStop(int jid, dReal val); diff --git a/ag.cc b/ag.cc index c525a40..c23d72f 100644 --- a/ag.cc +++ b/ag.cc @@ -275,6 +275,8 @@ namespace ag lua_setfield(L, -2, "setFMax"); lua_pushcfunction(L, joint::setAMotorBounce); lua_setfield(L, -2, "setBounce"); + lua_pushcfunction(L, joint::setAMotorAxis); + lua_setfield(L, -2, "setAxis"); } int _createAMotor(lua_State * L) @@ -1262,6 +1264,33 @@ namespace ag namespace joint { + int setAMotorAxis(lua_State * L) + { + int argc = lua_gettop(L); + if (argc == 6 + && lua_istable(L, 1) + && lua_isnumber(L, 2) + && lua_isnumber(L, 3) + && lua_isnumber(L, 4) + && lua_isnumber(L, 5) + && lua_isnumber(L, 6)) + { + lua_getfield(L, 1, "id"); + if (lua_isnumber(L, -1)) + { + int jid = lua_tointeger(L, -1); + g_engine->setAMotorAxis(jid, + lua_tointeger(L, 2), + lua_tointeger(L, 3), + lua_tonumber(L, 4), + lua_tonumber(L, 5), + lua_tonumber(L, 6)); + } + lua_pop(L, 1); + } + return 0; + } + int setAMotorLoStop(lua_State * L) { int argc = lua_gettop(L); diff --git a/ag.h b/ag.h index 326424a..b8a6d15 100644 --- a/ag.h +++ b/ag.h @@ -91,6 +91,7 @@ namespace ag namespace joint { + int setAMotorAxis(lua_State * L); int setAMotorLoStop(lua_State * L); int setAMotorHiStop(lua_State * L); int setAMotorVel(lua_State * L); diff --git a/ag.lua b/ag.lua index 0a80775..845570d 100644 --- a/ag.lua +++ b/ag.lua @@ -43,6 +43,7 @@ ag.createAMotor = function(obj1, obj2, axis0, axis1, axis2) amotor:setBounce(v) end end + amotor:setAxis(rel, x, y, z) end local o1 = obj1