float u_size = 1;
float v_size = 1;
- if(tex_fit!=STRETCH)
- {
- if((l1<l2)==(tex_fit==CUT))
- u_size = l1/l2;
- else
- v_size = l2/l1;
- }
+ adjust_texture_scale(u_size, v_size, l1, l2);
builder.begin(TRIANGLE_STRIP);
builder.texcoord(0, v_size);
{
float u_scale = 1.0/segments;
float v_scale = 1/(length+radius*M_PI);
- if(tex_fit!=STRETCH)
- {
- float l1 = radius*M_PI*2;
- float l2 = length+radius*M_PI;
- if((l1<l2)==(tex_fit==CUT))
- u_scale *= l1/l2;
- else
- v_scale *= l2/l1;
- }
+ adjust_texture_scale(u_scale, v_scale, radius*M_PI*2, length+radius*M_PI);
builder.normal(0, 0, -1);
builder.texcoord(0.5, 0);
for(unsigned i=1; i<rings; ++i)
{
float cz = length*(i>rings/2 ? 0.5 : -0.5);
- float v = (i*radius*M_PI/rings+(i>rings/2 ? length : 0))*v_scale;
+ float v = ((i>rings/2 ? i-1 : i)*radius*M_PI/(rings-1)+(i>rings/2 ? length : 0))*v_scale;
float ra = (i>rings/2 ? i-1 : i)*M_PI/(rings-1);
float rc = cos(ra);
float rs = sin(ra);