picking right point by mouse clicking

Started by
0 comments, last by dimebolt 18 years, 6 months ago
hi, i need help with selecting points in openGL. I have a reasonable (array)list of vertices, in the amount of 10.000(not any spatial algortithm applied to it). Now i need to find the nearest/closest point when an user clicks on a location. I read about the GL_SELECTION part, to create a ray that intersect with plane/ray collision. but how to (quickly) select individual points. cheers, P
Cosmic Keys to my Creations & Times
Advertisement
You can calculate the distance of a point to a ray (or line) using the formula numbered 9 of the description at mathworld.

One way to find the closest point, is to compare the distances of all points to the ray. This brute-force method will perform terrible (esp. with thousands of points). It can probably be optimized by (hierarchically) grouping the points in clusters and performing brute-force only within clusters that are near the ray. This may get tricky though, especially if the points are highly dynamic.

Tom

This topic is closed to new replies.

Advertisement