Skip to main content
GameDev.net gamedev.net
🔒 Locked

picking

Started by jhirst Feb 25, 2003 at 11:18 AM 1 replies 350+ views
Original Post
jhirst
jhirst
I have created an editor for placing objects in a 3d environment. I need to use the position of the cursor on screen, projected through the landscape to accurately position the selection object. I can use the camera position and another position using the camera''s forward vector but how do I take into account the position of the cursor on the screen? Thanks
J
Dobbs
Dobbs
Think of the cursor position as a 3d point on the near clip plane of your view frustum. Given the view angle, distance to the plane, camera position, and the cursor''s screen coordinates you can find the cursor''s 3d world coordinates with some simple math. Once you have those coordinates, cast a ray from the eye position through the cursor position and intersect it with the world geometry to figure out where it''s pointing (ie where you should place your object).
jhirst
jhirst
Of course, the cursor is apparently moving along the near plane. Thanks, I will try that.
J

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.