PDA

View Full Version : Clipping planes



Pat
01-22-2002, 08:20 AM
I'm working on a CAD package. One of the features in the app is the ability to define a clipping plane to "slice" a model to allow the user to view to the internal structure. The interface renders this clipping plane with a translucent quad so that the user knows the location of the clipping plane. The user can then use a slider control to move the clipping plane through the model. Everything works great until I received the request to allow the user define a custom vector for the clipping plane as opposed to the XY Plane, XZ Plane, or YZ plane that I've already implemented.

The actual clipping of the model is easy. I'm running into difficulty drawing the quad representing the clipping plane. I know the bounding box of the model, and I know the vector of the plane. How do I determine the four corners of the quad. Has someone out there done something similar to this that can help?

Thanks
Pat

knackered
01-22-2002, 08:39 AM
Yes, I've done something similar.
My brief was to not only clip the geometry against the plane, but also to accumulate all the intersection points of all the triangles that intersect the plane and draw them as connected lines! This meant that I basically had to do the triangle clipping manually.
Once you've got all the intersection points, you just transform them onto an axis aligned plane (using the inverse transform of the clipping plane) and do a simple test on every intersection point to find the extremeties - then use that information (min + max) to define a quad on that axis aligned plane - then just transform the points of this quad by the original planes transform to get a nice 2d box that encloses all the clipped geometry.
Phew! It was a fiddly thing to do, but its done now.
Best of luck.