Mouse picking question (probably just math related)

My name says it all, as good at math as I would like to think that I am I struggle with what seem like simple things…maybe its the hour, maybe its the beverage  ;)…



Anyway, what I am trying to do is figure out where on the y=0 plane a mouse click lands (there isn't necessarily anything there to intersect with).  The camera could have any orientation, though it will always face that plane from above (+y).  I want to place an object on that plane where the user clicks and I am trying to figure out how to do that.



I started to think that using the a directional vector calc'd from the center of the canvas (where your eye is) and where the mouse was clicked could be used to find the point where the y-plane is intersected.  I was thinking that I could use DisplaySystem.getWorldCoordinates() to get the info that I needed.  At any rate, I couldn't get it to work and I am not sure that if it did work that it would "feel" natural - I can't visualize where it would really land; under the mouse (in 2D) or somewhere else along that vector that made mathematical sense but felt weird to the user.  Can anyone point me in the right direction for this seemingly simple task?



Thanks in advance.

Create a Ray (e.g. like stated here).

Given that direction of the Ray has length 1 in the formula

( ray.origin + dray.direction ).y == 0

d would be the distance to the y=0 plane in direction of the ray. Solve this to d:

d = -ray.origin.y/ray.direction.y

then you can compute the intersection point

p = ray.origin + dray.direction


or in java

p.set( ray.direction ).multLocal( d ).addLocal( ray.origin );