added ag::object::setRotation()
git-svn-id: svn://anubis/anaglym/trunk@109 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
c9b0bc2d82
commit
3aa41bedd8
4
Engine.h
4
Engine.h
@ -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
32
ag.cc
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user