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:
parent
b82458aa98
commit
ea4346a55e
5
Engine.h
5
Engine.h
@ -140,6 +140,11 @@ class Engine
|
||||
bool importFullPath(const char * path);
|
||||
GLuint loadTexture(const char * name);
|
||||
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 drawText(const char * text, GLfloat r, GLfloat g, GLfloat b,
|
||||
int ptsize, float x, float y);
|
||||
|
20
ag.cc
20
ag.cc
@ -50,6 +50,7 @@ namespace ag
|
||||
{ "setAutoPhysics", setAutoPhysics },
|
||||
{ "setAutoStartFrame", setAutoStartFrame },
|
||||
{ "setCamera", setCamera },
|
||||
{ "setGravity", setGravity },
|
||||
// { "sleep", sleep },
|
||||
{ "startFrame", startFrame },
|
||||
|
||||
@ -168,6 +169,10 @@ namespace ag
|
||||
lua_setfield(L, -2, "setMass");
|
||||
lua_pushcfunction(L, object::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)
|
||||
@ -241,6 +246,21 @@ namespace ag
|
||||
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)
|
||||
{
|
||||
return g_engine->getCamera(L);
|
||||
|
1
ag.h
1
ag.h
@ -30,6 +30,7 @@ namespace ag
|
||||
int setAutoPhysics(lua_State * L);
|
||||
int setAutoStartFrame(lua_State * L);
|
||||
int setCamera(lua_State * L);
|
||||
int setGravity(lua_State * L);
|
||||
int sleep(lua_State * L);
|
||||
int startFrame(lua_State * L);
|
||||
|
||||
|
@ -393,6 +393,13 @@ The default center point is (0, 0, 0).
|
||||
The default up vector is (0, 0, 1).
|
||||
</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" />
|
||||
<h3>startFrame</h3>
|
||||
<p><tt>ag.startFrame()</tt></p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user