• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL



Topics in This Chapter

  • Customizing the color of shapes using the Appearance and Material nodes

  • Creating dull, shiny, glowing, and transparent surfaces

  • Wrapping images around shapes ("texture mapping")

  • Using the TextureTransform node to control texture mapping

In the previous chapter you learned how to customize Java 3D scenes by moving objects around and changing their physical attributes. As you have seen with VRML in Part 2 of this book, however, you can customize more than just the position, orientation, and scale of objects in a 3D scene. In this chapter you learn how to customize the color and texture of Java 3D objects, just as you learned how to customize these properties of VRML objects in Chapter 8, "Customizing Color and Texture."

In comparison to the techniques discussed in the previous chapter, customizing color and textures will seem somewhat awkward at first. Modifying the position, orientation, and scale of objects as you did in Chapter 13 revolved around modifying portions of the scene graph that corresponded to externally loaded files. By simply wrapping an extra TransformGroup node around each piece of the scene graph delivered by the loader you were able to customize the position, orientation, and scale of objects in the scene.

In comparison, customizing the color and texture of Java 3D content is a entirely different story. Both of these attributes are relative to the individual object. In a complex model, you can easily have hundreds of surfaces, each of which might have its own unique color and texture (we say might, because colors and textures can be shared by objects, as you'll learn later in this chapter). All of this is hidden from view by the convenience of the loader mechanism, meaning that you won't have easy access to color and texture information of externally loaded objects.

For the purposes of this chapter, therefore, we'll assume that you will be customizing the contents of a Java 3D program whose objects are created directly in Java 3D code. In other words, you can view, edit, and recompile the Java 3D code that corresponds to the objects that you wish to customize (i.e., any object that is not brought into the program through a loader). If you don't already have a suitable program to customize, you can get your feet wet by customizing one of the demonstration programs provided with your Java 3D implementation. Sun's Java 3D implementation, for example, comes with a sample program called AppearanceTest that is an ideal companion to this chapter. Alternately, you can use the source-code examples provided in the text that follows (visit the Core Web3D Web site at http: //www.CoreWeb3D.com/ to download code samples used in this book).

Note: Java 3D and VRML

Java 3D's color, shading, and lighting models are very similar to those used by VRML; once you know how to customize object appearances in VRML you'll find that it is relatively simple to do the same in Java 3D. With this in mind (and in an effort to reduce redundancy), many of the basic concepts introduced in Chapter 8, "Customizing Color and Texture," do not appear in this chapter.

The concept of mixing RGB colors, for example, is covered in detail in Chapter 8, and so it's assumed that you already know the basic principles behind RGB colors as you read the material that follows. Likewise, a detailed overview of light reflections (specular reflections and shininess, for example) and texture mapping (applying an image to the surface of shape) is not provided here, as these and other general color and texture topics are covered in detail in Chapter 8. This chapter instead focuses on fundamental, Java 3D-specific concepts that you must know to customize the color and texture of Java 3D objects.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint