0

How would I calculate the Intersection Point at the terrain in a World with the World, view and projection matrices. Now lets say that the intersection Point should be calculated from my 2D cursor coordinates and the part of the terrain behind my cursor should be the intersection Point. So if I have my mouse at the exact center of my screen the 2D view should look something like this:enter image description here

This test is easy if we know the "Y" Coordinate, but lets say that we don't know the "Y" Coordinate here (there could be a mountian)... I have absolutly no clue of how to solve this problem efficient. But this is definitivly possible. I Checked out CryEngine and from what I can see they display the collision Point of the bullet to the ground when firing a weapon. Any Help would be very appreciated, Tutorials and whatsoever.

Thanks Mikael.

  • Either do it with "mouse picking" (using the rendered image) or on the CPU side for example with ray marching (you basically want to intersect the height function of the slice with the camera ray, and you can solve that by stepping through the function in small steps = ray marching). – leemes Jul 10 '14 at 17:59
  • I am checking out raymarching at the moment, very good comment. Thanks – Mikael Törnqvist Jul 11 '14 at 04:06
  • Is your terrain always flat? Then you don't need an iterative method like ray marching. The solution can be calculated in closed form. – Nico Schertler Jul 13 '14 at 21:11
  • No my terrain is not Always flat, I am implementing a ray marching method atm. Just some glitter left :). It works very good so far. Very high performance. I Use a const value for step size untill I am under ground and then I step back with smaller steps(Face size) untill I find the intersection Point. I Will Upload code here when I'm done. However I read about a Function to determent step size and I just cant understand how this would work, anyone got a good link? – Mikael Törnqvist Jul 14 '14 at 18:00

0 Answers0