add scale factor to obj shader and scale tank object up

This commit is contained in:
Josh Holtrop 2012-09-08 00:15:41 -04:00
parent abb0d99553
commit 22b52f5fcc
2 changed files with 7 additions and 4 deletions

View File

@ -1,4 +1,6 @@
uniform float scale;
attribute vec3 pos; attribute vec3 pos;
attribute vec3 normal; attribute vec3 normal;
@ -7,7 +9,7 @@ varying vec3 normal_i;
void main(void) void main(void)
{ {
gl_Position = gl_ModelViewProjectionMatrix * vec4(pos, 1); gl_Position = gl_ModelViewProjectionMatrix * vec4(scale * pos, 1);
pos_i = gl_Position.xyz; pos_i = gl_Position.xyz;
normal_i = gl_NormalMatrix * normal; normal_i = gl_NormalMatrix * normal;
} }

View File

@ -183,9 +183,9 @@ void Client::update(double elapsed_time)
void Client::draw_players() void Client::draw_players()
{ {
GLint uniform_locations[4]; GLint uniform_locations[5];
const char *uniforms[] = { "ambient", "diffuse", "specular", "shininess" }; const char *uniforms[] = { "ambient", "diffuse", "specular", "shininess", "scale" };
m_obj_program.get_uniform_locations(uniforms, 4, uniform_locations); m_obj_program.get_uniform_locations(uniforms, 5, uniform_locations);
glPushMatrix(); glPushMatrix();
glTranslatef(m_player->x, m_player->y, 40); glTranslatef(m_player->x, m_player->y, 40);
glRotatef(m_player->direction * 180.0 / M_PI, 0, 0, 1); glRotatef(m_player->direction * 180.0 / M_PI, 0, 0, 1);
@ -198,6 +198,7 @@ void Client::draw_players()
stride, (GLvoid *) m_tank_obj.getVertexOffset()); stride, (GLvoid *) m_tank_obj.getVertexOffset());
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE,
stride, (GLvoid *) m_tank_obj.getNormalOffset()); stride, (GLvoid *) m_tank_obj.getNormalOffset());
glUniform1f(uniform_locations[4], 20.0f);
for (map<string, WFObj::Material>::iterator it = for (map<string, WFObj::Material>::iterator it =
m_tank_obj.getMaterials().begin(); m_tank_obj.getMaterials().begin();
it != m_tank_obj.getMaterials().end(); it != m_tank_obj.getMaterials().end();