joining two points

Hi

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?

thanx

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.

Chris

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.
di=sqr((xi^2+yi^2))

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

Any code snippet?

cheers

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

cheers[/b]

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

http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/002179.html

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