Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

3D computer graphics: Moving from wire-frame drawings to solid, shaded models

Find out how to create surfaces and add illumination to make your models more realistic

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Raise your hand if you haven't seen Toy Story -- the computer-animated extravaganza from Walt Disney Pictures and Pixar. For those of you who missed out, Toy Story, was the first fully computer-animated feature film in the history of motion pictures. I mention this in order to illustrate the role 3D computer graphics are beginning to play in our society. As I noted back in my first column on this topic, 3D computer graphics have made the leap from the benches of government and university laboratories into the heart of corporate America.

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.

Looking beneath the surface

Last month I presented a portal that rendered a scene (or model) as a wire frame. To see that applet in action, take a quick look back at "3D computer graphics: Slide it, spin it, make it move -- transforming your virtual world."

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.

The painter's algorithm

The painter's algorithm is based on a very simple observation: surfaces that are farther away from us are blocked by surfaces that are closer to us.

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.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (5)
Login
Forgot your account info?

A parametric feature based modeler is a Computer-aided design (CBy samtha on October 1, 2009, 3:57 amA parametric feature based modeler is a Computer-aided design (CAD) .... The ability to dynamically re-orient the model, in real-time shaded 3-D, ... Engineering...

Reply | Read entire comment

louis vuitton bagsBy Anonymous on September 23, 2009, 11:04 amI’d love to discuss louis vuitton outlet, but I am not sure if you really have one. This louisvuitton is so unique, and I never see it’s sold in the LV stores,...

Reply | Read entire comment

Re: How can I download it?By Anonymous on July 30, 2009, 6:17 amThe first and most obvious way would be to obtain the source and compile it yourself. However, another method involves going into your cache (Tools -> Internet Options...

Reply | Read entire comment

The applets don't work!By Anonymous on July 30, 2009, 6:12 amThe above two applets don't work! I opened up the Sun Java Console and for the first applet it says: java.lang.VerifyError: (class: Scene, method: elements signature:...

Reply | Read entire comment

How can I download it?By Anonymous on January 24, 2009, 3:37 amHow can I download it?

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources
  • Previous How-To Java articles