in a 3d game how would i convert 2d screen position mouse coordinates to 3d world coordinates.
1 Like
I don’t think you can straight convert them since the mouse has no 3rd dimension. If I remember correctly, the idea is to map the 2d screen position to your camera’s view bounds, then cast a ray from the camera position through the view position (mapped from the mouse). Then, whatever object the ray hits (that is appropriate), is what you pick (ie, terrain, a character, an object, etc…).
I read an article on this a long time ago but it’s been a while, maybe I can get lucky in a google…
Ahhh there’s a lot of hits and I don’t see the article I remember from back then. Just search “xna 3d mouse picking” and you’ll get a lot of articles of varying quality. Here’s one example!
1 Like
thanks i will check it out!