Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualFLeBlanc

Posted 16 April 2012 - 08:39 AM

You actually DO need to intersect with a mesh, in a manner of speaking. As Tom KQT state, you can not reverse-project a screen point to a single 3D point without additional information--namely, the depth of the point to project. Some reverse-projections will perform a read of the depth buffer to get the depth of the pixel at the mouse location, but if your purpose as stated is to find a target to move to, then this might not be optimal since the depth of the pixel might not lie on the movable area; it might be a piece of blocking geometry instead.

In your case, you need to compute the ray corresponding to the mouse location, then test intersection of that ray with any geometry forming the walkable or movable area, to find the point to move to. In the case that your walkable area is a simple flat plane, then this case is trivial and doesn't actually require testing against the geometry of your scene. Instead, you can just solve the case of the intersection of the ray against the ground plane.

#1FLeBlanc

Posted 16 April 2012 - 08:39 AM

You actually DO need to intersect with a mesh. As Tom KQT state, you can not reverse-project a screen point to a single 3D point without additional information--namely, the depth of the point to project. Some reverse-projections will perform a read of the depth buffer to get the depth of the pixel at the mouse location, but if your purpose as stated is to find a target to move to, then this might not be optimal since the depth of the pixel might not lie on the movable area; it might be a piece of blocking geometry instead.

In your case, you need to compute the ray corresponding to the mouse location, then test intersection of that ray with any geometry forming the walkable or movable area, to find the point to move to. In the case that your walkable area is a simple flat plane, then this case is trivial and doesn't actually require testing against the geometry of your scene. Instead, you can just solve the case of the intersection of the ray against the ground plane.

PARTNERS