Jump to content
  • Advertisement
Sign in to follow this  
Magnumwolf

XNA - Screen space to World space problem

This topic is 3218 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

Hi, Im working on a small tool using a Winform with an embeded XNA game. Ive just got picking working but it have left me with 2 mouse pointers, 1 in world space and 1 in screen space. I need to make the world space pointer follow the screen space pointer The problem is that this tool must allow the user to define the world size(resolution) but the world will always be drawn in a set size panel. (So the world will sometimes appear streched or squashed) If the world size is set to the same size as the panel the mouse and world space mouse line up perfectly but if the world space is a different size to the panel size it does not follow correctly. If anyone could help me out with calculating this i would be really greatful What im trying to do is convert 1 pixel of screen space into x pixels of world space but im having trouble doing this and im not even sure if that is the correct way to solve the problem. Ive made a screenshot to try and further explain the problem mouseexplan.png (Ive drawn the mouse pointer on as a circle as printscreen does not include the mouse pointer) Thanks for your help *** SOLVED *** Got it working finally [Edited by - Magnumwolf on October 25, 2009 6:11:49 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by programmer_tom
quick tip: look at Project() and UnProject() functions in DX.


Just to clarify he's using XNA, so he would want Viewport.Project and Viewport.Unproject.

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!