still working on AMotor parameters

git-svn-id: svn://anubis/anaglym/trunk@233 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2010-01-29 21:33:42 +00:00
parent fd33b69d78
commit f8db43ff2e
3 changed files with 87 additions and 7 deletions

40
ag.cc
View File

@ -260,6 +260,23 @@ namespace ag
lua_setfield(L, -2, "getSize");
}
static void createLuaJoint(lua_State * L, int id)
{
lua_newtable(L);
lua_pushinteger(L, id);
lua_setfield(L, -2, "id");
lua_pushcfunction(L, joint::setLoStop);
lua_setfield(L, -2, "setLoStop");
lua_pushcfunction(L, joint::setHiStop);
lua_setfield(L, -2, "setHiStop");
lua_pushcfunction(L, joint::setVel);
lua_setfield(L, -2, "setVel");
lua_pushcfunction(L, joint::setFMax);
lua_setfield(L, -2, "setFMax");
lua_pushcfunction(L, joint::setBounce);
lua_setfield(L, -2, "setBounce");
}
static int loadModelSpecify(lua_State * L, bool static_data)
{
bool added = false;
@ -1225,4 +1242,27 @@ namespace ag
return 1;
}
}
namespace joint
{
int setLoStop(lua_State * L)
{
}
int setHiStop(lua_State * L)
{
}
int setVel(lua_State * L)
{
}
int setFMax(lua_State * L)
{
}
int setBounce(lua_State * L)
{
}
}
}

9
ag.h
View File

@ -83,6 +83,15 @@ namespace ag
int getAABB(lua_State * L);
int getSize(lua_State * L);
}
namespace joint
{
int setLoStop(lua_State * L);
int setHiStop(lua_State * L);
int setVel(lua_State * L);
int setFMax(lua_State * L);
int setBounce(lua_State * L);
}
}
#endif

45
ag.lua
View File

@ -1,5 +1,4 @@
next = ag.next
type = ag.type
pairs = function(table)
@ -20,33 +19,65 @@ end
ag.createAMotor = function(obj1, obj2, axis0, axis1, axis2)
local function setAMotorAxis(amotor, anum, axis)
local rel, x, y, z, angle = 0, 1, 0, 0, 0
for k, v in pairs(axis) do
if (k == "rel") then
rel = v
elseif (k == "x") then
x = v
elseif (k == "y") then
y = v
elseif (k == "z") then
z = v
elseif (k == "angle") then
angle = v
elseif (k == "lo_stop") then
amotor:setLoStop(v)
elseif (k == "hi_stop") then
amotor:setHiStop(v)
elseif (k == "vel") then
amotor:setVel(v)
elseif (k == "fmax") then
amotor:setFMax(v)
elseif (k == "bounce") then
amotor:setBounce(v)
end
end
end
local o1 = obj1
local o2 = obj2
local num_axes = 1
local num_axes = 0
if (type(obj1) == "number") then
if (obj1 == 0) then
o1 = { id = 0 }
end
end
if (type(obj2) == "number") then
if (obj2 == 0) then
o2 = { id = 0 }
end
end
local num_axes = 0
local amotor = ag._createAMotor(obj1, obj2)
if (axis0 ~= nil) then
setAMotorAxis(0, axis0)
setAMotorAxis(amotor, 0, axis0)
num_axes = 1
if (axis1 ~= nil) then
setAMotorAxis(1, axis1)
setAMotorAxis(amotor, 1, axis1)
num_axes = 1
if (axis2 ~= nil) then
setAMotorAxis(2, axis2)
setAMotorAxis(amotor, 2, axis2)
num_axes = 2
end
end
end
ag.setAMotorNumAxes(num_axes)
amotor:setNumAxes(num_axes)
return amotor
end