add absolute/relative force/torque addition functions
git-svn-id: svn://anubis/anaglym/trunk@102 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
7e22874623
commit
724622e094
16
Engine.h
16
Engine.h
@ -35,6 +35,22 @@ class Engine
|
|||||||
}
|
}
|
||||||
void setVisible(bool visible) { m_is_visible = visible; }
|
void setVisible(bool visible) { m_is_visible = visible; }
|
||||||
bool getVisible() { return m_is_visible; }
|
bool getVisible() { return m_is_visible; }
|
||||||
|
void addForce(dReal fx, dReal fy, dReal fz)
|
||||||
|
{
|
||||||
|
m_ode_object->addForce(fx, fy, fz);
|
||||||
|
}
|
||||||
|
void addRelForce(dReal fx, dReal fy, dReal fz)
|
||||||
|
{
|
||||||
|
m_ode_object->addRelForce(fx, fy, fz);
|
||||||
|
}
|
||||||
|
void addTorque(dReal fx, dReal fy, dReal fz)
|
||||||
|
{
|
||||||
|
m_ode_object->addTorque(fx, fy, fz);
|
||||||
|
}
|
||||||
|
void addRelTorque(dReal fx, dReal fy, dReal fz)
|
||||||
|
{
|
||||||
|
m_ode_object->addRelTorque(fx, fy, fz);
|
||||||
|
}
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
|
84
ag.cc
84
ag.cc
@ -123,6 +123,14 @@ namespace ag
|
|||||||
lua_setfield(L, -2, "destroy");
|
lua_setfield(L, -2, "destroy");
|
||||||
lua_pushcfunction(L, object::setVisible);
|
lua_pushcfunction(L, object::setVisible);
|
||||||
lua_setfield(L, -2, "setVisible");
|
lua_setfield(L, -2, "setVisible");
|
||||||
|
lua_pushcfunction(L, object::addForce);
|
||||||
|
lua_setfield(L, -2, "addForce");
|
||||||
|
lua_pushcfunction(L, object::addRelForce);
|
||||||
|
lua_setfield(L, -2, "addRelForce");
|
||||||
|
lua_pushcfunction(L, object::addTorque);
|
||||||
|
lua_setfield(L, -2, "addTorque");
|
||||||
|
lua_pushcfunction(L, object::addRelTorque);
|
||||||
|
lua_setfield(L, -2, "addRelTorque");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int loadModelSpecify(lua_State * L, bool static_data)
|
static int loadModelSpecify(lua_State * L, bool static_data)
|
||||||
@ -393,5 +401,81 @@ namespace ag
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int addForce(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 4)
|
||||||
|
{
|
||||||
|
Engine::Object * obj = getObject(L, 1);
|
||||||
|
if (obj != NULL &&
|
||||||
|
lua_isnumber(L, 2) &&
|
||||||
|
lua_isnumber(L, 3) &&
|
||||||
|
lua_isnumber(L, 4))
|
||||||
|
{
|
||||||
|
obj->addForce(lua_tonumber(L, 2),
|
||||||
|
lua_tonumber(L, 3),
|
||||||
|
lua_tonumber(L, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int addRelForce(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 4)
|
||||||
|
{
|
||||||
|
Engine::Object * obj = getObject(L, 1);
|
||||||
|
if (obj != NULL &&
|
||||||
|
lua_isnumber(L, 2) &&
|
||||||
|
lua_isnumber(L, 3) &&
|
||||||
|
lua_isnumber(L, 4))
|
||||||
|
{
|
||||||
|
obj->addRelForce(lua_tonumber(L, 2),
|
||||||
|
lua_tonumber(L, 3),
|
||||||
|
lua_tonumber(L, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int addTorque(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 4)
|
||||||
|
{
|
||||||
|
Engine::Object * obj = getObject(L, 1);
|
||||||
|
if (obj != NULL &&
|
||||||
|
lua_isnumber(L, 2) &&
|
||||||
|
lua_isnumber(L, 3) &&
|
||||||
|
lua_isnumber(L, 4))
|
||||||
|
{
|
||||||
|
obj->addTorque(lua_tonumber(L, 2),
|
||||||
|
lua_tonumber(L, 3),
|
||||||
|
lua_tonumber(L, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int addRelTorque(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 4)
|
||||||
|
{
|
||||||
|
Engine::Object * obj = getObject(L, 1);
|
||||||
|
if (obj != NULL &&
|
||||||
|
lua_isnumber(L, 2) &&
|
||||||
|
lua_isnumber(L, 3) &&
|
||||||
|
lua_isnumber(L, 4))
|
||||||
|
{
|
||||||
|
obj->addRelTorque(lua_tonumber(L, 2),
|
||||||
|
lua_tonumber(L, 3),
|
||||||
|
lua_tonumber(L, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
ag.h
4
ag.h
@ -32,6 +32,10 @@ namespace ag
|
|||||||
int clone(lua_State * L);
|
int clone(lua_State * L);
|
||||||
int destroy(lua_State * L);
|
int destroy(lua_State * L);
|
||||||
int setVisible(lua_State * L);
|
int setVisible(lua_State * L);
|
||||||
|
int addForce(lua_State * L);
|
||||||
|
int addRelForce(lua_State * L);
|
||||||
|
int addTorque(lua_State * L);
|
||||||
|
int addRelTorque(lua_State * L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ end
|
|||||||
function key_pressed_event(key)
|
function key_pressed_event(key)
|
||||||
if (key == "d") then
|
if (key == "d") then
|
||||||
ball2:destroy()
|
ball2:destroy()
|
||||||
|
elseif (key == "p") then
|
||||||
|
ball:addForce(-10000, 0, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user