From ea4346a55e6caef3edb4addc7fe318aba142ce3d Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 9 Dec 2009 00:07:30 +0000 Subject: [PATCH] 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 --- Engine.h | 5 +++++ ag.cc | 20 ++++++++++++++++++++ ag.h | 1 + doc/index.html | 7 +++++++ 4 files changed, 33 insertions(+) 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).

+ +

setGravity

+

ag.setGravity(gx, gy, gz)

+

+This function sets the gravity vector to (gx, gy, gz). +

+

startFrame

ag.startFrame()