Unusual raypick situation

Started by
0 comments, last by bawbmarli 23 years, 10 months ago
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 ¯¯¯¯¯
_____Mike Henrybawbmarli@aol.com¯¯¯¯¯
Advertisement
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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement