[quote]I’m using glOrtho on an object I drew, but now I’d like to zoom in and out on it. I know how to translate left, right, up, down, and make it rotate, but I can’t make it zoom.
It seems that if I use my + or - keys, the near and far panes of my viewing volume are what’s being moved because it starts to clip my object either in the front or back. That’s done w/ the following code (I add and subtract to the ztrans variable in my glTranslatef()) which I think is wrong for zooming in or out.
public void display(GLDrawable drawable) {
…
gl.glTranslatef(xtrans, ytrans, ztrans);
…
}
Any help much appreciated.
[/quote]
glTranslate does exactly what it says on the tin
You could certainly use it to pan around your ortho view but if you translate along the Z axis , presuming you haven’t done any rotations before hand, the translation will result in your objects being drawn further away from or nearer to the near clip plane. Eventually they’ll be clipped. translating along the Z axis will make things bigger or smaller if you use a perspective transform , but ortho uses an orthographic transform which discards that notion*. To zoom in an orthographic transform you can either apply a scalef to the entire scene, or change the extants of the ortho transform itself. The latter is probably the best way to do it.
D.
*I was just reminded of that episode of Father Ted when i was writing this. “now Dougal, those are SMALL, those other ones (points out the window) are FAR AWAY”. ah the funnies.