Eye vs camera-space coordinates(opengl)

Started by
2 comments, last by JimmyP 23 years, 1 month ago
I understand that camera-space coordinates are the coords. you get by multiplying vertex coords. by the camera matrix(or more specific C=CM*(V-P) where P is the camera location)whereas eye coords are the ones you get by multiplying with the modelview matrix.Now supposing I only do a glTranslatef() and a couple of glRotatef()s in the beginning of each frame(to place the camera) and then draw a bunch of tris,can I get the ''camera-space'' coords. of these tris by mutiplying with the modelview matrix? What I want to say is that I''m trying to code a terrain engine based on the ROAM algorithm and I need the camera-space coordinates of the triangles to comute priorities.Yet I haven''t implemented a camera model yet(I just use those glRotatef()s and the glTranslatef() calls to place the camera).I''m not sure if the terrain I get is quite correct though so I was wondering if my cam-space coords were correct.Thanx in advance.
-=Jimmy=-
Advertisement
Normally, when you want to simulate camera movements, you use gluLookAt. This sets up a matrix that (should) be multiplied with the MODELVIEW matrix. You can do the exact same thing with the glRotate/Translate commands. So yes, you can do either way because both were meant to be multiplied to the MODELVIEW matrix. So for instance, moving the camera forward is the same as translating the verts back. (incidentally, the MODELVIEW matrix is named so because the matrix used to transform the MODEL and the VIEW is put into one matrix. at least, that''s what it seems like to me)
Yes,but suppose I use either gluLoookAt() or glTranslate()s and glRotate()s to obtain a matrix and multiply it my the MODELVIEW matrix(which is initially an identity) to get the desired view.How do I get camera-space coordinates then?Do I use glGetFloatv() to get the modelview matrix(which is the one I mutilplied since it initially was an identity)and mutiply the world-space coords. by it?Or do I have to do someting to the matrix first(like calculating the inverse or something)?
-=Jimmy=-
Yes, after you set up the modelview matrix, you can retrieve the matrix with glGetFloatv and multiply it with all the points of the polygons...Just remember the matrix that you get is in COLUMN MAJOR order. Calculating the inverse of the matrix is usually done when you also want to transform the polys'' normals (well, the transform of the inverse of a matrix is used). However, if the matrix is orthogonal (i.e. you only used rotations, translations, and/or uniform scaling), you don''t have to compute the inverse of the matrix to transform the normals.

This topic is closed to new replies.

Advertisement