added setPosition() for Quads
This commit is contained in:
parent
1009f91302
commit
bece35d270
@ -1347,6 +1347,7 @@ Engine::Quad::Quad(float cx, float cy, float cz,
|
|||||||
m_texture = 0;
|
m_texture = 0;
|
||||||
m_enable_blending = false;
|
m_enable_blending = false;
|
||||||
m_color[0] = m_color[1] = m_color[2] = m_color[3] = 1.0f;
|
m_color[0] = m_color[1] = m_color[2] = m_color[3] = 1.0f;
|
||||||
|
m_position[0] = m_position[1] = m_position[2] = 0.0f;
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,6 +1386,8 @@ int Engine::Quad::render()
|
|||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(m_position[0], m_position[1], m_position[2]);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glNormal3f(m_normal[0], m_normal[1], m_normal[2]);
|
glNormal3f(m_normal[0], m_normal[1], m_normal[2]);
|
||||||
glVertex3f(m_center[0] + m_v1[0] + m_v2[0],
|
glVertex3f(m_center[0] + m_v1[0] + m_v2[0],
|
||||||
@ -1400,6 +1403,7 @@ int Engine::Quad::render()
|
|||||||
m_center[1] + m_v1[1] - m_v2[1],
|
m_center[1] + m_v1[1] - m_v2[1],
|
||||||
m_center[2] + m_v1[2] - m_v2[2]);
|
m_center[2] + m_v1[2] - m_v2[2]);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
glPopMatrix();
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
glEndList();
|
glEndList();
|
||||||
return m_dl;
|
return m_dl;
|
||||||
|
8
Engine.h
8
Engine.h
@ -173,6 +173,13 @@ class Engine
|
|||||||
m_offset = f;
|
m_offset = f;
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
void setPosition(float x, float y, float z)
|
||||||
|
{
|
||||||
|
m_position[0] = x;
|
||||||
|
m_position[1] = y;
|
||||||
|
m_position[2] = z;
|
||||||
|
render();
|
||||||
|
}
|
||||||
void setTexture(int t)
|
void setTexture(int t)
|
||||||
{
|
{
|
||||||
m_texture = t;
|
m_texture = t;
|
||||||
@ -200,6 +207,7 @@ class Engine
|
|||||||
int m_texture;
|
int m_texture;
|
||||||
bool m_enable_blending;
|
bool m_enable_blending;
|
||||||
float m_color[4];
|
float m_color[4];
|
||||||
|
float m_position[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine(const std::string & path, AV & av);
|
Engine(const std::string & path, AV & av);
|
||||||
|
21
ag.cc
21
ag.cc
@ -740,6 +740,8 @@ fail:
|
|||||||
lua_setfield(L, -2, "setColor");
|
lua_setfield(L, -2, "setColor");
|
||||||
lua_pushcfunction(L, quad::setOffset);
|
lua_pushcfunction(L, quad::setOffset);
|
||||||
lua_setfield(L, -2, "setOffset");
|
lua_setfield(L, -2, "setOffset");
|
||||||
|
lua_pushcfunction(L, quad::setPosition);
|
||||||
|
lua_setfield(L, -2, "setPosition");
|
||||||
lua_pushcfunction(L, quad::setTexture);
|
lua_pushcfunction(L, quad::setTexture);
|
||||||
lua_setfield(L, -2, "setTexture");
|
lua_setfield(L, -2, "setTexture");
|
||||||
lua_pushcfunction(L, quad::setVisible);
|
lua_pushcfunction(L, quad::setVisible);
|
||||||
@ -1697,6 +1699,25 @@ fail:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setPosition(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 4 && lua_istable(L, 1)
|
||||||
|
&& lua_isnumber(L, 2)
|
||||||
|
&& lua_isnumber(L, 3)
|
||||||
|
&& lua_isnumber(L, 4))
|
||||||
|
{
|
||||||
|
Engine::Quad * q = getQuad(L, 1);
|
||||||
|
if (q != NULL)
|
||||||
|
{
|
||||||
|
q->setPosition(lua_tonumber(L, 2),
|
||||||
|
lua_tonumber(L, 3),
|
||||||
|
lua_tonumber(L, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int setTexture(lua_State * L)
|
int setTexture(lua_State * L)
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
|
1
ag.h
1
ag.h
@ -104,6 +104,7 @@ namespace ag
|
|||||||
int setBlending(lua_State * L);
|
int setBlending(lua_State * L);
|
||||||
int setColor(lua_State * L);
|
int setColor(lua_State * L);
|
||||||
int setOffset(lua_State * L);
|
int setOffset(lua_State * L);
|
||||||
|
int setPosition(lua_State * L);
|
||||||
int setTexture(lua_State * L);
|
int setTexture(lua_State * L);
|
||||||
int setVisible(lua_State * L);
|
int setVisible(lua_State * L);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user