Clipping a Line against a 3D View Volume

We can extend the Cohen-Sutherland clipping algorithm, so as to clip lines against a 3D view volume.

This is essentially similar to the 2D case, except now we need a six bit outcode.

The six bits are now:

• Bit 1     point is above view volume
• Bit 2     point is below view volume
• Bit 3     point is to left of view volume
• Bit 4     point is to right of view volume
• Bit 5     point is behind of view volume
• Bit 6     point is in front of view volume

Up to six iterations need to be performed for lines that are neither trivially accepted or rejected.

Clipping a Polygon against a 3D View Volume

The Cohen-Sutherland only clips lines. It is more often the case that we need to clip a polygon (or, depending on our modelling method, some other region containing a 2D area or a 3D volume).

We shall examine an algorithm for clipping a polygon against a 3D view volume.

Sutherland-Hodgeman Algorithm

The Sutherland-Hodgeman algorithm clips an entire polygon against one of the bounding volume edges. The result of this clip is a new polygon, which in turn is clipped against a second edge of the bounding volume. In this way the polygon is clipped against each of the six bounding volume edges.

Starting at vertex A and travelling in an anti-clockwise direction:

• AB intersects the right-side edge and A is outside the right-side edge, so the point of intersection and B is added to the output polygon.
• B and C are both inside the right-side edge, so BC is added to the output polygon.
• CA intersects the right-side edge and C is inside the right-side edge, so C and the point of intersection to A is added to the output polygon.

This output polygon is cliped against the top edge, and so on until all six edges have been clipped against.

Weiler-Atherton Algorithm

The Weiler-Atherton algorithm clips a polygon against a view volume by tracing around the border of the polygon in a clockwise direction until an intersection with the view volume is encountered.

If the polygon's edge is entering the view volume at the point of intersection, it continues along the polygon's edge.

If the polygon's edge is leaving the view volume at the point of intersection, it makes a clockwise turn and follows the line of intersection that the polygon makes with the view volume's clipping plane.

In either case the intersection is remembered and used to ensure that all paths are traced exactly once.

A clipped polygon may be broken into two or more smaller polygons, such as in the case above.

NOTE: The start point can be any vertex of the polygon.

<div align="center"><a href="../../versionC/index.html" title="DKIT Lecture notes homepage for Derek O&#39; Reilly, Dundalk Institute of Technology (DKIT), Dundalk, County Louth, Ireland. Copyright Derek O&#39; Reilly, DKIT." target="_parent" style='font-size:0;color:white;background-color:white'>&nbsp;</a></div>