View Full Version : Whats wrong with this bit of code?

07-01-2000, 07:19 AM
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.

07-01-2000, 12:44 PM
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:

gluLookat(MC.x,MC.y,MC.z,Ship.x,Ship.y,Ship.z,0.0, 1.0,0.0)

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).]

07-01-2000, 12:47 PM
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.