View Full Version : camera space coordinates of a point

I found an explanation in an article I read but I'm not sure how to do it in open GL.

Specifically I want to "tranform a world-space position into camera-space position" by "multiplying the world space position and your active camera matrix".

Basically, how do you access the active camera matrix in openGL(if that's what its callled)?

ZbuffeR

01-08-2004, 02:35 AM

There are two matrices related to camera in OpenGL, the 'modelview' and the 'projection'. I once knew for sure which was used for what, but I am not certain anymore...

glGet with argument GL_MATRIX_MODE

glGet with argument GL_MODELVIEW_MATRIX

glGet with argument GL_PROJECTION_MATRIX

You can have a doc here : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc02_5ub8.asp

Deiussum

01-08-2004, 05:30 AM

Here's a brief description of the 2 main matrices.

GL_PROJECTION - Defines the shape of the viewing volume. Roughly analagous to properties of a camera lens, like field of view, depth of field, etc. Functions that should be used with GL_PROJECTION include glFrustum, glOrtho, gluPerspective, gluOrtho2D. Note: Using any function here which is noted below for use with GL_MODELVIEW may result in incorrect calculations for fog and other things that base their calculations off of the GL_MODELVIEW matrix.

GL_MODELVIEW - A combination of the MODEL and VIEW transformations. Generally VIEW transformations are inverse transformations to simulate moving of the camera. (e.g. if you want to move the camera -10 on the Z axis, you translate the world +10 forward). MODEL transformations are those affecting positioning of the models within the world. To get the right effect, you should first apply your VIEW transformations and then the MODEL transformations. Functions that should be used with this matrix include glTranslate, glScale, glRotate, gluLookAt.

Hope that helps some.

Thanks. GLGET works perfectly.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.