diff --git a/Engine.h b/Engine.h index ab0287f..47bdaf5 100644 --- a/Engine.h +++ b/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); diff --git a/ag.cc b/ag.cc index a109a02..52c7fb7 100644 --- a/ag.cc +++ b/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); diff --git a/ag.h b/ag.h index dd6d290..1ced059 100644 --- a/ag.h +++ b/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); diff --git a/doc/index.html b/doc/index.html index 4a0e04b..9e73382 100644 --- a/doc/index.html +++ b/doc/index.html @@ -393,6 +393,13 @@ The default center point is (0, 0, 0). The default up vector is (0, 0, 1).
+ +ag.setGravity(gx, gy, gz)
++This function sets the gravity vector to (gx, gy, gz). +
+ag.startFrame()