chronophile
03-02-2010, 10:17 PM
Hi, I'm trying to wrap an image around a cylinder (30 sided for this example). I have the image correctly loaded and the parameters/settings are correct, but I'm making a mistake somewhere with my textcoords. The code snippet is the loop that makes the sides of the cylinder that I'm trying to wrap around. Right now it displays the image separately on each rectangle like so:
http://s803.photobucket.com/albums/yy315...pg&newest=1 (http://s803.photobucket.com/albums/yy315/Chronophile/?action=view&current=Capture-1.jpg&newest=1)
I also tried to divide the u coordinate (of the u,v pair) by 30, the number of sides but that gave me this:
http://s803.photobucket.com/albums/yy315...pg&newest=1 (http://s803.photobucket.com/albums/yy315/Chronophile/?action=view&current=Capture-2.jpg&newest=1)
So I guess I can't figure how to make the image partition between the rectangular sides of the cylinder. Any ideas?
for(double angle = 0; angle < 360; angle+=12){
if (count1 > nfaces) break;
double next_point = 0;
next_point = angle+face_div;
glBegin(GL_QUADS);
normals
if (smooth == false){
if(texture == true) glTexCoord2f(count1, 0);
glVertex3d(cos((double)((next_point)*PI/180))*rt, len/2, sin((double)((next_point)*PI/180))*rt);
if(texture == true) glTexCoord2f((count1+1), 0);
glVertex3d(cos((double)(angle*PI/180))*rt, len/2, sin((double)(angle*PI/180))*rt);
if(texture == true) glTexCoord2f((count1+1), 1);
glVertex3d(cos((double)(angle*PI/180))*rt, -len/2, sin((double)(angle*PI/180))*rt);
if(texture == true) glTexCoord2f(count1, 1);
glVertex3d(cos((double)((next_point)*PI/180))*rt, -len/2, sin((double)((next_point)*PI/180))*rt);
}
glEnd();
++count1;
}
http://s803.photobucket.com/albums/yy315...pg&newest=1 (http://s803.photobucket.com/albums/yy315/Chronophile/?action=view&current=Capture-1.jpg&newest=1)
I also tried to divide the u coordinate (of the u,v pair) by 30, the number of sides but that gave me this:
http://s803.photobucket.com/albums/yy315...pg&newest=1 (http://s803.photobucket.com/albums/yy315/Chronophile/?action=view&current=Capture-2.jpg&newest=1)
So I guess I can't figure how to make the image partition between the rectangular sides of the cylinder. Any ideas?
for(double angle = 0; angle < 360; angle+=12){
if (count1 > nfaces) break;
double next_point = 0;
next_point = angle+face_div;
glBegin(GL_QUADS);
normals
if (smooth == false){
if(texture == true) glTexCoord2f(count1, 0);
glVertex3d(cos((double)((next_point)*PI/180))*rt, len/2, sin((double)((next_point)*PI/180))*rt);
if(texture == true) glTexCoord2f((count1+1), 0);
glVertex3d(cos((double)(angle*PI/180))*rt, len/2, sin((double)(angle*PI/180))*rt);
if(texture == true) glTexCoord2f((count1+1), 1);
glVertex3d(cos((double)(angle*PI/180))*rt, -len/2, sin((double)(angle*PI/180))*rt);
if(texture == true) glTexCoord2f(count1, 1);
glVertex3d(cos((double)((next_point)*PI/180))*rt, -len/2, sin((double)((next_point)*PI/180))*rt);
}
glEnd();
++count1;
}