Reputation: 2166
I am building a scale model of buildings and landscape. I'm using openGL and GLUT and the function gluperspective. I know that the last two parameters of the function define the z-clipping path and can only be positive. Well I have stuff getting rendered with a negative z value. Well it is getting clipped which makes sense. Does anyone have a suggestion on how to stop this from clipping my things with a negative z value? My call to the gluperspective is below.
gluPerspective(50.0, (double)w / (double)h, 1.0, 300.0);
Upvotes: 1
Views: 3502
Reputation: 2645
There is a difference between the zbuffer and the z value in 3d space. Imagine that you have a camera and are holding it up to your eye. The 1.0 is the camera's screen (i.e. the closest an object can get to you), and the 300.0 is the furthest the camera can see. These define the zbuffer's "range" (which sets up clipping).
Now what if you have an object behind you? Well then the z-VALUE (not z-buffer) is negative. How do you see it? Just turn around (effectively pointing the camera in a new direction. The z-buffer stays the same (i.e. objects closer than 1.0 or further than 300.0 are not visible), but the object that has the negative z-VALUE is not visible.
So with gluPerspective, you set up your perspective matrix (i.e. the camera's field ov view and range). Then to see objects behind you, you need to set up your view matrix (i.e. the camera's orientation).
Edit: So to see stuff that has a negative z-VALUE (without turning around), move your camera backwards (i.e. change your view matrix, so that it is positioned further back).
Upvotes: 2