Three-dimensional drawing can become very complex. Most three-dimensional models are created with a series of planes that represent the shell of the object. If the planes are filled, then the plane is considered to be nontransparent. Similarly, if the plane is not filled, the plane is considered to be transparent.
When rotating or moving three-dimensional objects, it is often necessary to remove parts of objects, or even entire objects, in order to provide realistic representations of the environment. The method by which these objects are altered is called hidden surface removal. The most common types of hidden surface removal are discussed in this tutorial.
There are two basic types of hidden surface removal. These are object-space methods and image-space methods. Three-dimensional information is used with object-space methods to decide which surfaces should be hidden and which surfaces should overlay others. Image-space methods use two-dimensional information to determine the hidden surfaces.
The most common method of hidden surface removal for personal computers is probably the plane equation method, which is an object-space method. In general terms, the plane equation method determines if a point is in front of, on, or behind a specified plane. By testing each point against the viewing position, always (0,0,0), the visible and hidden planes are determined.
The equation of a plane is:
Ax + By + Cz + Dwhere x, y, and z define a point on the surface of the plane. The A, B, C, and D values are constants and are derived as follows when three points on the plane are specified (x1,y1,z1 ; x2,y2,z2 ; x3,y3,z3).
A = y1(z2-z3) + y2(z3-z1) + y3(z1-z2) B = z1(x2-x3) + z2(x3-x1) + z3(x1-x2) C = x1(y2-y3) + x2(y3-y1) + x3(y1-y2) D = -x1(y2z3-y3z2) - x2(y3z1-y1z3) - x3(y1z2-y2z1)By identifying three points on a plane, solving for A, B, C, and D, substituting A, B, C, and D into the plane equation, and passing each object point through the new plane equation, you can determine whether or not each point is on, in front of, or behind the defined plane. If the plane equation evaluates to a positive value, the point is hidden. If the plane equation evaluates to zero, the point is on the plane and is usually defined as visible. If the equation evaluates to a negative value, the point is visible.
When using this method it is important that the points used to derive the equations are plotted in a counterclockwise direction and can be viewed as part of a convex polyhedron. A convex polyhedron is a figure that has many faces and is curved outward, such as a cube.