• Advertisement
Sign in to follow this  

yet another stupid post on RAY PICKING

This topic is 2643 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi guys
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:


glu.gluPerspective(45.0f, h, 1.0, 20.0); //near plane is at: 1.0

Vector3D x0 = new Vector3D(0.6, 1, 2); // my target point

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?
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]

Share this post

Link to post
Share on other sites
ok if i put mouse coordinate z (3° input in gluUnproject) as 0.8 instead of 1
everything is ok.

why? ho can i calculate the exactly z value with other canvas dimension or different projections matrix?

Share this post

Link to post
Share on other sites
ok i got it it was stupid : )
picking ray needs to be horizzontal to clipping cube

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement