RE: [Algorithms] visualizing frustum planes?
Brought to you by:
vexxed72
From: Pallister, K. <kim...@in...> - 2000-08-22 05:38:53
|
Also, if you are on DX7 or OpenGL 1.1, you can download the eval version of GPT from Intel's web site. It include's a 'wide angle' and 'reverse wide angle' view that will do this transparently for you. Just run the EXE through it and voila. Kim Pallister We will find a way or we will make one. - Hannibal > -----Original Message----- > From: Michael S. Harrison [mailto:mic...@ud...] > Sent: Monday, August 21, 2000 11:31 AM > To: gda...@li... > Subject: Re: [Algorithms] visualizing frustum planes? > > > Duh. This is precisely the reason I like working on teams > where more than one person is familiar with a given system. > Sometimes having someone state the obvious is a good kick in the seat. > > It hadn't even occurred to me to use an artificial model > matrix and draw the simulated frustum planes, in order to > check (and help visualize) the camera math > > At 07:10 PM 8/21/00, you wrote: > >Hey, > > > >Here's a piece of code which will render the camera frustum, > which I find to > >be useful when hunting camera problems. It works best when > viewed from a > >second camera though (since the frustum is mostly clipped by the very > >frustum planes it is meant to visualize), with the AABB > culling code (or > >whatever you may end up using it for) hardwired to the first > camera - only, > >the second camera should just render everything, or only > rely on culling > >code of which you're certain that it works. > > > >----8<---- > > float ax, ay, bx, by, fx, fy; > > static Vertex verts[8]; > > static ushort indices[24] = { > > 0,1, 1,2, 2,3, 3,0, > > 4,5, 5,6, 6,7, 7,4, > > 0,4, 1,5, 2,6, 3,7 > > }; > > > > // Calculate fov/2 angles in x and y direction. > > ax = mFov / 2; > > ay = ax * ((float) mViewport.height / (float) mViewport.width); > > // Calculate x/y coordinates of the front plane. > > fx = mFront * (float) tan(ax); > > fy = mFront * (float) tan(ay); > > // Calculate x/y coordinates of the back plane. > > bx = mBack * (float) tan(ax); > > by = mBack * (float) tan(ay); > > // Setup frustum verts. > > verts[0].loc.set(-fx, +fy, mFront); > > verts[1].loc.set(+fx, +fy, mFront); > > verts[2].loc.set(+fx, -fy, mFront); > > verts[3].loc.set(-fx, -fy, mFront); > > verts[4].loc.set(-bx, +by, mBack); > > verts[5].loc.set(+bx, +by, mBack); > > verts[6].loc.set(+bx, -by, mBack); > > verts[7].loc.set(-bx, -by, mBack); > > for (short i = 0; i < 8; i++) > > verts[i].color = Color3(0.8f, 0.8f, 0.8f); > > // Render frustum. > > GfxDevice->SetTransform(eTransformWorld, mMatrix); > > GfxDevice->Draw(GfxDevice::PrimLineList, verts, 8, indices, 24); > >----8<---- > > > >If you have any questions about the specifics of the above > code, mail me > >offline. > > > >HTH > > > >Jim Offerman > > > >Innovade > >- designing the designer > >----- Original Message ----- > >From: "Michael S. Harrison" <mic...@ud...> > >To: <gda...@li...> > >Sent: Monday, August 21, 2000 9:18 AM > >Subject: [Algorithms] visualizing frustum planes? > > > > > >> I'm attempting to implement the AABB culling code talked > about here some > >time ago and I'm running into a general problem in > visualizing the frustum > >planes used to cull objects based on their AABB's > >> > >> I'm using both Klaus Hartmann's AABBCull sample and the > Viewcull sample > >included with the OpenGL FAQ. > >> > >> While the code generally works, I'm having some difficulty > visualizing the > >relationship between the plane vector and the "distance" > value stored with > >it, which I'm sure is the reason I can't quite figure out > why the code > >generates intersection results when it should generate a full cull. > >> > >> As you might guess, I'm fairly new to the world of 3d > projection and I'm > >still wrapping my mind around all the transformations that > take an object > >from "world" space to screen space. > >> > >> Can anyone suggest a reference or way to visualize exactly > what's going on > >with the plane extraction and how the vectors relate back to > the AABB? > >> > >> > >> _______________________________________________ > >> GDAlgorithms-list mailing list > >> GDA...@li... > >> http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list > >> > > > > > >_______________________________________________ > >GDAlgorithms-list mailing list > >GDA...@li... > >http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list > > > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list > |