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

Thread: Ability to tell where the transformed modelview origin point is

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2000
    Location
    London
    Posts
    28

    Ability to tell where the transformed modelview origin point is

    It would be nice to be able to get the modelview origin for a ModelView matrix that is used to transform glVertex3f.

    At the moment I'm trying to calculate it and I'm having absolutely no sucess. I've looked all over google.com, asked on several message boards (with no useful answers, or none at all), and tried just about every combination of reversing signs, rotating transformations, not reversing or not rotating transformations, of the numbers I extract from the modelView matrix. And none of it works! They all failed to give a coord that could be used consistantly for correct depth sorting. (Blended objects are best done with depth sorting)

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

    Re: Ability to tell where the transformed modelview origin point is

    In general, you should always use separate variables that holds the values of where your viewpoint is, aswell as for your objects. Doing so, you don't need to know where the matrix's origin is located. And for depthsorting, just calculate the distance from the viewpoint and the objects to be sorted.

    In my oppinion, you should never need to do things like this. If you once placed the origin somewhere, pointing it in a certain direction, you must have used some kind of variable/static to get there, and why not use these variables/statics for this purpuse.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: Ability to tell where the transformed modelview origin point is

    Maybe I'm crazy, but for depth testing on opengl it is not only faster to use the hess'sche normal-form of a plane to calculate the distance (no square root for every vertex, 3 floating point subtracts, 2 floating point additions and 3 floating point multiplications) than to use the distance from the viewpoint (3 floating point multiplications, 2 floating point additions one square root ). It's also more exact.
    - Michael Steinberg

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

    Re: Ability to tell where the transformed modelview origin point is

    You don't need to do a squareroot to get the distance. OK, to get the exact distance you need it, but for depthsorting, the exact distance is not needed, only the relative distance. Use the squared distance instead. If a > b, then a^2 > b^2. Because a distance is always positive, the above forulma is always correct, for any positive value of a and b.

    So I dunno it's slower (3 fp multiplications, 2 fp adds), but as you say, it's less correct.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: Ability to tell where the transformed modelview origin point is

    Well, I'm not only using it for depth testing so I always needed it to be exact. Didn't think about only depth testing, ooops. Well, thanks anyway!
    That I didn't see that. ****.
    Well, anyway, the depth is the distance from the near culling plane, so only planar distance will be exact for many big and near-to-each other billboards.
    - Michael Steinberg

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Lafayette, LA
    Posts
    138

    Re: Ability to tell where the transformed modelview origin point is

    Hmm, if you're not guilty of projection matrix abuse (see http://web2.airmail.net/sjbaker1/projection_abuse.html ) the last row of the modelview matrix negated should give you the viewer position. What do you get?

Posting Permissions

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