#### Archived

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.

## 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 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

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

• 12
• 15
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632656
• Total Posts
3007678
• ### Who's Online (See full list)

There are no registered users currently online

×