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

Thread: Coordinate system question

  1. #1
    Member Regular Contributor
    Join Date
    May 2000
    Location
    Batavia, NY, 14020
    Posts
    259

    Coordinate system question

    How do I retrieve, or set the visible coordinate system of a perspective volume?

    I know how to map the x,y on an ortho volume to the window's x,y, but is there a way to do this for perspective volumes?

    Hmm, is it just me or do I seem vague here?

    What I'm trying to do is find out what the ratio is between 1.0 units in the x or y direction on a given plane x,y along the z axis in relation to the window coordinates.

    ie: the right-most edge of the window is, say, 400 pixels. I want to know what that is in volume units 200 units back into the viewing volume. I know it will be much bigger than 400.

    Thanks in advance!

    Siwko
    - I am not opensource! -

  2. #2
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Huntsville, AL, USA
    Posts
    3

    Re: Coordinate system question

    As long as you have access to the viewing matrix (GL_MODELVIEW) and projection matrix (GL_PROJECTION), you can use the "gluProject" function (part of the GLU library). You pass in your object coordinates (x,y,z), model view matrix, projection matrix, and viewport extents. The function returns the window (x,y,z).

    Originally posted by Siwko:
    How do I retrieve, or set the visible coordinate system of a perspective volume?

    I know how to map the x,y on an ortho volume to the window's x,y, but is there a way to do this for perspective volumes?

    Hmm, is it just me or do I seem vague here?

    What I'm trying to do is find out what the ratio is between 1.0 units in the x or y direction on a given plane x,y along the z axis in relation to the window coordinates.

    ie: the right-most edge of the window is, say, 400 pixels. I want to know what that is in volume units 200 units back into the viewing volume. I know it will be much bigger than 400.

    Thanks in advance!

    Siwko
    Tim Palmer
    CG2, Inc.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: Coordinate system question

    When (if) you set your frustum with glFrustum(l, r, b, t, n, f), you can use these values to calculate how much a unit on the y (or x)-axix at z=<anything> is worth on the viewport. A hint: the point <l,b,n> is the point on the near clippingplane that will be projected on the bottom left corner of the viewport, and <r,t,f> is the point on the far plane that will be projected on the top right corner of the viewport.

Posting Permissions

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