joining two points


I have a grid whereby I want to be able to select a point on that grid and then join it to another - what is the best way of tackling it - any code snippets/ ideas?


Assuming that you know the coordinates of all of the grid points, the only way I can think of is to get the mouse-click location, transform it into your coordinate system, figure out which point they are nearest to, and start the line there. Etc.


any one have selection code for mouse hitting a pixel?

[This message has been edited by fox (edited 05-09-2001).]

Project your points from 3D space to 2D coordinates using gluproject. Then compute nearest point using a 2D distance.

Select the point on the grid with smallest di to your mouse click.

Any code snippet?


Originally posted by fox:
[b] Any code snippet?


For the 2D-3D stuff (gluProject and gluUnproject) look at

[This message has been edited by Kilam Malik (edited 05-10-2001).]