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 › How do you invert the y axis
Page Index Toggle Pages: 1
How do you invert the y axis? (Read 1092 times)
How do you invert the y axis?
Mar 25th, 2008, 9:14pm
 
I've been using 3d apps for over a decade and am used to having the positive direction on the y axis point up.  Is there any way to change processing's coordinate system so that it behaves that way, or is that more trouble than it's worth?
Re: How do you invert the y axis?
Reply #1 - Mar 25th, 2008, 10:23pm
 
when using the camera command;

camera(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ)

on the upY parameter, pass -1, instead of 1

however, it ends up being a bit too much effort, because things will appear upside down, and you'll just have to flip everything you import

I'd say it's easier to just get used to it.
Re: How do you invert the y axis?
Reply #2 - Mar 26th, 2008, 3:14pm
 
or scale(1,-1,1)
Re: How do you invert the y axis?
Reply #3 - Mar 26th, 2008, 9:44pm
 
that'll fix the translations but the coordinate space is still inverted. screw it, i'll just get used to it.
Re: How do you invert the y axis?
Reply #4 - Mar 27th, 2008, 12:51am
 
Yeah. I guess that's the best way. It's not that hard to get used to it, although I know it takes some time. I too was used to Y axis growing upwards, and now I just make sure to add when going downwards and substract when going upwards.
Re: How do you invert the y axis?
Reply #5 - Mar 27th, 2008, 3:52pm
 
sgsrules wrote on Mar 26th, 2008, 9:44pm:
that'll fix the translations but the coordinate space is still inverted. screw it, i'll just get used to it.


I probably misunderstood what you're after, but once you invert the y scale coordinates will appear inverted, subsequent transforms are inverted, etc.  Try the following example with/without the call to scale(), isn't that what you want

Quote:


import processing.opengl.*;

void setup() {
 size(400,400,OPENGL);
}

void draw() {
 background(0);
 translate(width/2f, height/2f, 0f); // put 0,0 at screen center
 scale(1,-1,1); // flip y axis
 // draw positive axes saturated
 stroke(255,0,0);
 line(0,0,0, 100,0,0); // +x red
 stroke(0,255,0);
 line(0,0,0, 0,100,0); // +y green (points UP when inverted)
 // draw negative axes desaturated
 stroke(192,128,128);
 line(0,0,0, -100,0,0); // -x pink
 stroke(128,192,128);
 line(0,0,0, 0,-100,0); // -y ltgreen (points DOWN when inverted)
}
Page Index Toggle Pages: 1