From: Mark Wayland <mwayland@to...>  20010331 00:17:46

Yes, after finally finding this info in the DX8 docs, the near/far clip volume is defined by the inequalities to be w' < x' < w' w' < y' < w' 0 < z' < w' So, my C4C3 equation below should work... but doesn't seem to. I'm currently basing this on the results of my frustum test routine which simply tests a sphere to be on the normal side of the plane(s). This is so trivial (and I've looked at it several hundred times, used it in other projects etc.) that I can't see any problem with the routine  therefore I assumed that the plane equation was stuffed. With an identity view matrix, the normal looks correct in that it points in the direction I expect (opposite to the zbasis vector in the view matrix). Are you able to give any suggestions as to how better determine where the problem lay? Thanks a heap, Mark Original Message From: Gil Gribb <ggribb@...> To: gdalgorithmslist@... <gdalgorithmslist@...> Date: Saturday, 31 March 2001 12:13 Subject: Re: [Algorithms] More on frustum plane extraction >Well, it comes down to the question "what are the z clip space inequalties >for D3D?" > >I thought they used to be: > >0<z<w > >But then I thought they changed them to: > >w<z<w > >But I really don't know. You said near was working, but far was not. If that >is the case then both of these are the same for zfar. What numbers are you >getting? >Gil > > > Original Message  >From: "Mark Wayland" <mwayland@...> >To: <gdalgorithmslist@...> >Sent: Thursday, March 29, 2001 6:21 PM >Subject: [Algorithms] More on frustum plane extraction > > >> Actually the title should read "moron using frustum plane extraction" :) >> >> As you can assume by the previous sentence, I was wondering if any of you >> kind folk out there may be able to help with the frustum plane extraction >> problem I'm having (Gil?) >> >> I have some code which successfully extracts the left, right, top and >> bottom planes but for some reason has a problem with the near and far. >> Actually, I think the near is working too, but it's a little hard to test >at >> the moment. The far plane seems to be the problem. >> >> Firstly, I'm using D3D not OpenGL. That places the restriction on the >> homogenous z' being 0 < z' < 1. I believe in OpenGL this is >> expressed as w' < z' < w' which is where my difficulty comes in. >> >> I thought I understood the math behind it, thanks to Gil's explanation, >> so I derived my own equations to be sure  the left, right, top, bottom >> and near seem to work... >> >> Anyway, here's my derivation for the (near and) far clip plane. >> Can someone show me where I went wrong? >> I've even tried using the eqn 0 < z' < w'. At this point, i'm >> thoroughly confused so any advice would be very welcome :) >> >> in = [x y z 1] >> Cn = nth column in viewprojection matrix. >> >> These basically represent a 4x4 matrix transformation: >> >> x' = in dot C1 >> y' = in dot C2 >> z' = in dot C3 >> w' = in dot C4 >> >> For NEAR and FAR planes, must satisfy following constraint to be in >frustum >> (in D3D terms): >> >> 0 < z' < 1 >> >> For NEAR, 0 < z' => z' >= 0 >> Substituting z' = in dot C3, we get: >> >> in dot C3 >= 0 >> >> So the plane equation is simply C3... >> >> For FAR, z' < 1 => z'  1 < 0 => 1  z' >= 0 >> Substituting z' = in dot C3, we get: >> >> 1  (in dot C3) >= 0 >> >> Now we need the equation in the form of in dot P, so we rearrange >> to give: >> >> in dot ( [0 0 0 1]  C3 ) >= 0 >> >> So the plane equation is [0 0 0 1]  C3 >> >> if the equation should be 0 < z' < w', then >> >> w'  z' >= 0 >> (in dot C4)  (in dot C3) >= 0 >> in dot (C4  C3) >= 0 >> >> Plane equation in this case is C4  C3 >> >> I've tried both and only the near plane equation seems correct. >> Any suggestions? >> >> Thanks a heap, >> >> Mark >> >> _______________________________________________ >> GDAlgorithmslist mailing list >> GDAlgorithmslist@... >> http://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > > >_______________________________________________ >GDAlgorithmslist mailing list >GDAlgorithmslist@... >http://lists.sourceforge.net/lists/listinfo/gdalgorithmslist 