diff --git a/Engine.h b/Engine.h index 2aa6a30..58a8b2e 100644 --- a/Engine.h +++ b/Engine.h @@ -78,6 +78,10 @@ class Engine void setMass(dReal mass) { m_ode_object->setMass(mass); } const float * getAABB() { return m_aabb; } dBodyID getBody() { return m_ode_object->getBody(); } + void setGravityMode(bool enabled) + { + m_ode_object->setGravityMode(enabled); + } protected: void createManagedObject(); diff --git a/ag.cc b/ag.cc index 20f0d6a..3dd6229 100644 --- a/ag.cc +++ b/ag.cc @@ -248,6 +248,8 @@ namespace ag lua_setfield(L, -2, "addTorqueRel"); lua_pushcfunction(L, object::setColor); lua_setfield(L, -2, "setColor"); + lua_pushcfunction(L, object::setGravityMode); + lua_setfield(L, -2, "setGravityMode"); lua_pushcfunction(L, object::setTexture); lua_setfield(L, -2, "setTexture"); lua_pushcfunction(L, object::setTextureScale); @@ -1164,6 +1166,20 @@ namespace ag return 0; } + int setGravityMode(lua_State * L) + { + int argc = lua_gettop(L); + if (argc == 2 && lua_isboolean(L, 2)) + { + Engine::Object * obj = getObject(L, 1); + if (obj != NULL) + { + obj->setGravityMode(lua_toboolean(L, 2)); + } + } + return 0; + } + int setTexture(lua_State * L) { int argc = lua_gettop(L); diff --git a/ag.h b/ag.h index c159022..e2cbd6e 100644 --- a/ag.h +++ b/ag.h @@ -81,6 +81,7 @@ namespace ag int addTorque(lua_State * L); int addTorqueRel(lua_State * L); int setColor(lua_State * L); + int setGravityMode(lua_State * L); int setTexture(lua_State * L); int setTextureScale(lua_State * L); int getMass(lua_State * L); diff --git a/tests/managed_objects.lua b/tests/managed_objects.lua index 8173738..457af31 100644 --- a/tests/managed_objects.lua +++ b/tests/managed_objects.lua @@ -43,5 +43,8 @@ function key_down_event(key) init_obj(box) ag.createAMotor(0, box, { x = 0, y = 0, z = 1, vel = 10, fmax = 10 }) + local x, y, z = box:getPosition() + box:setPosition(x, y, 2) + box:setGravityMode(false) end end