View Full Version : 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?
05-09-2001, 05:05 AM
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).]
05-09-2001, 07:15 AM
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.
05-10-2001, 05:55 AM
Originally posted by fox:
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).]
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.