Mouse position on heightmap
Hi!
Is there a faster way than using the glPushName/glPopName solution to find out the x,y position on the heightmap using the mouse pointers position?
Maybe by calculating the position depending on the depth buffer using glReadPixels?
An example would be also nice, because I'm not so good with calculating all those 3D things.
Thanks for every help :)
Should do some raypicking.
Get the Picking Ray with using glunproject for the near and farclipplane and with your mouse coordinates. Now you must test which triangle intersects with the picking ray. You will find some good slides which show how to do:
http://www.cs.princeton.edu/courses/archive/fall00/cs426/lectures/raycast/sld016.htm
Maybe you will get a some more than only one triangle. You must take that triangle which is closest to the viewpoint.
For improving this technique and not testing all of you triangles do something like spatial subdivision (fire up google...).
This sound very complicated but indeed it is quite easy and with the spatial subdivsion technique it's faster than all glReadPixels or whatever.
Get the Picking Ray with using glunproject for the near and farclipplane and with your mouse coordinates. Now you must test which triangle intersects with the picking ray. You will find some good slides which show how to do:
http://www.cs.princeton.edu/courses/archive/fall00/cs426/lectures/raycast/sld016.htm
Maybe you will get a some more than only one triangle. You must take that triangle which is closest to the viewpoint.
For improving this technique and not testing all of you triangles do something like spatial subdivision (fire up google...).
This sound very complicated but indeed it is quite easy and with the spatial subdivsion technique it's faster than all glReadPixels or whatever.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement