made startFrame() callable from lua, filled in Engine::setCamera()

git-svn-id: svn://anubis/anaglym/trunk@40 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-09-30 15:32:24 +00:00
parent a1c8736488
commit 7bc249599f
2 changed files with 32 additions and 0 deletions

1
ag.cc
View File

@ -26,6 +26,7 @@ namespace ag
{ "videoStart", videoStart },
{ "videoStop", videoStop },
{ "sleep", sleep },
{ "startFrame", startFrame },
{ "endFrame", endFrame },
{ "setCamera", setCamera },
{ NULL, NULL }

View File

@ -180,6 +180,7 @@ Engine::Object * Engine::getObject(int id)
int Engine::startFrame(lua_State * L)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(m_eye[0], m_eye[1], m_eye[2],
@ -197,6 +198,36 @@ int Engine::endFrame(lua_State * L)
int Engine::setCamera(lua_State * L)
{
int argc = lua_gettop(L);
vector<double> args;
for (int i = 1; i <= argc; i++)
{
int type = lua_type(L, i);
if (type == LUA_TNUMBER || type == LUA_TSTRING)
args.push_back(lua_tonumber(L, i));
else
args.push_back(0);
}
if (argc >= 3)
{
m_eye[0] = args[0];
m_eye[1] = args[1];
m_eye[2] = args[2];
}
if (argc >= 6)
{
m_center[0] = args[3];
m_center[1] = args[4];
m_center[2] = args[5];
}
if (argc >= 9)
{
m_up[0] = args[6];
m_up[1] = args[7];
m_up[2] = args[8];
}
return 0;
}