PDA

View Full Version : Help with perspective



EdenMatrix
05-10-2000, 01:27 PM
Hello. I am making a program that simulates a simple solar system and allows the user to navigate through it. I have a sphere for the sun and a small planet rotating around it. Everything seems to work fine, except when I get close to the sun it seems distorted if it is near the edges of the screen.

My question is, how would i correctly setup the perspective using the glFrustum()?

Logically, i would set a very small viewing area since the viewer is very small compared to the objects in the solar system, and a very large 'far' distance since the viewer can see deep into space, but i'm not sure what the near parameter does. When i tried setting the viewing area very small and 'far' very large the distortions went away but then the engine would have problems with the hidden structure removal when the planet went behind the sun.

As you can see i'm very confused. =) Any explanation would be greatly appreciated.

Thanx!

Gorg
05-10-2000, 02:51 PM
try to make you Near plane far away from the viewer. It's a problem with the z-buffer.

so instead of putting your near plane at 0.1 or 1 put it at 10,50,100. Large, and change your left and top dimension accordingly. You should less are no z fight.

because of the perspective projection, the z values in the z buffer are not distributed uniformly. So making the zNear bigger, helps making them more uniform, because it gets closer to the far plane wich gives a projection wich is closer to an orthographic one, and hence, uniform distribution.

You could also make the far plane closer, but because of the projection formulas, making the near planer farther gives better results