We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Texture tiling (Read 615 times)
Texture tiling
Oct 24th, 2005, 12:02pm
 
Hello Everyone

I am having the following problem. I nead to tile a texture but when I get to the end of the image the remaining polygons are rendered with the entire texture flipped.

as can be seen in the following image http://kisd.de/~stephen/TextureTile.jpg

This happens because when the left hand vertext is 240px and the right hand vertext is 10px the texture from left to right backward from 240px to 10px. This is not what I would like. I would like the image to be rendered from 250 to 256 and then from 0px to 10px.


Below is my source code. I would be very greatfull if someone could provide so insite into how I may achieve my goal.

Kind regards,
Stephen

void setup(){
size(1200,800,P3D);

noStroke();
PImage a = loadImage("image.jpg");
beginShape(TRIANGLES);
texture(a);
// "arch.jpg" is 100x100 pixels in size so
// the values 0 and 100 are used for the
// parameters "u" and "v" to map it directly
// to the vertex points
float texScale = 0.25;
for(int x=0; x<15;x++){
 for(int y=0; y<10;y++){
   vertex(100*x, 100*y, ((100*x)/texScale)%a.width, (100*y)/texScale%a.height);
   vertex(100+100*x, 100*y, ((100*x+100)/texScale)%a.width, (100*y)/texScale%a.height);
   vertex(100+100*x, 100+100*y, ((100*x+100)/texScale)%a.width, (100*y+100)/texScale%a.height);
   println(((x*100+100)));

   vertex(100*x, 100*y, ((100*x)/texScale)%a.width, (100*y)/texScale%a.height);
   vertex(100+100*x, 100+100*y, ((100*x+100)/texScale)%a.width, (100*y+100)/texScale%a.height);
   vertex(100*x, 100+100*y, ((100*x)/texScale)%a.width, (100*y+100)/texScale%a.height);
 }
}


endShape();


noFill();
stroke(255);
beginShape(TRIANGLES);
for(int x=0; x<15;x++){
 for(int y=0; y<10;y++){
   vertex(100*x, 100*y);
   vertex(100+100*x, 100*y);
   vertex(100+100*x, 100+100*y);
   println(((x*100+100)));

   vertex(100*x, 100*y);
   vertex(100+100*x, 100+100*y);
   vertex(100*x, 100+100*y);
 }
}
endShape();


}
Page Index Toggle Pages: 1