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.
Page Index Toggle Pages: 1
Up vector bug? (Read 602 times)
Up vector bug?
May 15th, 2006, 12:46am
 
I've been experimenting with using the camera() function to navigate around a sketch.  Apparently I don't understand the Up vector .. or possibly there's a bug??

Here's a test of the Up vector, simplified as much as I could do:
 http://www.backspaces.net/files/testcam0/applet/

Note that if you have the java console up, you'll see the modified Up vector as you use the x,y,z and - keys to test the camera() function.

Here's what I think I'm doing: drawing a box and rect, with X,Y,Z axes drawn and labeled.  We use
 camera(width,width,width,  0,0,0,  upX,upY,upZ);
with upX,upY,upZ being set by keystrokes and starting with 0,0,1.

It seems to me that the results are "backwards" from my expectation .. I'd presume a +1 upZ would give me the Z axis pointing up rather than the down I end up with.  Ditto with the others.  The "eye" and "center" coordinates do seem to do what I'd expect .. so I guess I'm just confused by the Up vector.

Is this the way its supposed to work?

Owen

Here's the code, or just look at the source in the applet:

float upX=0f, upY=0f, upZ=1f;

void setup() {
 size(500, 500, P3D);
 textFont(loadFont("AmericanTypewriter-Bold-24.vlw"));
 framerate(5);
}
void draw() {
 background(200);
 stroke(0);
 fill(255);
 camera(width,width,width,  0,0,0,  upX,upY,upZ);

 box(100, 100, 100);
 rect(-200,-200,400,400);

 float len = width/2;
 line(0,0,0,len,0,0);
 line(0,0,0,0,len,0);
 line(0,0,0,0,0,len);
 fill(color(255,0,0));
 text("X",len,0,0);
 text("Y",0,len,0);
 text("Z",0,0,len);
}
void keyPressed() {
 switch(key) {
 case 'x': upX=1f; upY=0f; upZ=0f; break;
 case 'y': upX=0f; upY=1f; upZ=0f; break;
 case 'z': upX=0f; upY=0f; upZ=1f; break;
 case '-': upX=-upX; upY=-upY; upZ=-upZ; break;
 }
 println("Up vector: ["+upX+" "+upY+" "+upZ+"]");
}
Re: Up vector bug?
Reply #1 - May 15th, 2006, 2:31am
 
nah, not a bug. i think you're just not understanding how it works.
Re: Up vector bug?
Reply #2 - May 15th, 2006, 3:55am
 
OK, how's it work?   Smiley

Pointers appreciated.  I looked at
http://glprogramming.com/red/chapter03.html

It seemed that the up-vector specified there was the same as I tried in my experiment.

Owen
Page Index Toggle Pages: 1