Whats wrong with this bit of code?

void RenderCamera()
int tx,ty,tz;

glTranslatef(0,0,-Mcamera.zoom);  // bigger zoom is farther out you go




I want the camera to rotate around the target ship. It’s pretty basic code. But something is wrong and it translates funny or rotates funny.
I’m just not sure if it’s a GL problem or my own error.

I think the problem might be in the zoom out… I didn’t really look at it too carefully.

I recommend using gluLookat()… with something like this:


Try this and let me know… for zooming you’re probably going to have to use some trig if the ship is moving!

[This message has been edited by ngill (edited 07-01-2000).]

You might want to swap the order of the translation and rotation (depending on what effect you’re trying to accomplish).

Also, is this code run before you render the scene (in the scene view matrix mode) or in the project matrix view mode?

Last, I would suggest changing the edge coordinates (or the near clipping plane location) rather than move the camera when zooming in/out. I think that looks better; it certainly emulates the real effect of a zoom lens much closer.