PDA

View Full Version : retriving camera position



gunslinger
05-28-2004, 04:47 AM
hi all,
i am working on a project based on a graphic library named OpenSG.
I want to add a couple of vertex/fragment programs, but i can't get the position of the camera (it is stored into a private variable).
Is there a state variable holding that data?
something like the ole good

PARAM mvp[4] = { state.matrix.mvp };

i.e.

PARAM camera[4] = { state.camera.pos }

thank you!
the G.

Tom Nuydens
05-28-2004, 05:55 AM
No, because there is no OpenGL state that holds the camera position. However, you know that in eye space, the camera is always at the origin, so if you really need it, you could multiply the vector [0, 0, 0] with the inverse of the modelview matrix.

-- Tom

gunslinger
05-30-2004, 10:56 PM
thanks for the answer Tom,
just to check whether i've understood it clear, you are suggesting me this:


eye_cam * inv_mod_view

[0,0,0,1] * | mvi00 mvi01 mvi02 mvi03 |
| mvi10 mvi11 mvi12 mvi13 |
| mvi20 mvi21 mvi22 mvi23 |
| mvi30 mvi31 mvi32 mvi33 |whis is equal, if i am not wrong to

camera pos = [mvi30 mvi31 mvi32 mvi33]

am I right? Thank you G.

plasmonster
05-31-2004, 10:25 PM
That looks good to me. Make sure that you have only view transformations on the modelview stack, as I assume you don't want model transformations to affect the view position.