PDA

View Full Version : project/unproject with glOrtho vs perspective.



Mario1982
12-06-2009, 10:19 AM
Hello,

I've written an application where i find the closest vertex to the mouse pointer on the 3d model. I currently use glOrtho and everything works perfectly. When i switch to using perspective view and gluLookAt the vertex selection doesnt work.

Is there a difference between the way the matices should be handled when using perspective vs ortho?

Thank you.

starmerak
12-06-2009, 03:34 PM
you must use the same matrices when picking as when rendering..

Mario1982
12-07-2009, 01:18 AM
I do, thats what i find strange that it doesnt work. What else can cause my picking to fail when in perspective?

Mario1982
12-07-2009, 05:54 AM
I solved my problem. It was a silly mistake, instead of unprojecting to the near and far plane of the frustum i unprojected to z = 0 , z = 1. Which works fine in glOrtho.

Thanks again.

MOlOX
12-08-2009, 01:53 AM
hi mario,

if there is no secret data / flow in your code, can you share your application with me / us.

i would like to go over your code , to gain experience ?

Thank you

Ramya Maithreyi
12-08-2009, 03:52 AM
Hi
Even i experience the same problem.
I thought the problem was with the z-value passed to the gluunproject.
Can you tell me what is to be done after getting both the vertices in near plane and far plane.

I mean we need just one unprojected vertex right? Are we supposed to find a mean between the vertices of near and far plane ?