willy
YaBB Newbies
Offline
Posts: 7
the texture is distort
Feb 6th , 2006, 11:53pm
hi i have modified the RGBcube to show you the problem. here is the code: float xmag, ymag = 0; float newXmag, newYmag = 0; PImage a; void setup() { size(200, 200, P3D); noStroke(); colorMode(RGB, 1); noStroke(); a = loadImage("picture.jpg"); } void draw() { background(0.5, 0.5, 0.45); pushMatrix(); translate(width/2, height/2, -30); newXmag = mouseX/float(width) * TWO_PI; newYmag = mouseY/float(height) * TWO_PI; float diff = xmag-newXmag; if (abs(diff) > 0.01) { xmag -= diff/4.0; } diff = ymag-newYmag; if (abs(diff) > 0.01) { ymag -= diff/4.0; } rotateX(-ymag); rotateY(-xmag); scale(50); beginShape(QUADS); texture(a); vertex(-1, 1, 1, 0, 0); vertex( 1, 1, 1, 700, 0); vertex( 1, -1, 1, 700, 700); vertex(-1, -1, 1, 0, 700); endShape(); beginShape(QUADS); fill(1, 1, 1); vertex( 1, 1, 1); fill(1, 1, 0); vertex( 1, 1, -1); fill(1, 0, 0); vertex( 1, -1, -1); fill(1, 0, 1); vertex( 1, -1, 1); fill(1, 1, 0); vertex( 1, 1, -1); fill(0, 1, 0); vertex(-1, 1, -1); fill(0, 0, 0); vertex(-1, -1, -1); fill(1, 0, 0); vertex( 1, -1, -1); fill(0, 1, 0); vertex(-1, 1, -1); fill(0, 1, 1); vertex(-1, 1, 1); fill(0, 0, 1); vertex(-1, -1, 1); fill(0, 0, 0); vertex(-1, -1, -1); fill(0, 1, 0); vertex(-1, 1, -1); fill(1, 1, 0); vertex( 1, 1, -1); fill(1, 1, 1); vertex( 1, 1, 1); fill(0, 1, 1); vertex(-1, 1, 1); fill(0, 0, 0); vertex(-1, -1, -1); fill(1, 0, 0); vertex( 1, -1, -1); fill(1, 0, 1); vertex( 1, -1, 1); fill(0, 0, 1); vertex(-1, -1, 1); endShape(); popMatrix(); } you can see that the picture distorts if you rotate the cube. what is the misstake here? mfg willy