Most read:
Popular archives:
JavaWorld's new look is here!
We've upgraded the site with a fresh look-and-feel, improved topical navigation, better search, new features, and expanded
community platform. Learn more about the changes to JavaWorld.
| Oracle Compatibility Developer's Guide |
| The Explosion in DBMS Choice |
Now, it may surprise you to know that the techniques I've demonstrated in this column and the techniques used by the folks at Pixar in Toy Story have a lot in common. We certainly won't be covering everything the guys at Pixar know in this series of columns, but the material presented here will provide you with the foundation that all 3D computer graphic concepts rest upon. After all, 3D computer graphics, whether used in a movie like Toy Story or in an applet in one of my columns, begins with a model of the world (Toy Story required over 400) and ends with a picture on a computer screen.
With this in mind, let's begin.
While wire-frame drawings are a fit vehicle to introduce the topic of 3D computer graphics, they suffer from several shortcomings. In particular, they display only the edges of a model. Of course, that limitation is also one of their advantages. Edge information is faster to process and to display. Consequently, large wire-frame drawings often can be manipulated in real time, while more realistic drawings cannot.
None the less, the illusion of reality suffers. Real objects have surfaces, or faces, not just edges (you can't see through them as you can with a wire-frame object). The modeling environment we've been working with in previous months contained information about edges only. Remember, the basic unit of construction is the triangle. To add surfaces to our model, we simply need to draw solid triangles instead of just their edges.
No problem, right? Wrong. Unfortunately, the order in which we draw these triangles is very important. In fact, it is the most challenging part of creating the applet in this article.
The painter's algorithm provides us with one way to properly draw surfaces. Let's take a look at this technique.
Take a look at the following series of illustrations, which show a cube in the process of being drawn -- first the back face (A), then the two sides (B), and finally the front (C). The faces drawn last (those toward the front) obscure the appropriate parts of the surfaces drawn earliest (those toward the rear), creating a very natural effect. This is the essence of the painter's algorithm -- draw the farthest faces first and the nearest faces last.