Archived

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

RajanSky

Picking edges

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 this post


Link to post
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 this post


Link to post
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 =)

Share this post


Link to post
Share on other sites