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 2 of 2

Thread: screen coordinates to world coordinates

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2009
    Posts
    10

    screen coordinates to world coordinates

    Hi

    I want to convert a point in screen coordinate to world coordinate. I have gone through several threads regarding this. Everything boils down to ray tracing.

    The problem in my case is that, there are numerous objects that are being rendered and we do not keep track of them. As and when an object is processed, it is rendered and we get rid of it. So i would be glad if someone could suggest a solution without going through all objects to find if the projected ray intersects it or not.

    One additional info is that, the relationship with the z value to y value for all the objects in world coordinates is linear in my case. I was trying to find the intersection between the projected ray and the yz line. It dint work out. Probably i dint get the proper method to get it right.

    Also, it is not necessary to find the exact object that intersects the ray. I have other methods to find it out. All i need is just the exact world coordinate.

    I would be glad if someone could derive an alternative method ( apart from object picking - ray tracing ) to find out the world coordinate with the given info.

    Thanks in advance.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882

    Re: screen coordinates to world coordinates

    Quote Originally Posted by Ramya Maithreyi
    I want to convert a point in screen coordinate to world coordinate. ... it is not necessary to find the exact object that intersects the ray. ... All i need is just the exact world coordinate.
    Well, ignoring the "exact" world coordinate mention...:
    Code :
    glPixelStorei( GL_PACK_ALIGNMENT, 1 );
    glReadPixels( x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth );
    gluUnProject( x, y, depth, modelview, projection, viewport,
                  &x, &y, &z );
    As you know, anytime you're dealing with floating point values, there is no "exact" except in odd circumstances.

    If you don't think this is sufficient, please respond with why as there are variants (such as higher-resolution depth buffers, different depth buffer encodings, other approaches).

    BTW, if you do want "world" coordinates, then your "modelview" above should just be the VIEWING matrix.

Posting Permissions

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