Jump to content
  • Advertisement
Sign in to follow this  
CastorX

Mouse pointer in 3D space

This topic is 3029 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hy! Is there a helper function in XNA that helps to convert the mouse pointer position from screen-space to 3D space, and maybe returns a ray pointing from the viewer's screen plane to the corresponding direction of the far clip plane? The method I used until now extracts the 6 planes from the view*projection matrix, determines the intersection points of the frustum planes and then interpolates between them using the position of the mouse pointer on the screen. I'was just wondering if there is a simpler method to do this in XNA (or D3D9,10,11). Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by CastorX
Hy!
Is there a helper function in XNA that helps to convert the mouse pointer position from screen-space to 3D space, and maybe returns a ray pointing from the viewer's screen plane to the corresponding direction of the far clip plane?


Yes, you can use GraphicsDevice.Viewport.Unproject()
Here is a guide on how to use it: http://msdn.microsoft.com/en-us/library/bb203905.aspx

Also, a quick google for "xna picking" will give you more results and sample code. Hope that helps =)

Share this post


Link to post
Share on other sites
That is very simple. Thank you! This is what I need. I did not really know what to search for in google.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!