Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Galileo430

2D Screen Points To 3D World Points

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

Assume your looking at a 3D RTS game sorta like Warcraft 3. When I click on the screen.. How do I turn the screen U, V into points on the map?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
The way I do I it is to define a point in 3D space that IS upper left corner of my screen. The lower right corner in world space is then (WORLD_SIZE) / (SCREEN_SIZE) + 3D_POINT_UPPER_LEFT_CORNER.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

you have access to the cameras position and orientation matrix.
place the screen u v values into the x and y portions of a vector.
take the near clipplane of the camera and place that as the z value. you now have a vector in relation to the camera that points
in the direction of the button click. transforming this vector back into world space (mulitply it by the transpose of the camera matrix) gives you a world vector that you can use in a collision routine thatll return the exact position of the world where you clicked. you may need to play with the z value to get the desired results, cause this really depends on where the renderer places the "screen".




Share this post


Link to post
Share on other sites

  • 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!