I’m having a problem trying to zoom in and out of my models smoothly. What I have below works, but the more I zoom in (or the larger it gets) … the bigger the jump it makes to the next zoom level and the model doesn’t appear to “grow” proportionately or smoothly. Pressing the + or - key makes big jumps on the size of the model.
So I’m wondering what better ways to do this would be. Any help much appreciated.
I use glOrtho to zoom in and out of my model.
public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
...
gl.glOrtho(-winWidth * getScaleFactor(), winWidth * getScaleFactor(), -winHeight * getScaleFactor(), winHeight * getScaleFactor(), 100, -100);
...
}
Here is the code where I set the zoom value and depending on the model I display, the 0.005 value doesn’t work to well.
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_EQUALS:
glListener.setScaleFactor(glListener.getScaleFactor() - 0.005f);
break;
case KeyEvent.VK_MINUS:
glListener.setScaleFactor(glListener.getScaleFactor() + 0.005f);
break;
}
this.glListener.glDrawable.display();
return;
}