added ag::object::setTransparency() and Engine::Object::setTransparency()

git-svn-id: svn://anubis/anaglym/trunk@316 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2010-09-17 17:02:28 +00:00
parent 1a2213f39c
commit 11da99b3ad
4 changed files with 24 additions and 2 deletions

View File

@ -68,7 +68,11 @@ class Engine
m_color[0] = r;
m_color[1] = g;
m_color[2] = b;
m_color[3] = 1.0f;
render();
}
void setTransparency(float t)
{
m_color[3] = 1.0f - t;
render();
}
void setTexture(GLuint tex);

16
ag.cc
View File

@ -372,6 +372,8 @@ fail:
lua_setfield(L, -2, "addTorqueRel");
lua_pushcfunction(L, object::setColor);
lua_setfield(L, -2, "setColor");
lua_pushcfunction(L, object::setTransparency);
lua_setfield(L, -2, "setTransparency");
lua_pushcfunction(L, object::setGravityMode);
lua_setfield(L, -2, "setGravityMode");
lua_pushcfunction(L, object::setTexture);
@ -1443,6 +1445,20 @@ fail:
return 0;
}
int setTransparency(lua_State * L)
{
int argc = lua_gettop(L);
if (argc == 2 && lua_isnumber(L, 2))
{
Engine::Object * obj = getObject(L, 1);
if (obj != NULL)
{
obj->setTransparency(lua_tonumber(L, 2));
}
}
return 0;
}
int setGravityMode(lua_State * L)
{
int argc = lua_gettop(L);

1
ag.h
View File

@ -89,6 +89,7 @@ namespace ag
int setGravityMode(lua_State * L);
int setTexture(lua_State * L);
int setTextureScale(lua_State * L);
int setTransparency(lua_State * L);
int getMass(lua_State * L);
int setMass(lua_State * L);
int getAABB(lua_State * L);

View File

@ -3,9 +3,10 @@ function init_event()
ground = ag.createBox(8, 8, 0.1, {static = true})
ground:setTexture(checker_texture)
ag.setCamera(10, -10, 10, 0, 0, 0)
hilite = ag.createBox(2, 2, 0.1, {static = true})
hilite = ag.createBox(2, 2, 0.1, {static = true, enable_blending = true})
hilite:setColor(0.3, 0.5, 1)
hilite:setPosition(1, 1, 0.1)
hilite:setTransparency(0.4)
ag.setCursorVisible(true)
end