Jump to content
  • Advertisement


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


Unusual raypick situation

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

Here is the deal: I am currently working on an engine similar to the grand theft auto engine in which there is an birdseye view of a map, but it is 3d and you cant rotate the camera. All you can do with the camera is move it up/down left/right and zoom in and out of the map. The map is composed of tiles (there is no height yet). Now, lets say the camera is 6 units above the map and there is a building that takes up one tile, and it is 4 units high. How would I detect when the mouse clicks on the building in the viewport...if you think about it, when the camera moves, and the building moves away from the center, it changes shape due to perspective. I can''t figure this one out. I know this probably seems very criptic, but I am hoping someone understands what I am trying to say. _____ Mike Henry bawbmarli@aol.com ¯¯¯¯¯

Share this post

Link to post
Share on other sites
Assuming that z defines the height above the ground and x and y is the coordinate in the map.

Start by finding the tile that the camera is over then follow the ray until it reaches the edge of this tile. There you check if the z value of the ray against the height of the tile. If it is below the you the ray hits the tile if not you start over with the next tile that the ray enters and first checks if the ray is above the tile then follow it until it reaches the edge of that tile test against the height of the tile again and so on.

Of course you still need to compute the direction of the ray from the mouse pointer, but that is done just as in all the other threads about object picking and ray/triangle intersection that has been here lately

- WitchLord

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!