Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the Irrlicht Engine and would like to convert the coordinates of the mouse on the screen to the floor of my world. I am currently trying to use


which returns a "Ray starting from the position of the camera and ending at a length of the far value of the camera at a position which would be behind the 2d screen coodinates." Then I do this to get the position:

    core::line3df line = getRayFromScreenCoordinates(receiver.mousePos, device);
    irr::core::vector3df lineVector = line.getVector().normalize();
    irr::core::vector3df pos = line.start + lineVector*x;

x would be the magnitude from camera to the coordinate. However I do not know how to calculate x (as I don't know the coordinate yet).

The page I got the code from, written in 2003

share|improve this question
up vote 1 down vote accepted

What you need to do is get a ray intersection against a plane which is your floor. I'm not certain how this is done in Irrlicht, but my guess is that there's some function such as:

vector3df plane::getIntersectionWithRay(line3df)

You can then discard the y part of the vector (or z, depending on your co-ordinate system ) as it will be equal to zero, and use the other two for a 2D vector.

share|improve this answer
I should have really checked the docs. Thanks! – andrew Apr 13 '13 at 20:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.