2016-08-05 19 views
1

我想在opengl/processing3中渲染floortiles。我的紋理渲染出了什麼問題?

這裏是我的代碼:

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(); 
    } 
    } 
} 

而這裏的質地: tile texture

最終的結果,但是,看起來很可怕!

results with artefacts

爲什麼?

回答

2

看起來你有四倍大小= 64,但你在x和z方向上移動它32。我認爲你在這裏有交點。試圖取代到這一點:

translate(x*64.0,0.0,z*64.0); 
+0

jeez,多麼愚蠢,謝謝! – monoceres

+0

當然,打我吧。有一個upvote。 –