PDA

View Full Version : Mouse position on heightmap



10-24-2006, 05:10 AM
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 :)

Flavious
10-30-2006, 10:13 PM
Selection will only return hits at the granularity of the objects themselves, so it's not very useful or efficient in this particular context.

A reading of the depth buffer followed by a reverse projection (gluUnProject) makes quite a bit more sense in this scenario, that is if pinpoint accuracy is not a requirement (you're really at the mercy of zbuffer precision here).

Line tracing is also a good possibility, probably the best. A bit more difficult to implement robustly, but more accurate and potentially more efficient, depending on the algorithm.