I have a program where my camera roams around a forest that is 20X20 units. My problem is that I can’t get the perspective right. My trees are 0.2 units wide.
Here is the code that causes the problem.
gluLookAt(view.x,view.y, view.z+0.5, view.lx, view.ly, view.lz, 0, 0, 1);
Originally posted by Terminatore3:
A znear of 0 is invalid and will kill your zbuffer, it must be a value greater then zero, try 0.1 instead.
A FOV of 120° is kind of extrem, I usually go for 45-60 depending on the situation.
Two more issues:
You have to use gluPerspective OR glOrtho, not both of them.
On the projection matrix you should have ONLY the projection, not the camera transformation.
gluPerspective(60, (float)width/(float)height, 0.1, 50);
width and height are the dimensions of your window. The near plane should be set a bit away from the origin, never set it to 0. The far plane has to be far enough to see something, I think in your case 50 should be enough. You can play around with these values…