PDA

View Full Version : NearZ and Clipping

wingo
09-25-2008, 08:44 AM
Hey guys, I'm working with a polygon being generated depending on where the nearZ plane intersects other polygons in my scene.

First, I've got a question about NearZ. I altered the value in gluPerspective from 0.1 to 5.0 and my scene wasn't clipped any sooner as I advanced my 'camera'. Is there a way to make that happen?

Now, about this 'nearZ plane' intersecting polygons in my scene. Is there a way to find out the coordinates of where it cuts(preferably on the edges) the polygons.

I'd like to use these intersection points as vertex points to generate a new polygon.

If there's no sure way, what are the coordinates of the nearZ plane? That way i could just use vector math to find those vertex points, right?

Thanks guys

dletozeun
09-26-2008, 08:03 AM
When modifying the znear value in gluPerspective and others, you should see polygons clipping farther from or closer to the camera. You may misuse these functions...

Then, when you set near and far planes distance from the camera, coordinates are in eye space. (Camera is assumed to be at origin (0,0,0) looking toward Z negative axis).

So, to find an intersection with a polygon and the near plane, just transform vertices coordinates in eye space multiplying them by the modelview matrix. After, it is very easy to find the intersection with a vertical plane.

wingo
09-30-2008, 08:24 AM
So I can simulate this plane by creating vertices that are manipulated by multiplying them by the modelview matrix as i move the camera?

Can anyone explain how this works?

Would I be better off writing my own functions w/ some vector math?
I don't know much about the matrices OpenGL uses.