Sign in to follow this  
Mr Lane

Zooming in Othographic mode

Recommended Posts

Mr Lane    178
Hello I was wondering what is the best way to implement Zooming along the Z axis in ortho mode. At the moment i just scale up and down the items in the viewport to simulate zooming. The problem with this, is when I have zoomed out a long distance from the scene and I pan the view in X and Y with the mouse, the panning is very slow...when I am zoomed in closely, the panning is so sensitive. I know why this is happening, but I cant think of a way around it, except to derive some sort of mathematical function that increases the speed of the panning at long distances and slows it when the zoom is in close. In additon when in-close zooming isnt very sensitive, but when zoomed out only a slight movement of the mouse greatly changes the change in zoom. Is there a better was to do zooming? Of course the order I do things in 2D is scale and translate, rather than translate and scale (else the scaling occurs around the point of translation rather than the centre of the viewport. Also another thing unrelated, what does "Render to Texture" mean just briefly? Thanks

Share this post


Link to post
Share on other sites
TomasH    360
Hi,
Another way to do zooming, is to change the size of the view volume (the left, right, bottom and top values for glOrtho). When zooming in, you would make the volume smaller, and when you zoom out you would make it bigger.
As for the mouse sensitivity, well either you could divide mouse movements by the "zoom value" (so that if you have zoomed in to 2x the original size, all mouse movements would be divided by 2) or you could use glUnProject on the mouse positions to find out how far the mouse pointer has moved in world coordinates. These are just ideas, mind you. I haven't actually tried them.

Render to Texture means just that - you render to a texture instead of rendering to the screen. This could be either by first rendering to the back buffer and then copying to a texture with glTexSubImage2D or by using pbuffers.

Share this post


Link to post
Share on other sites
Mr Lane    178
Yeah i tried dividing by the scale value, but the most odd thing happens: zooming behaves the same as when i apply transformations before scaling...in other words:

glScalef(zZoom2D, zZoom2D, 1.0);
glTranslatef(1*xPos2D/zZoom2D, -1*yPos2D/zZoom2D, 0.0);

Is the same as:

glTranslatef(1*xPos2D, -1*yPos2D, 0.0);
glScalef(zZoom2D, zZoom2D, 1.0);

Which isnt suitable, as scaling needs to be applied first here...

Share this post


Link to post
Share on other sites
zedzeek    529
u misunderstand u dont call scale translate etc
as TomasH said u go
glOrtho( left*scale, right*scale, up*scale, ... )

Share this post


Link to post
Share on other sites
Mr Lane    178
Nah i knew what he meant, but it stiil presented the same problems, so I stuck with scaling. I have implemented a solution, not elegant, but it adjusts mouse sensitivity incrementally as you zoom out, and zooming out is slower the further you zoom out.

Thanks for the help anyway, I didnt think about using the viewport to alter zoom.

Share this post


Link to post
Share on other sites
ViperG    206
When your in Ortho mode, your supposed to use GlRotatef(ZOOM_HERE!, 0,0,0);

This is designed to transform the matrix. You can zoom out but can't zoom in.

So if you wan't it to work correctly start drawing at the cloest level, and then zoom out to where you want.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this