Mouse Pointer Aiming (Finally)

Subscribers:
1,270
Published on ● Video Link: https://www.youtube.com/watch?v=QFFXj8tjxoM



Duration: 2:11
143 views
5


First normalize the mouse coordinates to the ranges -1 to 1.
Then build a RayVector.
X component MouseX times tan( verticalFOV / 2 ) times the aspect ratio.
Y component MouseY times tan( verticalFOV / 2 ).
Z component of 1.0.
Then normalize this vector and cast it from the Camera's position into world space and test the geometry's triangles for the nearest point. I move the point up an arbitrary amount and cast another ray straight down to get the final position.