Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 6 123 ... LastLast
Results 1 to 10 of 52

Thread: closet vertex to camera.

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    111

    closet vertex to camera.

    Hey guys!!!

    I have a question again:

    Do somebody of you know a fast way to find the closest vertex to the the eye camera?

    The first idea, which popped into my mind was to read back the depth buffer and find the minimum depth value.

    But this is a rather dirty solution. Are there better ones?

    Thanks a lot!!!

    remark: I meant CLOSEST vertex to camera, not closet :-)

    [This message has been edited by A027298 (edited 01-16-2003).]

  2. #2
    Intern Contributor
    Join Date
    Dec 2001
    Posts
    98

    Re: closet vertex to camera.

    Pythogora's Theorem?

    Or am I missing something?

  3. #3
    Junior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    111

    Re: closet vertex to camera.

    An if I have 100000 vertices. The whole thing should be in realtime.

    BTW what exactly do you mean here with Pythagoras theorem?

    [This message has been edited by A027298 (edited 01-16-2003).]

  4. #4
    Junior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    111

    Re: closet vertex to camera.

    Hmmm...or is it possible to use maybe a vertex program to use the distance from the last processed vertex for the current processed vertex?

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

    Re: closet vertex to camera.

    Originally posted by A027298:
    An if I have 100000 vertices. The whole thing should be in realtime.
    Build a hierarchical representation of your scene, e.g. an octree. That'll help speed things up.

    -- Tom

  6. #6
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,537

    Re: closet vertex to camera.

    BTW what exactly do you mean here with Pythagoras theorem?
    A^2 + B^2 = C^2

    I'm suprised you didn't know this. This is stuff taught back in middle school, like 6th grade. One of the things taught when people first start to learn algebra as kids.

    -SirKnight
    -SirKnight

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Jul 2001
    Posts
    533

    Re: closet vertex to camera.

    Hey SirKnight, add disclaimer: some of us didn't pay attention in school!

  8. #8
    Intern Contributor
    Join Date
    Dec 2001
    Posts
    98

    Re: closet vertex to camera.

    Originally posted by A027298:
    An if I have 100000 vertices. The whole thing should be in realtime.
    Shouldn't be a problem. I just did a quick test on a machine with a modest modern processor, and 100000 vertices take about 2 milliseconds.

    As mentioned above, there are other techniques which might be quicker depending on your problem (eg. is your geometry static, etc.).

  9. #9
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,537

    Re: closet vertex to camera.

    Originally posted by Robbo:

    Hey SirKnight, add disclaimer: some of us didn't pay attention in school!
    Maybe, but my god, this thing is taught/used in almost every math class after algebra is first taught to students. I've had to use it so much in the past ungodly amount of years in school that I probably know it better than my own name. But paying attention or not, one needs to know math before diving into a subject as math intensive as 3d graphics.

    -SirKnight
    -SirKnight

  10. #10
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: closet vertex to camera.

    Use your scene graph. Assuming you have bounding volumes for each object, start like this:

    [CODE]
    cur_min = +Inf;
    foreach obj in scene.objects
    if distance( obj.center, camera ) - obj.radius < cur_min then
    foreach vert in obj
    if( distance( vert, camera ) < cur_min ) then
    cur_min = distance( vert, camera )
    endif
    endfor
    endif
    endfor

    This will only visit, on average, perhaps sqrt(N) vertices out of the scene. You can make it better with better bounding/dividing volumes in your scene graph.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

Posting Permissions

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