PDA

View Full Version : clipping outside of z 1 and -1!



beeduul
04-02-2004, 10:15 AM
My app is clipping anything that falls outside of z 1 and -1! (so it's showing stuff that should be behind the camera which is at 0,0,0 and peering down the negative z axis)

I want the clipping to be between 1 and 200 (or whatever I am using for the depth range).

Do I need to set the plane equations for the clipping planes?

I am not using the GL matrix funcs, I am using my own Matrix class but it has worked fine in the past.

I'm a bit exasperated, please help!

chowe6685
04-02-2004, 11:20 AM
you need to change the projection matrix, right now its the identity which indicates a far and near plane of -1 and 1 as you are experiencing. If you want everything else to remain the same you could use glOrtho to change the clip planes in the projection matrix

look at this:
http://pyopengl.sourceforge.net/documentation/manual/glOrtho.3G.html
its the matrix generated by glOrtho, you could use that to change the clip planes with your own matrix

beeduul
04-03-2004, 05:38 AM
Thanks! It worked, but I still don't quite understand how glOrtho is affecting the clip planes. Is it simply projecting the coordinates between the -near and -far planes into the unit cube, which is still clipping between z -1 and 1? Or is it actually changing the clip planes?

After the call to glOrtho, my objects don't seem to clip anywhere anymore. Even if I push them back way beyond the bounds set with near/far planes in glOrtho, they don't clip anymore.

Still slightly confused, but not quite so exasperated...

zeckensack
04-03-2004, 11:23 PM
There are two matrix stacks in OpenGL that transfer geometry from one space into another.

World space => modelview matrix => eye space => projection matrix => clip space
Clipping is done in clip space, obviously :)
All generated fragments have |x|>=w, |y|>=w, |z|>=w. Everything else is clipped away.


It worked, but I still don't quite understand how glOrtho is affecting the clip planes.It doesn't affect the clip planes themselves. It affects the transformation to clip space, which is a subtly different thing.


After the call to glOrtho, my objects don't seem to clip anywhere anymore. Even if I push them back way beyond the bounds set with near/far planes in glOrtho, they don't clip anymore.Maybe you scale by zero along the z axis? Then nothing would be clipped by the near/far planes, regardless of z.

If you could show us your glOrtho call or, more generally, what matrices you load on the modelview and projection stacks, we might be able to tell you what's going on.

beeduul
04-11-2004, 04:28 PM
thanks for the response and sorry for the delay. i have been working on my code. i have the clip planes mostly sorted out. i am not using any GL matrix manipulations, i am doing the math with my own code. i am having a few more minor problems but i am nailing the bugs one by one so hopefully will eventually achieve perfect code bliss. however i may be back if my programmer ego bursts again.