backspaces
Junior Member
Offline
Posts: 66
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+"]"); }