I am in the process of developing a 3D terrain engine. Most has gone well, it looks good, textures good, rotates good and draws at a nice frame rate. Everything I wanted so far. Now, for the fun bit. I want to be able to interact with the terrain with the mouse. My maths not being great, I sort of hit a brick wall. I've done some searching on the web and found bits and bobs related to "ray picking", but nothing I've yet been able to get my head around. So, I've turned my attention here as I'd like to spend some of my points getting a good answer.
My terrain is stored in a vertex buffer (obviously) and draw to the screen. I have the vertex information in an untransformed buffer. The buffer basically contains a bunch of vertices for each "tile" in my terrain.
Given a screen co-ordinate of x,y I'd like to be able to see if the mouse is "clicking" on a tile. To do this, I'm guessing I need to check each triangle that makes up each "tile" and if it intersects either of them, that's the tile I want.
I'd also like to extend this routine at some point to determine which corner vertex is nearest to the mouse.
If you need more info, let me know, but basically that's what I want to do!
Thanks in advance guys