We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › the texture is distort
Page Index Toggle Pages: 1
the texture is distort (Read 575 times)
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
Re: the texture is distort
Reply #1 - Feb 7th, 2006, 12:57pm
 
It's a problem in P3D unfortunately.

See: http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1115241346;start=0#0
and
http://dev.processing.org/bugs/show_bug.cgi?id=103
Page Index Toggle Pages: 1