Heightfield-ray intersection

Hi

Does anyone have any opinions on the best way to do ray-heightfield intersections?

I’m using JOGL, but I don’t think that OGL picking really helps in that context (I believe the fact that the Z buffer depth you get back from OGL selection results is not linear means that you can’t figure out the intersection point by scaling between the hither and yon planes - or can you?)

TIA

Peter.

If you want to genericly test against a heightfield, I only know the method utilizing spatial division using a BSP or quad tree and test against the bounding boxes. If you have identified sections, your ray intersects with, you have to use the heightfield data to create a triangle mesh and ray-triangle test all containing triangles in that (sub)mesh.

What I did In JOGL, was ask for the (x,y) coordinates of the mouseclick, ask the depth from the buffer, and then use glu.gluUnproject() to get world coordinates. Since you have a heightmap, you don’t really need the unprojected “height”, but the other two coordinates will tell you what position on the map you clicked. Voila ;D