added ag::object::setRotation()

git-svn-id: svn://anubis/anaglym/trunk@109 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-10-19 17:25:51 +00:00
parent c9b0bc2d82
commit 3aa41bedd8
3 changed files with 33 additions and 4 deletions

View File

@ -51,6 +51,10 @@ class Engine
{
m_ode_object->addRelTorque(fx, fy, fz);
}
void setRotation(dReal x, dReal y, dReal z)
{
m_ode_object->setRotation(x, y, z);
}
void draw();

32
ag.cc
View File

@ -117,6 +117,8 @@ namespace ag
lua_setfield(L, -2, "setPosition");
lua_pushcfunction(L, object::getPosition);
lua_setfield(L, -2, "getPosition");
lua_pushcfunction(L, object::setRotation);
lua_setfield(L, -2, "setRotation");
lua_pushcfunction(L, object::clone);
lua_setfield(L, -2, "clone");
lua_pushcfunction(L, object::destroy);
@ -305,10 +307,9 @@ namespace ag
double position[3];
for (int i = 0; i < 3; i++)
{
if (lua_isnumber(L, i + 2))
{
position[i] = lua_tonumber(L, i + 2);
}
position[i] = (lua_isnumber(L, i + 2))
? lua_tonumber(L, i + 2)
: 0.0;
}
obj->setPosition(position[0], position[1], position[2]);
}
@ -336,6 +337,29 @@ namespace ag
return 0;
}
int setRotation(lua_State * L)
{
int argc = lua_gettop(L);
if (argc == 4)
{
Engine::Object * obj = getObject(L, 1);
if (obj != NULL)
{
double rot[3];
for (int i = 0; i < 3; i++)
{
rot[i] = (lua_isnumber(L, i + 2))
? lua_tonumber(L, i + 2)
: 0.0;
}
obj->setRotation(rot[0], rot[1], rot[2]);
}
}
return 0;
}
int clone(lua_State * L)
{
int argc = lua_gettop(L);

1
ag.h
View File

@ -29,6 +29,7 @@ namespace ag
int draw(lua_State * L);
int setPosition(lua_State * L);
int getPosition(lua_State * L);
int setRotation(lua_State * L);
int clone(lua_State * L);
int destroy(lua_State * L);
int setVisible(lua_State * L);