Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: retriving camera position

Hybrid View

  1. #1
    Intern Contributor
    Join Date
    Apr 2003
    Location
    Turin, Italy
    Posts
    94

    retriving camera position

    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.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    857

    Re: retriving camera position

    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

  3. #3
    Intern Contributor
    Join Date
    Apr 2003
    Location
    Turin, Italy
    Posts
    94

    Re: retriving camera position

    thanks for the answer Tom,
    just to check whether i've understood it clear, you are suggesting me this:

    Code :
    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.

  4. #4
    Advanced Member Frequent Contributor plasmonster's Avatar
    Join Date
    Mar 2004
    Posts
    750

    Re: retriving camera position

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •