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
getRayFromScreenCoordinates()
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).