# Thread: closet vertex to camera.

1. ## 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. ## Re: closet vertex to camera.

Pythogora's Theorem?

Or am I missing something?

3. ## 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. ## 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. ## 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. ## 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

7. ## Re: closet vertex to camera.

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

8. ## 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. ## 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

10. ## 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.

#### Posting Permissions

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