#### Archived

This topic is now archived and is closed to further replies.

# Picking edges

This topic is 5727 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi! I was wondering, does anyone know how to pick an edge in OpenGL? Like, I know that you can assign a name to each polygon and then when you click on the screen, you can work backwards to figure out which polygon you clicked on, but how about clicking on an edge? This is what I''m thinking for now... Say I have a polygon, and I click on one of its edges. Then, I''ll figure out which *polygon* was clicked on, and then use that to get access to its edges, and then compute the distance to all of the polygons edges to find which one the point is closest to. I think this should work although there might be a better way to do it... Thanks! Raj

##### Share on other sites
Consider just clicking an edge based on the distance from its midpoint - that might ultimately make it more intuitive for the user.

##### Share on other sites
quote:

This is what I''m thinking for now... Say I have a polygon, and I click on one of its edges. Then, I''ll figure out which *polygon* was clicked on, and then use that to get access to its edges, and then compute the distance to all of the polygons edges to find which one the point is closest to. I think this should work although there might be a better way to do it...

That''s great if the user only clicks inside the polygon to select it''s edges, clicking the edge from outside is just as likely.

As mentioned above, the best way to do this will be in 3D space. First find the closest points of intersection between the eye/mouse ray and the edge, constraining it to the [0:1] interval for the edge. If the distance between these points is less than some threshold then select the edge.

##### Share on other sites
Cool, thanks for the ideas! Hmm, the ray intersection idea is awesome, though I think I''ll go for something more simple since this is just a small project that I have to finish by tomorrow hehe =)

1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 38
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631710
• Total Posts
3001845
×