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 › Camera Question - the three UP variables
Page Index Toggle Pages: 1
Camera Question - the three UP variables (Read 1566 times)
Camera Question - the three UP variables
Jun 5th, 2005, 6:54am
 
What do the three up variables do when setting up a camera?

Quote:
camera(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ)
   
Parameters
eyeX   float: x coordinate for the eye
eyeY   float: y coordinate for the eye
eyeZ   float: z coordinate for the eye

centerX   float: x coordinate for the center of the scene
centerY   float: y coordinate for the center of the scene
centerZ   float: z coordinate for the center of the scene

upX   float: usually 0.0, 1.0, or -1.0
upY   float: usually 0.0, 1.0, or -1.0
upZ   float: usually 0.0, 1.0, or -1.0


I presume they are used to specify which way to 'right' the camera, such as keeping a boat upright in water, stopping it rolling upside down.

I just don't understand them at the moment, could someone explain?
Re: Camera Question - the three UP variables
Reply #1 - Jun 5th, 2005, 8:37am
 
you presume right.. they are the definition of which axis the camera's UP will be..
i use 0,-1,0 where Y is my UP factor, therefor giving me everything correctly rotated when i run the progam..

-seltar
Re: Camera Question - the three UP variables
Reply #2 - Jun 5th, 2005, 10:35am
 
Ok, well I seem to have acheived what I wanted:
http://mkv25.net/applets/cameraVector3DPlane/

By setting the up values to ..., 0, 0, -1) - pointing directly down the Z axis I can now spin the scene around the Z axis.

The only problem is that when you are looking directly down the Z axis, the renderer freaks out and hits infinite mode, nothing displays. Dragging past this point causes it to flip over. My solution has been to limit rotation values to within 0.001 of the 'infinite' value.
e.g.:
viewRotationY = constrain(viewRotationY, 0.001, PI-0.001);

I again presume that this has something to do with the tan function and the way the camera works.
Re: Camera Question - the three UP variables
Reply #3 - Jun 5th, 2005, 6:58pm
 
I think you may need to modify your "up" axis throughout the life of the program. It should (theoreticaly) always be at 90' to the "forwards" direction of the counter, that way you could avoid the point where the forwards and up vectors are the same, and it goes insane.
Re: Camera Question - the three UP variables
Reply #4 - Jun 5th, 2005, 7:33pm
 
See http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Contribution_3DOpenGL;a... for an example how to update the up vector depending on your view. Notice that it uses the Vector class, which you can find in the same thread.
Re: Camera Question - the three UP variables
Reply #5 - Jun 5th, 2005, 8:24pm
 
yeah, i got it working of this:
http://www.millbridge.de/processing/cameraVector3DPlane.pde (found it in the thread)

-seltar
Page Index Toggle Pages: 1