

I think that somewhere I am not taking into account the zoomOut factor when maintaining the mouse position.ĮDIT * *********** here is my final code that I am still struggling with. Seems to work, but frustrum jumps when I make a new click. (0 - mouseStoreY) * zoomOut + mouseStoreY, (window_height - mouseStoreY) * zoomOut + mouseStoreY, (window_width - mouseStoreX) * zoomOut + mouseStoreX, (where mouseStoreX and mouseStoreY are the position saved on the first click) glOrtho( (0 -mouseStoreX )* zoomOut + mouseStoreX, I am trying to get the coordinates in feet from my mouse cursor coordinates. My question is, how do I zoom in using the mouse position as the center? glOrtho( 0 * zoomOut, window_width * zoomOut, window_height * zoomOut, 0 * zoomOut, 100, -100) When I execute the zoom function in the mouse callback, I multiply the frust edges by the zoom factor. Then I set glOrtho so that my frustrum forces the screen coordinates to match the world coordinates. I have set the viewport to standard width and height. Watch it be like some simple thing that I figure out right after posting Though maybe someone can help me get proper screen-to-world actually working though, which it would be cool.I am currently using glOrtho for zooming and panning a 2D plot I am presenting. I apologize if this post sounds garbled or stupid, I haven't gotten much sleep in the last 48 hours.

I hope I didn't place this in the wrong category too. I'm only using SFML::Window currently for window creation, so I don't think I can use the screen coord conversion in SFML::View.

Longer term, I tried to use gluUnProject and such to get world coordinates, but it was always inaccurate in the results. When I click on the edge of the cube, I would expect values close to -1 or 1. The dimensions of the cube are -1 to 1 on all sides.

The further from this 'origin' I click, the larger the misalignment gets. This point scales with window size as well to remain around width/2,height/6. For testing purposes, I am displaying a cube. Specifically, with the default 800圆00 window size, there is a point at 400,100 where the two coordinates do appear to line up properly. Normally I'd feel pretty emarassed to post what could just be a math stupidity on my part, but maybe someone else can give me a quick answer. I am displaying a building model and would like to know the actual object coordinates of a mouse click on the building. Anyway, my overtired brain can't seem to piece it together. So, if I have an object at say (256, 90, 7) in opengl space, and I want to know when the mouse is near 256, 90, it seems like it would be a simple addition of half the width and height of the window, but that only works I think when its in that quadrant. For what I need it would seem like a simple formula (or multiple formulas) to transform top/left to center would suffice, at least for now as a hack until I have time later. It's basically a mouse picking (screen to world coord) problem, but I have zero time to implement a big color checking, raycasting, etc, solution. The mouse coordinates are retrieved from top/left right? Can anyone tell me what formula would be best to convert this to start from the center of the screen (opengl style)? Everything I come up with has a flaw, but maybe I have to have a bunch of ifs to check for what quadrant the mouse is in and then do something different? It sounds like a stupid question, but my brain just doesn't seem to be working today. I haven't been able to find anything that directly does what I want here. I've been trying to figure this (mouse picking and coordinates) out all night and I'm getting nothing but a headache.
