< Zurück | Inhalt | Weiter >

9.1 Introduction

Java 3D contains a host of classes to specify the rendering attributes for geometric primitives, such as color, texture, back−face removal, and so on. Java 3D defines “has−a” relationships between the classes that control overall rendering appearance. For example, an Appearance has a Material class, a PolygonAttributes class, a RenderingAttributes class, and so on. This is one of the best−designed areas of Java 3D; with a little experience you can quickly learn to navigate the various classes that, when combined, specify object appearance. Compared with learning the plethora of separate OpenGL methods to specify appearance, the OO nature of the Java 3D design pays dividends.

An instance of an Appearance object is associated with each Shape3D geometric object in the scenegraph. The Appearance object defines rendering state information that must be applied to the rendering pipeline before the raw geometry within the Shape3D is rendered.

It is useful to think of the Java 3D renderer traversing through the defined scenegraph; when it encounters

TransformGroups, it applies matrix transformations; when it encounters a Shape3D Node, it applies

the Shape3D’s Appearance state—all before executing the Shape3D object to generate native graphics API calls.

What follows is an overview of the NodeComponent−derived classes that define a Java 3D rendering state for a Shape3D object. Emphasis is placed on areas of potential confusion or typical problems. Consult the detailed Sun API reference for a method−by−method summary of the classes. I have prefaced each section with a table listing the capability bits that control access to the specific feature being discussed. The tables include references to OpenGL functions where appropriate and useful.

One of the lengthier examples of the book accompanies this chapter: AppearanceTest (illustrated in figure 9.1) allows you to dynamically modify most of the Appearance attributes on a simple scene. I encourage you to examine the code for the example and run it as you work through this chapter—most of the sections will be significantly clarified by this interactive example.


Figure 9.1 The AppearanceTest example application allows Appearance settings to be modified at runtime