I can't get my head wrapped around this issue. The issue is my latest code is making the camera zoom in and out really quickly.
My approach is built on -
The opengl scale will be getting the variable - scale.
gl.glScalef(scale, scale, 1);
the distance is obtained by between two fingers, old distance (initial touch points), and new distance (dragging touch points). The zooming in and out works well. However, it would reset glScalef each time the user start using pinch zoom.
scale = newDistance / oldDistance;
I tried calculating by additive ratio. The oldtscale handles the previous distance, if it is same, then it doesn't need to add up anything to scale. The zooming is really quick, I moved the fingers closer by mere 1 cm to 5 cm, zoom goes down or up fast. I think additive ratio is a bad solution. I think it might be incomplete solution. I'm trying to figure out what's wrong with it.
//additive ratio
tscale = (newDistance / oldDistance) - 1;
if(oldtscale == tscale) {
oldtscale = tscale;
tscale = 0;
}
else {
oldtscale = tscale;
}
//adding up the additive ratio and scale
tscale = scale + tscale;
//checking tscale for limiting the maximum/minimum scale
if(tscale >= 2) {
tscale = 2;
}
else if(tscale <= 1) {
tscale = 1;
}
//supply scale
scale = tscale;