PDA

View Full Version : Picking single 3D points with no name



alb84
07-12-2010, 02:45 AM
I am working on a project to load a vectorial cartography as a 3D mesh (x, y, z) and overlay that cartography on the video taken from a plane, beeing known the GPS position and the lookAt angles of the camera mounted on the plane.
The overlay is working but there are some errors, so I wanted to analyze the errors. To do this I need to manually specify the correspondences between some 2d points in the video and some 3d point in the mesh.
The 2d point in the video is easy to get because it is the mouse coordinate.
The 3d point in the mesh is not so easy.
I am not particurlarly skin of OpenGL picking but I read that picking can be done on entire objects in selection mode after a name has been assigned to them.
This is not particurlarly comfortable for my case because
* the cartograhic mesh is loaded from a file
* i need to pick a single point, not an object
* if i define an object for each 3d point I cannot draw LINE_STRIPS between points and the number of objects would be very very high

Is there a way to pick the 3d coordinates of the closest point to the line from the point of view to the point clicked on the screen?
Maybe not with OpenGL but is there some library like VTK but working directly on the 3d model loaded by OpenGL in the graphic card memory with this functionality already implemented? A sort of gluUnproject....

Any help is much appreciated

alb84
07-13-2010, 02:29 AM
An idea that came to my mind was to use gluUnProject setting winX, winY to the screen coordinates clicked by the mouse, winZ=0, then gluUnProject tell me a 3D point.

Now it is possible to define a line from the point of view to the 3D point computed by gluUnProject:
http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html

The picked point in the 3D mesh can be found as the point of the mesh which is closest to that line.

The search can be quite time consuming but it should work... what do you think?
And I do not have to define an object for each point and assign a name to it for selection mode...