Zy

10-14-2001, 07:59 PM

Is there a simple OpenGL command that I can grab the XYZ coordinate position of the camera.

View Full Version : Camera XYZ position

Zy

10-14-2001, 07:59 PM

Is there a simple OpenGL command that I can grab the XYZ coordinate position of the camera.

Korval

10-14-2001, 11:59 PM

Well, the camera is technically at 0,0,0. But, if you want to think of the camera as the first transformation you put on the MODELVIEW matrix stack, then it is probably a gluLookAt call. If so, then you told OpenGL where to put the camera, so you should know.

Zy

10-15-2001, 12:07 PM

What if I did a bunch of translates and rotates first, then drew my model. Will the camera still be at (0,0,0)? Or am I thinking about this all wrong?

Korval

10-15-2001, 06:01 PM

OK, technically there is no camera. The entire modelview stack transforms to "world space", which has a viewpoint centered at the origin. If you want, you can get the inverse of the modelview matrix stack, and transform (0, 0, 0) by it to get where the effective "camera" is.

If you do things by what I consider the standard method, you have a notion of a camera matrix. The camera matrix lives at the bottom of the matrix stack. Every transform above this is the transform to world space. The camera matrix transforms to camera space.

So, when you set up your scene rendering, it looks something like this:

//Matrix stack is at level 0.

gluLookAt(camera stuff);

glPushMatrix();

SetGLGlobalLightingState();

DrawOpenGLScene();

glPopMatrix();

Your camera position is part of the "camera stuff".

If you do things by what I consider the standard method, you have a notion of a camera matrix. The camera matrix lives at the bottom of the matrix stack. Every transform above this is the transform to world space. The camera matrix transforms to camera space.

So, when you set up your scene rendering, it looks something like this:

//Matrix stack is at level 0.

gluLookAt(camera stuff);

glPushMatrix();

SetGLGlobalLightingState();

DrawOpenGLScene();

glPopMatrix();

Your camera position is part of the "camera stuff".

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.