Mouse Position to 3D position...Help please

Started by
1 comment, last by Ogmios1107 21 years, 9 months ago
I''m trying to convert the mouse screen position to a 3d world position, ie. use the mouse and select a point in a 3d world. Can someone please point me in the right direction. Thanks
Remember kids, if there is a loaded gun in the room, be sure that you're the one holding it.- Captain Combat
Advertisement
you cant really convert a 2D coordinate into 3D... what you want to do is called Picking (which finds a 3D object, that is projected onto a mouse position)...Should look up that term in tutorials/books for API you are using..
What you need to do is back-project your screen point to the view plane. The you use the camera location and this back-projected point to create a vector that can be used to fire a ray accross your world, use bounding boxes and polygon\line intersection to find where the ray intersects with an object. I am writing a model\level editor for a game I am created at Reality Creations, and I did it this way, just make sure that you get your sorting order right, I perpetually built a rough BSP (slow on some machines, but the machines we use for editing are good enough), I then use the BSP to ensure that I only find an intersection with the closest surface\point\whatever.

This topic is closed to new replies.

Advertisement