added visibility flag to Engine::Object and ag::object::setVisible() to control it
git-svn-id: svn://anubis/anaglym/trunk@68 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
207f7e628a
commit
792e087885
16
ag.cc
16
ag.cc
@ -115,6 +115,8 @@ namespace ag
|
||||
lua_setfield(L, -2, "clone");
|
||||
lua_pushcfunction(L, object::destroy);
|
||||
lua_setfield(L, -2, "destroy");
|
||||
lua_pushcfunction(L, object::setVisible);
|
||||
lua_setfield(L, -2, "setVisible");
|
||||
}
|
||||
|
||||
static int loadModelSpecify(lua_State * L, bool static_data)
|
||||
@ -347,5 +349,19 @@ namespace ag
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setVisible(lua_State * L)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
if (argc == 2)
|
||||
{
|
||||
Engine::Object * obj = getObject(L, 1);
|
||||
if (obj != NULL && lua_isboolean(L, 2))
|
||||
{
|
||||
obj->setVisible(lua_toboolean(L, 2));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
ag.h
1
ag.h
@ -26,6 +26,7 @@ namespace ag
|
||||
int getPosition(lua_State * L);
|
||||
int clone(lua_State * L);
|
||||
int destroy(lua_State * L);
|
||||
int setVisible(lua_State * L);
|
||||
}
|
||||
}
|
||||
|
||||
|
21
anaglym.cc
21
anaglym.cc
@ -355,10 +355,12 @@ Engine::Object::Object(bool is_static, OdeWorld & world, GLuint dl)
|
||||
m_display_list = dl;
|
||||
m_display_list_refcnt = new int;
|
||||
*m_display_list_refcnt = 1;
|
||||
m_is_visible = true;
|
||||
}
|
||||
|
||||
Engine::Object::Object(const Engine::Object & orig)
|
||||
{
|
||||
m_is_visible = orig.m_is_visible;
|
||||
m_ode_object = new OdeWorld::Object(*orig.m_ode_object);
|
||||
m_display_list = orig.m_display_list;
|
||||
m_display_list_refcnt = orig.m_display_list_refcnt;
|
||||
@ -379,15 +381,18 @@ Engine::Object::~Object()
|
||||
|
||||
void Engine::Object::draw()
|
||||
{
|
||||
const dReal * pos = m_ode_object->getPosition();
|
||||
const dReal * rot = m_ode_object->getRotation();
|
||||
bool transform = (pos != NULL && rot != NULL);
|
||||
if (m_is_visible)
|
||||
{
|
||||
const dReal * pos = m_ode_object->getPosition();
|
||||
const dReal * rot = m_ode_object->getRotation();
|
||||
bool transform = (pos != NULL && rot != NULL);
|
||||
|
||||
if (transform)
|
||||
OdeWorld::pushTransform(pos, rot);
|
||||
if (transform)
|
||||
OdeWorld::pushTransform(pos, rot);
|
||||
|
||||
glCallList(m_display_list);
|
||||
glCallList(m_display_list);
|
||||
|
||||
if (transform)
|
||||
glPopMatrix();
|
||||
if (transform)
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ class Engine
|
||||
{
|
||||
m_ode_object->loadPhy(path);
|
||||
}
|
||||
void setVisible(bool visible) { m_is_visible = visible; }
|
||||
bool getVisible() { return m_is_visible; }
|
||||
|
||||
void draw();
|
||||
|
||||
@ -40,6 +42,7 @@ class Engine
|
||||
OdeWorld::Object * m_ode_object;
|
||||
GLuint m_display_list;
|
||||
int * m_display_list_refcnt;
|
||||
bool m_is_visible;
|
||||
};
|
||||
|
||||
Engine();
|
||||
|
@ -1,10 +1,5 @@
|
||||
|
||||
function update()
|
||||
elapsed = ag.elapsedTime()
|
||||
if (elapsed > 2000 and ball2there) then
|
||||
ball2:destroy()
|
||||
ball2there = false
|
||||
end
|
||||
ballx, bally, ballz = ball:getPosition()
|
||||
ag.setCamera(7, -6, 15, ballx, bally, ballz, 0, 0, 1)
|
||||
ag.doPhysics()
|
||||
@ -15,11 +10,11 @@ end
|
||||
|
||||
--ag.setCamera(8, -8, 15, -8, 8, 4, 0, 0, 1)
|
||||
arena = ag.loadStaticModel("boxarena")
|
||||
arena:setVisible(false)
|
||||
ball = ag.loadModel("ball")
|
||||
ball:setPosition(-7, 7.4, 12)
|
||||
ball2 = ball:clone()
|
||||
ball2:setPosition(-7, 7.4, 14)
|
||||
ball2there = true
|
||||
ball3 = ball:clone()
|
||||
ball3:setPosition(-7, 7.4, 16)
|
||||
logo = ag.loadModel("dwlogo")
|
||||
|
Loading…
x
Reference in New Issue
Block a user