OK guys, I have been using P3D and I’m trying to render multiple minecraft grass blocks using a for loop. I have a for loop in draw that runs this function, increasing x each iteration:
void makeTexturedCube(PImage pix,PImage pix2,PImage pix3,PImage pix4,PImage pix5,PImage pix6, float ix, float iy, float iz) {
translate(width/2.0, height/2.0, 500);
rotateX(rotx);
rotateY(roty);
scale(90);
float x = ix * 2;
float y = iy * 2;
float z = iz * 2;
beginShape(QUADS);
texture(pix2);
// +Z "front" face
vertex(-1+x, -1+y, 1+z, 0, 0);
vertex( 1+x, -1+y, 1+z, 1, 0);
vertex( 1+x, 1+y, 1+z, 1, 1);
vertex(-1+x, 1+y, 1+z, 0, 1);
endShape();
beginShape(QUADS);
texture(pix4);
// -Z "back" face
vertex( 1+x, -1+y, -1+z, 0, 0);
vertex(-1+x, -1+y, -1+z, 1, 0);
vertex(-1+x, 1+y, -1+z, 1, 1);
vertex( 1+x, 1+y, -1+z, 0, 1);
endShape();
beginShape(QUADS);
texture(pix6);
// +Y "bottom" face
vertex(-1+x, 1+y, 1+z, 0, 0);
vertex( 1+x, 1+y, 1+z, 1, 0);
vertex( 1+x, 1+y, -1+z, 1, 1);
vertex(-1+x, 1+y, -1+z, 0, 1);
endShape();
beginShape(QUADS);
texture(pix);
// -Y "top" face
vertex(-1+x, -1+y, -1+z, 0, 0);
vertex( 1+x, -1+y, -1+z, 1, 0);
vertex( 1+x, -1+y, 1+z, 1, 1);
vertex(-1+x, -1+y, 1+z, 0, 1);
endShape();
beginShape(QUADS);
texture(pix3);
// +X "right" face
vertex( 1+x, -1+y, 1+z, 0, 0);
vertex( 1+x, -1+y, -1+z, 1, 0);
vertex( 1+x, 1+y, -1+z, 1, 1);
vertex( 1+x, 1+y, 1+z, 0, 1);
endShape();
beginShape(QUADS);
texture(pix5);
// -X "left" face
vertex(-1+x, -1+y, -1+z, 0, 0);
vertex(-1+x, -1+y, 1+z, 1, 0);
vertex(-1+x, 1+y, 1+z, 1, 1);
vertex(-1+x, 1+y, -1+z, 0, 1);
endShape();
}
I can’t seem for the life of me to figure out why it only renders one!
Thanks for any advice anyone gives
– kokomoko