added setAMotorAxis

git-svn-id: svn://anubis/anaglym/trunk@235 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2010-01-31 01:48:33 +00:00
parent 4ce1891cd1
commit 50cb363151
5 changed files with 42 additions and 0 deletions

View File

@ -312,6 +312,15 @@ int Engine::addAMotor(Object * o1, Object * o2)
return id; 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) void Engine::setAMotorNumAxes(int jid, int num_axes)
{ {
if (m_joints.find(jid) != m_joints.end()) if (m_joints.find(jid) != m_joints.end())

View File

@ -125,6 +125,8 @@ class Engine
int addObject(bool is_static, OdeWorld::GeomType geom_type, int addObject(bool is_static, OdeWorld::GeomType geom_type,
refptr< std::vector<float> > args); refptr< std::vector<float> > args);
int addAMotor(Object * o1, Object * o2); 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 setAMotorNumAxes(int jid, int num_axes);
void setAMotorLoStop(int jid, dReal val); void setAMotorLoStop(int jid, dReal val);
void setAMotorHiStop(int jid, dReal val); void setAMotorHiStop(int jid, dReal val);

29
ag.cc
View File

@ -275,6 +275,8 @@ namespace ag
lua_setfield(L, -2, "setFMax"); lua_setfield(L, -2, "setFMax");
lua_pushcfunction(L, joint::setAMotorBounce); lua_pushcfunction(L, joint::setAMotorBounce);
lua_setfield(L, -2, "setBounce"); lua_setfield(L, -2, "setBounce");
lua_pushcfunction(L, joint::setAMotorAxis);
lua_setfield(L, -2, "setAxis");
} }
int _createAMotor(lua_State * L) int _createAMotor(lua_State * L)
@ -1262,6 +1264,33 @@ namespace ag
namespace joint 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 setAMotorLoStop(lua_State * L)
{ {
int argc = lua_gettop(L); int argc = lua_gettop(L);

1
ag.h
View File

@ -91,6 +91,7 @@ namespace ag
namespace joint namespace joint
{ {
int setAMotorAxis(lua_State * L);
int setAMotorLoStop(lua_State * L); int setAMotorLoStop(lua_State * L);
int setAMotorHiStop(lua_State * L); int setAMotorHiStop(lua_State * L);
int setAMotorVel(lua_State * L); int setAMotorVel(lua_State * L);

1
ag.lua
View File

@ -43,6 +43,7 @@ ag.createAMotor = function(obj1, obj2, axis0, axis1, axis2)
amotor:setBounce(v) amotor:setBounce(v)
end end
end end
amotor:setAxis(rel, x, y, z)
end end
local o1 = obj1 local o1 = obj1