Bug 145 : "up" vector in camera inverted
Last modified: 2005-09-07 07:52




Status:
RESOLVED
Resolution:
WONTFIX -
Priority:
P2
Severity:
normal

 

Reporter:
JohnG
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2005-09-06 08:22
(unable to select version from dropdown box, so included in title)

When using the camera(...) function, the up vector appears to be being
interpreted wrongly.

The example code draws the 3 principal axes, x (in red), y (in green) and z
(in blue)
The camera is set to rotate around the origin, whilst looking at the origin.

The camera sits 200 units above the z=0 plane whilst rotating, and the up
vector is set to be +z, however the "up" z axis, is downwards on screen.
Change the 0,0,1 in the camera to be 0,0,-1 and then the up blue z axis
goes upwards on screen.

This behaviour is consistent across P3D and OPENGL modes.

Example code:

float rotation;
void setup()
{
size(400,400,P3D);
rotation=0;
}
void draw()
{
background(0);
rotation+=0.03;
camera(400*sin(rotation),400*cos(rotation),200,0,0,0,0,0,1);
beginShape(LINES);
stroke(255,0,0);
vertex(0,0,0);
vertex(100,0,0);
stroke(0,255,0);
vertex(0,0,0);
vertex(0,100,0);
stroke(0,0,255);
vertex(0,0,0);
vertex(0,0,100);
endShape();
}
Additional Comment #1 From fry 2005-09-07 06:29
you know that y increases going downwards (2D graphics style) rather than up (3D graphics
style) right? or is there something else going on here?

reference about coordinate system:
http://processing.org/reference/environment/index.html#Coordinates
Additional Comment #2 From JohnG 2005-09-07 07:23
I was assuming that in 3D mode, 3D conventions would be the "correct" way
of handling the co-ordinate system.

As far as I know, all 3D environments have either Y or Z (whichever they
use for "up") to go up the screen, and it's only in 2D space that Y is
down, for low-level reasons.
Additional Comment #3 From fry 2005-09-07 07:52
right, but the difference is that we're mixing 2D and 3D, and because our
audience is primarily coming from 2D, we can't just switch an axis when
you're in one mode versus the other.

thanks for teh complete report and example, at any rate.. this is just the
sort of thing i need to track things down properly.