Skip to main content
gamedev.net
🔒 Locked

[D3D] Picking a line

Started by devdept Jun 16, 2007 at 5:26 PM 2 replies 1.5k views
Original Post
devdept
devdept
Hi All, How do I pick a line or a point in Direct3D? I saw many example on finding the Mesh triangle under the curso but not on standard line / point entities. Thanks so much, Alberto
ankhd
ankhd
Hey.
Turn the line into a rectangle if 2d, or a box then do pick.
ET3D
ET3D
Point: That's easy. Transform it into screen space, compare to mouse position. If distance is less than something (less than a pixel, for example), consider it picked.

Line: Transform both endpoints into screen space, use 'distance between point and line' calculation (google it) to find out how far the mouse position is from the line, and if close enough also check that it's not beyond the two endpoints (i.e., it's on the line segment).
devdept
devdept
I know this techniques,

But what if I want to select lines with a pick rectangle selection and one very long line crosses the rectangle without having a point in it.

Thanks again,

Alberto

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.