still working on AMotor parameters
git-svn-id: svn://anubis/anaglym/trunk@233 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
fd33b69d78
commit
f8db43ff2e
40
ag.cc
40
ag.cc
@ -260,6 +260,23 @@ namespace ag
|
|||||||
lua_setfield(L, -2, "getSize");
|
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)
|
static int loadModelSpecify(lua_State * L, bool static_data)
|
||||||
{
|
{
|
||||||
bool added = false;
|
bool added = false;
|
||||||
@ -1225,4 +1242,27 @@ namespace ag
|
|||||||
return 1;
|
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
9
ag.h
@ -83,6 +83,15 @@ namespace ag
|
|||||||
int getAABB(lua_State * L);
|
int getAABB(lua_State * L);
|
||||||
int getSize(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
|
#endif
|
||||||
|
45
ag.lua
45
ag.lua
@ -1,5 +1,4 @@
|
|||||||
next = ag.next
|
next = ag.next
|
||||||
|
|
||||||
type = ag.type
|
type = ag.type
|
||||||
|
|
||||||
pairs = function(table)
|
pairs = function(table)
|
||||||
@ -20,33 +19,65 @@ end
|
|||||||
|
|
||||||
ag.createAMotor = function(obj1, obj2, axis0, axis1, axis2)
|
ag.createAMotor = function(obj1, obj2, axis0, axis1, axis2)
|
||||||
local function setAMotorAxis(amotor, anum, axis)
|
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
|
||||||
|
end
|
||||||
|
|
||||||
local o1 = obj1
|
local o1 = obj1
|
||||||
local o2 = obj2
|
local o2 = obj2
|
||||||
local num_axes = 1
|
local num_axes = 0
|
||||||
|
|
||||||
if (type(obj1) == "number") then
|
if (type(obj1) == "number") then
|
||||||
if (obj1 == 0) then
|
if (obj1 == 0) then
|
||||||
o1 = { id = 0 }
|
o1 = { id = 0 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(obj2) == "number") then
|
if (type(obj2) == "number") then
|
||||||
if (obj2 == 0) then
|
if (obj2 == 0) then
|
||||||
o2 = { id = 0 }
|
o2 = { id = 0 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local num_axes = 0
|
|
||||||
|
local amotor = ag._createAMotor(obj1, obj2)
|
||||||
|
|
||||||
if (axis0 ~= nil) then
|
if (axis0 ~= nil) then
|
||||||
setAMotorAxis(0, axis0)
|
setAMotorAxis(amotor, 0, axis0)
|
||||||
num_axes = 1
|
num_axes = 1
|
||||||
if (axis1 ~= nil) then
|
if (axis1 ~= nil) then
|
||||||
setAMotorAxis(1, axis1)
|
setAMotorAxis(amotor, 1, axis1)
|
||||||
num_axes = 1
|
num_axes = 1
|
||||||
if (axis2 ~= nil) then
|
if (axis2 ~= nil) then
|
||||||
setAMotorAxis(2, axis2)
|
setAMotorAxis(amotor, 2, axis2)
|
||||||
num_axes = 2
|
num_axes = 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ag.setAMotorNumAxes(num_axes)
|
|
||||||
|
amotor:setNumAxes(num_axes)
|
||||||
|
|
||||||
|
return amotor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user