Advertisement

Mapping Screen Coordinates to a a rotated map

Started by October 12, 2002 10:43 PM
-1 comments, last by Fonz 22 years, 4 months ago
Hey, Ive hit a bit of a predicament, Im using open-gl but I dont think that really matters, The Information I have: * the eye perspective position * the eye hover point (where the eye is looking) -- this is the middle of the screen. * the difference in X, Y, Z between the eye point, and the hover point. * mouse coordinates, window range * the minimun & maximum X,Y map coordinates on the screen Firstly, What Im doing is getting the mouse-click screen position, mapping that to the unrotated game map (which is being displayed) ie so if map position 15,100 was at the top left of the display, the mouse click at the top left (0,0 - screen coordinates) is mapped to 15, 100. * this is easy to do. Then, (mouse click independant) I get the X angle by taking the eye point height, and the difference in X (between the eye and hover); * also with the Y angle. Using this angle I take the mouse coordinates (after they''ve been mapped to map coordinates) and calculate the real (after rotations) map position. I then get the difference between this new point, and the central hover point, and add it to the central point to get the mouse click.. (I then use a ray between the eye and this point, to get the exact click position.. this is to avoid hills ) Sorry about the explanation, Ask questions if you have any.. My problem is that this works fine with 1 axis being rotated at a time. However, If I rotate (move the eye) along both X and Y then this method only works for X, the Y coordinates generate errors. Can anyone help me? cheers, Fonz

This topic is closed to new replies.

Advertisement