i have to ray pick some points on the screen with JOGL.
i want to use gluUnproject cause i think it is better way instead of selection buffer.
i have 3 points in world (3d) space:
x1: eye's coordinate
x2: mouse coordinate on near plane
x0: point to test
i have to get the distance between between line x1-x2 and see the difference between x0, with this formula:
http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
now..
firstofall:
glu.gluPerspective(45.0f, h, 1.0, 20.0); //near plane is at: 1.0Vector3D x0 = new Vector3D(0.6, 1, 2); // my target point
x1:
glu.gluUnProject(width/2, height/2, 0, mvmatrix, 0,projmatrix, 0, viewport, 0, wcoord, 0);
because my eye's coordinate is at the center of the screen at z = 0, right?
x2:
glu.gluUnProject( mouseX, height-mouseY, 1, blabla);
because my mouse is on my near plane at z = 1.0
and then math for distance between point and line
..
where am i wrong??
the result is not good.. i thought it should be perfectly calculated but i have to add some offset to get distance <0.2 exactly where is the point..
hope some of you can help me despite my bad english
[Edited by - nkint on December 22, 2010 2:07:17 PM]