I will try and answer your various questions.
where did you get about the 1.0 and 0.0?
I tried it and it didn't work, look here there they also use the width of the image.Although you can use the image width and height to set texture coordinates this is not recommended -what if you want to use a texture of a different size you would need to alter all the vertex statements. By using
Code: textureMode(NORMAL);
we use the values 0 to 1 for texture coordinates - see my earlier post.
Note in my earlier post I used s and t whereas in the Processing documentation they use u and v which is more correct - so I will do the same.
In your code you have used 2 versions of vertex one with 4 parameters and one with 5 these correspond to
Code:
vertex(x1,y1,u1,v1);
vertex(x2,y2,z3,u2,v2);
Since we are using 3D then we need the one with 5 parameters.
P3D sucks, if I change to opengl then there is no strange texture protection.
must this be reported as a P3D bug? No - P3D uses Java 3D for rendering it is quicker than OPENGL but there are sacrifices to be made - poor texture mapping is one of them.
I think that just about covers it all you need now is the solution and here it is.
Code:
import peasy.*;
import processing.opengl.*;
PeasyCam cam;
PImage vloer;
PImage links;
PImage rechts;
PImage voor;
PImage achter;
void setup(){
size(1000, 1000, OPENGL);
cam = new PeasyCam(this, 1800);
cam.lookAt(0,0,0);
cam.setMinimumDistance(500);
cam.setMaximumDistance(2500);
smooth();
noStroke();
vloer = loadImage("vloer.png");
links = loadImage("links.png");
rechts = loadImage("rechts.png");
voor = loadImage("voor.png");
achter = loadImage("achter.png");
}
void draw(){
background(204);
textureMode(NORMAL);
pushMatrix();
beginShape(QUADS); //vloer
texture(vloer);
vertex(-500, -200, 500, 0, 0);
vertex(500, -200, 500, 1, 0);
vertex(500, -200, -500, 1, 1);
vertex(-500, -200, -500, 0, 1);
endShape();
beginShape(QUADS);
texture(links);
// -X "left" face
vertex(-500, -200, -500, 1, 1);
vertex(-500, -200, 500, 1, 0);
vertex(-500, 200, 500, 0, 0);
vertex(-500, 200, -500, 0, 1);
endShape();
beginShape(QUADS);
texture(achter);
// +X "right" face
vertex( 500, -200, 500, 0, 0);
vertex( 500, -200, -500, 1, 0);
vertex( 500, 200, -500, 1, 1);
vertex( 500, 200, 500, 0, 1);
endShape();
beginShape(QUADS);
texture(rechts);
// +Z "front" face
vertex(-500, -200, 500, 0, 0);
vertex( 500, -200, 500, 1, 0);
vertex( 500, 200, 500, 1, 1);
vertex(-500, 200, 500, 0, 1);
endShape();
beginShape(QUADS);
texture(voor);
// -Z "back" face
vertex( 500, -200, -500, 0, 0);
vertex(-500, -200, -500, 1, 0);
vertex(-500, 200, -500, 1, 1);
vertex( 500, 200, -500, 0, 1);
endShape();
popMatrix();
}
I have centered the shoebox arround the origin (0,0,0) to simplify the rotation.
You can rotate the textures by 'rotating' the u/v coordinates within the 4 vextors that make up the shape