finished filling in ag::create<Object>() functions
git-svn-id: svn://anubis/anaglym/trunk@132 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
d564f3b5a0
commit
2616100ded
10
Engine.cc
10
Engine.cc
@ -678,8 +678,8 @@ void Engine::Object::createManagedObject()
|
|||||||
{
|
{
|
||||||
switch (m_geom_type)
|
switch (m_geom_type)
|
||||||
{
|
{
|
||||||
case OdeWorld::CUBE:
|
case OdeWorld::BOX:
|
||||||
m_ode_object->addCube(m_args);
|
m_ode_object->addBox(m_args);
|
||||||
break;
|
break;
|
||||||
case OdeWorld::SPHERE:
|
case OdeWorld::SPHERE:
|
||||||
m_ode_object->addSphere(m_args);
|
m_ode_object->addSphere(m_args);
|
||||||
@ -704,7 +704,7 @@ void Engine::Object::render()
|
|||||||
bool valid = false;
|
bool valid = false;
|
||||||
switch (m_geom_type)
|
switch (m_geom_type)
|
||||||
{
|
{
|
||||||
case OdeWorld::CUBE:
|
case OdeWorld::BOX:
|
||||||
if (m_args->size() >= 3) valid = true;
|
if (m_args->size() >= 3) valid = true;
|
||||||
break;
|
break;
|
||||||
case OdeWorld::SPHERE:
|
case OdeWorld::SPHERE:
|
||||||
@ -730,7 +730,7 @@ void Engine::Object::render()
|
|||||||
GLUquadric * quad = gluNewQuadric();
|
GLUquadric * quad = gluNewQuadric();
|
||||||
switch (m_geom_type)
|
switch (m_geom_type)
|
||||||
{
|
{
|
||||||
case OdeWorld::CUBE: {
|
case OdeWorld::BOX: {
|
||||||
struct { float norm[3]; float verts[4][3]; } sides[] = {
|
struct { float norm[3]; float verts[4][3]; } sides[] = {
|
||||||
{ {1, 0, 0}, /* right */
|
{ {1, 0, 0}, /* right */
|
||||||
{{1, -1, -1}, {1, 1, -1}, {1, 1, 1}, {1, -1, 1}} },
|
{{1, -1, -1}, {1, 1, -1}, {1, 1, 1}, {1, -1, 1}} },
|
||||||
@ -880,7 +880,7 @@ void Engine::Object::loadPhy(const FileLoader::Path & path)
|
|||||||
}
|
}
|
||||||
if (type == "cube")
|
if (type == "cube")
|
||||||
{
|
{
|
||||||
m_ode_object->addCube(args);
|
m_ode_object->addBox(args);
|
||||||
}
|
}
|
||||||
else if (type == "sphere")
|
else if (type == "sphere")
|
||||||
{
|
{
|
||||||
|
46
ag.cc
46
ag.cc
@ -286,7 +286,7 @@ namespace ag
|
|||||||
return g_engine->clearEventHandler(L);
|
return g_engine->clearEventHandler(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int addManagedObject(lua_State * L, bool is_static,
|
static void addManagedObject(lua_State * L, bool is_static,
|
||||||
OdeWorld::GeomType geom_type, refptr< vector<float> > args)
|
OdeWorld::GeomType geom_type, refptr< vector<float> > args)
|
||||||
{
|
{
|
||||||
int id = g_engine->addObject(is_static, geom_type, args);
|
int id = g_engine->addObject(is_static, geom_type, args);
|
||||||
@ -302,9 +302,8 @@ namespace ag
|
|||||||
lua_isnumber(L, 3))
|
lua_isnumber(L, 3))
|
||||||
{
|
{
|
||||||
refptr< vector<float> > args = new vector<float>();
|
refptr< vector<float> > args = new vector<float>();
|
||||||
args.push_back(lua_tonumber(L, 1));
|
for (int i = 1; i <= 3; i++)
|
||||||
args.push_back(lua_tonumber(L, 2));
|
args->push_back(lua_tonumber(L, i));
|
||||||
args.push_back(lua_tonumber(L, 3));
|
|
||||||
addManagedObject(L, is_static, OdeWorld::BOX, args);
|
addManagedObject(L, is_static, OdeWorld::BOX, args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -328,7 +327,7 @@ namespace ag
|
|||||||
if (argc == 1 && lua_isnumber(L, 1))
|
if (argc == 1 && lua_isnumber(L, 1))
|
||||||
{
|
{
|
||||||
refptr< vector<float> > args = new vector<float>();
|
refptr< vector<float> > args = new vector<float>();
|
||||||
args.push_back(lua_tonumber(L, 1));
|
args->push_back(lua_tonumber(L, 1));
|
||||||
addManagedObject(L, is_static, OdeWorld::SPHERE, args);
|
addManagedObject(L, is_static, OdeWorld::SPHERE, args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -349,16 +348,18 @@ namespace ag
|
|||||||
static int createPlaneSpecify(lua_State * L, bool is_static)
|
static int createPlaneSpecify(lua_State * L, bool is_static)
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
if (argc == 3 &&
|
if (argc == 6 &&
|
||||||
lua_isnumber(L, 1) &&
|
lua_isnumber(L, 1) &&
|
||||||
lua_isnumber(L, 2) &&
|
lua_isnumber(L, 2) &&
|
||||||
lua_isnumber(L, 3))
|
lua_isnumber(L, 3) &&
|
||||||
|
lua_isnumber(L, 4) &&
|
||||||
|
lua_isnumber(L, 5) &&
|
||||||
|
lua_isnumber(L, 6))
|
||||||
{
|
{
|
||||||
refptr< vector<float> > args = new vector<float>();
|
refptr< vector<float> > args = new vector<float>();
|
||||||
args.push_back(lua_tonumber(L, 1));
|
for (int i = 1; i <= 6; i++)
|
||||||
args.push_back(lua_tonumber(L, 2));
|
args->push_back(lua_tonumber(L, i));
|
||||||
args.push_back(lua_tonumber(L, 3));
|
addManagedObject(L, is_static, OdeWorld::PLANE, args);
|
||||||
addManagedObject(L, is_static, OdeWorld::BOX, args);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
@ -378,16 +379,12 @@ namespace ag
|
|||||||
static int createCylinderSpecify(lua_State * L, bool is_static)
|
static int createCylinderSpecify(lua_State * L, bool is_static)
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
if (argc == 3 &&
|
if (argc == 2 && lua_isnumber(L, 1) && lua_isnumber(L, 2))
|
||||||
lua_isnumber(L, 1) &&
|
|
||||||
lua_isnumber(L, 2) &&
|
|
||||||
lua_isnumber(L, 3))
|
|
||||||
{
|
{
|
||||||
refptr< vector<float> > args = new vector<float>();
|
refptr< vector<float> > args = new vector<float>();
|
||||||
args.push_back(lua_tonumber(L, 1));
|
args->push_back(lua_tonumber(L, 1));
|
||||||
args.push_back(lua_tonumber(L, 2));
|
args->push_back(lua_tonumber(L, 2));
|
||||||
args.push_back(lua_tonumber(L, 3));
|
addManagedObject(L, is_static, OdeWorld::CYLINDER, args);
|
||||||
addManagedObject(L, is_static, OdeWorld::BOX, args);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
@ -406,6 +403,17 @@ namespace ag
|
|||||||
|
|
||||||
static int createCCylinderSpecify(lua_State * L, bool is_static)
|
static int createCCylinderSpecify(lua_State * L, bool is_static)
|
||||||
{
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 2 && lua_isnumber(L, 1) && lua_isnumber(L, 2))
|
||||||
|
{
|
||||||
|
refptr< vector<float> > args = new vector<float>();
|
||||||
|
args->push_back(lua_tonumber(L, 1));
|
||||||
|
args->push_back(lua_tonumber(L, 2));
|
||||||
|
addManagedObject(L, is_static, OdeWorld::CCYLINDER, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int createCCylinder(lua_State * L)
|
int createCCylinder(lua_State * L)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user