diff --git a/Engine.cc b/Engine.cc
index 6ec8e89..452950c 100644
--- a/Engine.cc
+++ b/Engine.cc
@@ -1023,6 +1023,7 @@ Engine::Object::Object(bool is_static, OdeWorld & world,
for (int i = 0; i < 4; i++)
m_color[i] = 1.0f;
m_texture = 0;
+ m_texture_scale = 1.0f;
createManagedObject();
}
@@ -1045,6 +1046,7 @@ Engine::Object::Object(const Engine::Object & orig)
for (int i = 0; i < 4; i++)
m_color[i] = orig.m_color[i];
m_texture = orig.m_texture;
+ m_texture_scale = orig.m_texture_scale;
if (m_is_managed)
render();
}
@@ -1182,7 +1184,8 @@ void Engine::Object::render()
{
if (m_texture != 0)
{
- glTexCoord2fv(tex_coords[v]);
+ glTexCoord2f(tex_coords[v][0] * m_texture_scale,
+ tex_coords[v][1] * m_texture_scale);
}
glVertex3f(sides[s].verts[v][0] * width / 2.0,
sides[s].verts[v][1] * depth / 2.0,
@@ -1269,12 +1272,12 @@ void Engine::Object::render()
float half_span = num_sections * section_size / 2.0;
float x_c = x * section_size - half_span;
float y_c = y * section_size - half_span;
- glTexCoord2f(0.0, y);
+ glTexCoord2f(0.0, y * m_texture_scale);
glVertex3f(x_o + rotated_x[0] * x_c + rotated_y[0] * y_c,
y_o + rotated_x[1] * x_c + rotated_y[1] * y_c,
z_o + rotated_x[2] * x_c + rotated_y[2] * y_c);
x_c += section_size;
- glTexCoord2f(1.0, y);
+ glTexCoord2f(1.0, y * m_texture_scale);
glVertex3f(x_o + rotated_x[0] * x_c + rotated_y[0] * y_c,
y_o + rotated_x[1] * x_c + rotated_y[1] * y_c,
z_o + rotated_x[2] * x_c + rotated_y[2] * y_c);
diff --git a/Engine.h b/Engine.h
index 02f98ef..c7cf793 100644
--- a/Engine.h
+++ b/Engine.h
@@ -68,6 +68,10 @@ class Engine
render();
}
void setTexture(GLuint tex);
+ void setTextureScale(float scale)
+ {
+ m_texture_scale = scale;
+ }
void draw();
dReal getMass() { return m_ode_object->getMass(); }
void setMass(dReal mass) { m_ode_object->setMass(mass); }
@@ -93,6 +97,7 @@ class Engine
refptr< std::vector
obj:setTextureScale(scale)
++This function sets the "texture scale" for obj. +Currently, texture scaling is only supported for boxes and planes. +scale actually scales the texture coordinates. +Hence a scale of 4 would appear to shrink the texture by a factor of +4 and tile the texture 16 times where it normally would have once. +
+obj:setVisible(visible_flag)