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 & HelpPrograms › Changing the vanishing point
Page Index Toggle Pages: 1
Changing the vanishing point (Read 788 times)
Changing the vanishing point
Jan 13th, 2010, 7:02am
 
Hi
I'm having a go at making a turn-the-page album. I've managed to turn one page; code below. When the turning "page" is facing me edge on, the perspective is unnaturally exaggerated. I think the solution is to push the vanishing point much further away.
Playing with the z value of translate (together with the image size) does not fix it.
Any ideas?
Thanks
string


Code:
//originated from
//TexturedCube by Dave Bollinger
PImage square1;
float rotY = 0.0;

void setup()
{
 size(400, 200, P3D);
 noStroke();
 
 square1 = loadImage("square01.jpg");
 textureMode(NORMALIZED);
}

void draw()
{
 background(255);
 
 translate(width/2, height/2, -100);
 rotateY(rotY);
 picturePage(square1);
}

void picturePage(PImage square1)
{
 beginShape(QUADS);
 texture(square1);  
 vertex(0, -100, 0, 0, 0);
 vertex(200, -100, 0, 1, 0);
 vertex(200, 100, 0, 1, 1);
 vertex(0, 100, 0, 0, 1);
 endShape();
}

void mouseMoved()
{
 rotY = map(mouseX, 0, width, -PI, 0);
}
Re: Changing the vanishing point
Reply #1 - Jan 13th, 2010, 7:27am
 
Take a look at perspective() and the zNear, zFar.
http://processing.org/reference/perspective_.html

Re: Changing the vanishing point
Reply #2 - Jan 13th, 2010, 9:39am
 
your quad gets very close to the camera eye, thus the exaggerated perspective.

a simple fix would be to arbitrarily squash z by adding something like scale(1,1,.5) right after translate(), then tune the ".5" to your liking

a more "correct" approach would be to push it further back in the scene (like translate z to -1000), then reduce the field of view with perspective().  analagous to a real camera with a telephoto lens on a distant object, will "flatten" perspective
Re: Changing the vanishing point
Reply #3 - Jan 14th, 2010, 1:08am
 
Thank you.
Changing the scale to scale(1, 1, 0.3) has given the best results.
string
Page Index Toggle Pages: 1