adding ag::create<Object>() lua interfaces - in progress (not compiling)
git-svn-id: svn://anubis/anaglym/trunk@131 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
9c94186d31
commit
d564f3b5a0
132
ag.cc
132
ag.cc
@ -286,6 +286,138 @@ namespace ag
|
|||||||
return g_engine->clearEventHandler(L);
|
return g_engine->clearEventHandler(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int addManagedObject(lua_State * L, bool is_static,
|
||||||
|
OdeWorld::GeomType geom_type, refptr< vector<float> > args)
|
||||||
|
{
|
||||||
|
int id = g_engine->addObject(is_static, geom_type, args);
|
||||||
|
createLuaObject(L, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int createBoxSpecify(lua_State * L, bool is_static)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 3 &&
|
||||||
|
lua_isnumber(L, 1) &&
|
||||||
|
lua_isnumber(L, 2) &&
|
||||||
|
lua_isnumber(L, 3))
|
||||||
|
{
|
||||||
|
refptr< vector<float> > args = new vector<float>();
|
||||||
|
args.push_back(lua_tonumber(L, 1));
|
||||||
|
args.push_back(lua_tonumber(L, 2));
|
||||||
|
args.push_back(lua_tonumber(L, 3));
|
||||||
|
addManagedObject(L, is_static, OdeWorld::BOX, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int createBox(lua_State * L)
|
||||||
|
{
|
||||||
|
return createBoxSpecify(L, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int createStaticBox(lua_State * L)
|
||||||
|
{
|
||||||
|
return createBoxSpecify(L, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int createSphereSpecify(lua_State * L, bool is_static)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 1 && lua_isnumber(L, 1))
|
||||||
|
{
|
||||||
|
refptr< vector<float> > args = new vector<float>();
|
||||||
|
args.push_back(lua_tonumber(L, 1));
|
||||||
|
addManagedObject(L, is_static, OdeWorld::SPHERE, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int createSphere(lua_State * L)
|
||||||
|
{
|
||||||
|
return createSphereSpecify(L, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int createStaticSphere(lua_State * L)
|
||||||
|
{
|
||||||
|
return createSphereSpecify(L, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int createPlaneSpecify(lua_State * L, bool is_static)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 3 &&
|
||||||
|
lua_isnumber(L, 1) &&
|
||||||
|
lua_isnumber(L, 2) &&
|
||||||
|
lua_isnumber(L, 3))
|
||||||
|
{
|
||||||
|
refptr< vector<float> > args = new vector<float>();
|
||||||
|
args.push_back(lua_tonumber(L, 1));
|
||||||
|
args.push_back(lua_tonumber(L, 2));
|
||||||
|
args.push_back(lua_tonumber(L, 3));
|
||||||
|
addManagedObject(L, is_static, OdeWorld::BOX, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int createPlane(lua_State * L)
|
||||||
|
{
|
||||||
|
return createPlaneSpecify(L, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int createStaticPlane(lua_State * L)
|
||||||
|
{
|
||||||
|
return createPlaneSpecify(L, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int createCylinderSpecify(lua_State * L, bool is_static)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 3 &&
|
||||||
|
lua_isnumber(L, 1) &&
|
||||||
|
lua_isnumber(L, 2) &&
|
||||||
|
lua_isnumber(L, 3))
|
||||||
|
{
|
||||||
|
refptr< vector<float> > args = new vector<float>();
|
||||||
|
args.push_back(lua_tonumber(L, 1));
|
||||||
|
args.push_back(lua_tonumber(L, 2));
|
||||||
|
args.push_back(lua_tonumber(L, 3));
|
||||||
|
addManagedObject(L, is_static, OdeWorld::BOX, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int createCylinder(lua_State * L)
|
||||||
|
{
|
||||||
|
return createCylinderSpecify(L, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int createStaticCylinder(lua_State * L)
|
||||||
|
{
|
||||||
|
return createCylinderSpecify(L, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int createCCylinderSpecify(lua_State * L, bool is_static)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int createCCylinder(lua_State * L)
|
||||||
|
{
|
||||||
|
return createCCylinderSpecify(L, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int createStaticCCylinder(lua_State * L)
|
||||||
|
{
|
||||||
|
return createCCylinderSpecify(L, true);
|
||||||
|
}
|
||||||
|
|
||||||
namespace object
|
namespace object
|
||||||
{
|
{
|
||||||
static Engine::Object * getObject(lua_State * L, int index)
|
static Engine::Object * getObject(lua_State * L, int index)
|
||||||
|
11
ag.h
11
ag.h
@ -27,6 +27,17 @@ namespace ag
|
|||||||
int registerEventHandler(lua_State * L);
|
int registerEventHandler(lua_State * L);
|
||||||
int clearEventHandler(lua_State * L);
|
int clearEventHandler(lua_State * L);
|
||||||
|
|
||||||
|
int createBox(lua_State * L);
|
||||||
|
int createStaticBox(lua_State * L);
|
||||||
|
int createSphere(lua_State * L);
|
||||||
|
int createStaticSphere(lua_State * L);
|
||||||
|
int createPlane(lua_State * L);
|
||||||
|
int createStaticPlane(lua_State * L);
|
||||||
|
int createCylinder(lua_State * L);
|
||||||
|
int createStaticCylinder(lua_State * L);
|
||||||
|
int createCCylinder(lua_State * L);
|
||||||
|
int createStaticCCylinder(lua_State * L);
|
||||||
|
|
||||||
namespace object
|
namespace object
|
||||||
{
|
{
|
||||||
int draw(lua_State * L);
|
int draw(lua_State * L);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user