added ag::setGravity() so the script programmer can change the world gravity

git-svn-id: svn://anubis/anaglym/trunk@200 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-12-09 00:07:30 +00:00
parent b82458aa98
commit ea4346a55e
4 changed files with 33 additions and 0 deletions

View File

@ -140,6 +140,11 @@ class Engine
bool importFullPath(const char * path); bool importFullPath(const char * path);
GLuint loadTexture(const char * name); GLuint loadTexture(const char * name);
void debug_hook(lua_Debug * debug); void debug_hook(lua_Debug * debug);
void setGravity(float gx, float gy, float gz)
{
m_world.setGravity(gx, gy, gz);
}
void getScreenSize(int * width, int * height); void getScreenSize(int * width, int * height);
void drawText(const char * text, GLfloat r, GLfloat g, GLfloat b, void drawText(const char * text, GLfloat r, GLfloat g, GLfloat b,
int ptsize, float x, float y); int ptsize, float x, float y);

20
ag.cc
View File

@ -50,6 +50,7 @@ namespace ag
{ "setAutoPhysics", setAutoPhysics }, { "setAutoPhysics", setAutoPhysics },
{ "setAutoStartFrame", setAutoStartFrame }, { "setAutoStartFrame", setAutoStartFrame },
{ "setCamera", setCamera }, { "setCamera", setCamera },
{ "setGravity", setGravity },
// { "sleep", sleep }, // { "sleep", sleep },
{ "startFrame", startFrame }, { "startFrame", startFrame },
@ -168,6 +169,10 @@ namespace ag
lua_setfield(L, -2, "setMass"); lua_setfield(L, -2, "setMass");
lua_pushcfunction(L, object::getMass); lua_pushcfunction(L, object::getMass);
lua_setfield(L, -2, "getMass"); lua_setfield(L, -2, "getMass");
lua_pushcfunction(L, object::getAABB);
lua_setfield(L, -2, "getAABB");
lua_pushcfunction(L, object::getSize);
lua_setfield(L, -2, "getSize");
} }
static int loadModelSpecify(lua_State * L, bool static_data) static int loadModelSpecify(lua_State * L, bool static_data)
@ -241,6 +246,21 @@ namespace ag
return g_engine->setCamera(L); return g_engine->setCamera(L);
} }
int setGravity(lua_State * L)
{
int argc = lua_gettop(L);
if (argc == 3
&& lua_isnumber(L, 1)
&& lua_isnumber(L, 2)
&& lua_isnumber(L, 3))
{
g_engine->setGravity(lua_tonumber(L, 1),
lua_tonumber(L, 2),
lua_tonumber(L, 3));
}
return 0;
}
int getCamera(lua_State * L) int getCamera(lua_State * L)
{ {
return g_engine->getCamera(L); return g_engine->getCamera(L);

1
ag.h
View File

@ -30,6 +30,7 @@ namespace ag
int setAutoPhysics(lua_State * L); int setAutoPhysics(lua_State * L);
int setAutoStartFrame(lua_State * L); int setAutoStartFrame(lua_State * L);
int setCamera(lua_State * L); int setCamera(lua_State * L);
int setGravity(lua_State * L);
int sleep(lua_State * L); int sleep(lua_State * L);
int startFrame(lua_State * L); int startFrame(lua_State * L);

View File

@ -393,6 +393,13 @@ The default center point is (0, 0, 0).
The default up vector is (0, 0, 1). The default up vector is (0, 0, 1).
</p> </p>
<a name="ag_setGravity" />
<h3>setGravity</h3>
<p><tt>ag.setGravity(gx, gy, gz)</tt></p>
<p>
This function sets the gravity vector to (gx, gy, gz).
</p>
<a name="ag_startFrame" /> <a name="ag_startFrame" />
<h3>startFrame</h3> <h3>startFrame</h3>
<p><tt>ag.startFrame()</tt></p> <p><tt>ag.startFrame()</tt></p>