I'm trying to render floortiles in opengl/processing3.
Here's my code:
PImage floorImage;
void setup() {
size(1200, 600, P3D);
smooth(8);
floorImage = loadImage("floor3.png");
}
void draw() {
background(0);
ambientLight(255,255,255);
camera(0.0,100.0,-300.0,mouseX-width/2.0,-(mouseY-height/2.0),0.0,0.0,-1.0,0.0);
for(int x=-20;x<20;x++)
{
for(int z=-20;z<20;z++)
{
pushMatrix();
translate(x*32.0,0.0,z*32.0);
beginShape();
textureMode(NORMAL);
texture(floorImage);
vertex(-32.0,0.0,-32.0,0.0,0.0);
vertex(32.0,0.0,-32.0,1.0,0.0);
vertex(32.0,0.0,32.0,1.0,1.0);
vertex(-32.0,0.0,32.0,0.0,1.0);
endShape(CLOSE);
popMatrix();
}
}
}
The end result, however, looks terrible!
Why?
Looks like you have quad size = 64, but you move it by 32 in x and z directions.I think you have intersections here. Try to replace to this:
translate(x*64.0,0.0,z*64.0);