PDA

View Full Version : newbie question about open gl

 pekko03-09-2005, 10:53 AMHi I am building rendering software that should use camera that is looking along to positive Z axis. I want to use open gl (GLUT) for display purposes. As far as i know opengl cameras are lookin along negative z-axis. I am thinking to build all the transformation matrices inside this rendering soft, so i need good way to convert my camera transformation (positive z axis) to opengl (negative z axis)..so i would see beforehand what i am suppose to be rendering :) Is plain z mirroring enough to my world->view matrix? Or is there way to make opengl camera to work like mine?
Vertizor
03-09-2005, 02:47 PM
Here is a general overview of camera and viewing in OpenGL:
http://www.opengl.org/resources/faq/technical/viewing.htm

And this is a more technical explanation of the gluLookAt() function
http://msdn.microsoft.com/library/en-us/opengl/glufnc01_8wtw.asp

The GLU is the OpenGL Utility library with extra functionality. The gluLookAt() function allows you to specify a location for the eye/camera, and a point of interest. So if you wanted to view along +Z, specify the origin of the camera down the -Z axis, and specify the point of interest (the direction the camera is pointed in) somewhere on the +Z side.

pekko
03-10-2005, 06:18 AM
Thanks, but i am not lookin the way to just move and point the camera in world axis, but change the axis system of the camera local space, that instead the camera is facing in -z direction in its own axis system (the z values from the camera point of view would go from 0 to -infinity. I would like to have the opposite. The camera system that is looking ( in it's own axis) to +infinity in z axis.

So in the end i want have opengl camera that, when look from the camera view, all the visible things (when you have fov less then 180 deg) would have positive z coordinates

So i quess that i need to do some extra work with the world->cameraspace matrix, but i am not sure how.

mummey
03-10-2005, 01:26 PM
Sounds like you want to shift it from a right-hand coordinate system (like OpenGL uses) to a Left-handed coordinate system (like the one DirectX uses).

Well, let's see what google can find...

http://astronomy.swin.edu.au/~pbourke/projection/leftright/ (http://astronomy.swin.edu.au/%7Epbourke/projection/leftright/)
http://www.evl.uic.edu/ralph/508S98/coordinates.html

Thank you for the good question.
-b

Edit: Opps, this appears to be the question you asked but not the question you intended. Here you go:

http://www.cs.unc.edu/~vogel/Equations/projection.doc
http://www.csee.umbc.edu/~squire/cs437_l14.html
http://www.engineering.uiowa.edu/~ie_246/Lecture/OpenGLMatrices.ppt

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glufnc01_8wtw.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glufnc01_6m79.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc02_0oj1.asp

Hope this works for you.

pekko
03-10-2005, 05:41 PM
Thanks
You named my problem: to change from right to left handed coordinate. In open gl FAQ i found what i think will be good for my purposes:
OpenGL doesn't have a mode switch to change from right- to left-handed coordinates. However, you can easily obtain a left-handed coordinate system by multiplying a negative Z scale onto the ModelView matrix. For example:

glMatrixMode (GL_MODELVIEW);