🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Mouse position on heightmap

Started by
0 comments, last by rotalever 17 years, 8 months ago
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 :)
Advertisement
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.

This topic is closed to new replies.

Advertisement