Advertisement

Mouse Coordinates

Started by May 19, 2003 09:00 PM
0 comments, last by _chucky 21 years, 9 months ago
What I want is the user to be able to click on my OpenGL window, with the x y coords I want to be able to transform that into a point on a plane facing the camera, with a distance of say s from the camera. So far to calculate the coordinates of the point is first scaling the x y coordinates so that they are between -1 and 1, here is the code I have been using: pos_y = (GLfloat) (view[3] / 2 - y) / (view[3] / 2) * 0.392699081; pos_y = 4 * tan(pos_y); newCenter.y = pos_y; pos_x = (GLfloat) (x - rect.right / 2) / (rect.right / 2) * fov_x; pos_x = 4 * tan(pos_x); newCenter.x = pos_x; (btw the 4 is the distance the plane is from the camera) This works resonably well, however the point is not exactly where I click - the further I get from the center of the window the more the point is offset from the the actual position, do I like have the completely wrong equation that just happens to kinda work or maybe I just need to scale it or something. Any advice?
Hey i cant help you, i just wanted to say i had same problem, but i was making it by taking camera vector + some mouse coordinates, but i wasn''t precise enough, because more i get from center of screen more is it disorted.

This topic is closed to new replies.

Advertisement