View Full Version : Nonlinear zoom
05-07-2002, 09:17 AM
Any ideas for a nonlinear zoom using the mouse?
So, zoom out is slow when zoom factor is very small and zoom out
is fast when zoom factor is very large.
Linear zoom makes zoom in very slow, and zoom out very fast.
05-08-2002, 04:07 AM
if (zoom_in) zoom_factor*=1.1f;
if (zoom_out) zoom_factor*=(1.0f/1.1f);
//clamp zoom_factor to min/max values hereAs most non-linear animation stuff, this is hard to get right if you want to make it fps-independant.
It's better to use the fov angle of the projection matrix setup for zooming. This will also work nicely with linear adjustments.
05-08-2002, 07:40 AM
Sorry, I forgot to mention that it's a windowed, 2D ortho projection
for a basic 3D modeller I'm writing, if that helps any.
I'm basically doing what you described, is that I have a zoom_factor,
and based on the mouse movement delta, I multiply it with mouse_dy.
However this zoom_factor is still linear.
How would I get a nonlinear zoom_factor that slows down when the
zoom_factor is less than 1?
05-08-2002, 08:32 AM
float fudge_factor; http://www.opengl.org/discussion_boards/ubb/smile.gif //<- adjust this one with mouse movement
This way you can apply any arbitrary mapping between the mouse position and the actual zoom factor.
You can do some stuff with an interpolated table lookup or a function with exp, log, square roots, whatever works for your application.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.