filled in Engine::Object::{get,set}Position()
git-svn-id: svn://anubis/anaglym/trunk@44 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
0753f243c5
commit
05858c0c22
9
ag.cc
9
ag.cc
@ -246,6 +246,7 @@ namespace ag
|
||||
position[i] = lua_tonumber(L, i + 2);
|
||||
}
|
||||
}
|
||||
obj->setPosition(position[0], position[1], position[2]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,9 +261,15 @@ namespace ag
|
||||
Engine::Object * obj = getObject(L, 1);
|
||||
if (obj != NULL)
|
||||
{
|
||||
double x, y, z;
|
||||
obj->getPosition(&x, &y, &z);
|
||||
lua_pushnumber(L, x);
|
||||
lua_pushnumber(L, y);
|
||||
lua_pushnumber(L, z);
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
return 3;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
anaglym.cc
19
anaglym.cc
@ -239,3 +239,22 @@ void Engine::Object::loadPhy(const std::string & path, bool static_data)
|
||||
{
|
||||
geoms = g_engine->m_world.loadPhy(path, &body, static_data);
|
||||
}
|
||||
|
||||
void Engine::Object::setPosition(double x, double y, double z)
|
||||
{
|
||||
if (body != 0)
|
||||
{
|
||||
dBodySetPosition(body, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::Object::getPosition(double * x, double * y, double * z)
|
||||
{
|
||||
if (body != 0)
|
||||
{
|
||||
const dReal * pos = dBodyGetPosition(body);
|
||||
*x = pos[0];
|
||||
*y = pos[1];
|
||||
*z = pos[2];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user