天天看点

Introduction to Java 3D

Java 3D Concepts

Aspecification serves to define objects, methods, and their actions precisely. It

is not the best way to learn an API. Describing how to use an API belongs in a tutorial

or programmer’s reference manual—and that is well beyond the scope of this

book. However, a short introduction to the main concepts in Java 3D can provide

the context for understanding the detailed, but isolated, specification found in the

remainder of this book.

This chapter introduces Java 3D concepts and illustrates them with some simple

program fragments. Appendix G, “The Example Programs” describes the examples

included with the CD-ROM and highlights particular code segments for some

examples.

Basic Scene Graph Concepts

A scene graph is a “tree” structure that contains data arranged in a hierarchical

manner. The scene graph consists of parent nodes, child nodes, and data objects.

The parent nodes, called Group nodes, organize and, in some cases, control how

Java 3D interprets their descendants. Group nodes serve as the glue that holds a

scene graph together. Child nodes can be either Group nodes or Leaf nodes. Leaf

nodes have no children. They encode the core semantic elements of a scene

graph— for example, what to draw (geometry), what to play (audio), how to illuminate

objects (lights), or what code to execute (behaviors). Leaf nodes refer to

data objects, called NodeComponent objects. NodeComponent objects are not

scene graph nodes, but they contain the data that Leaf nodes require, such as the

geometry to draw or the sound sample to play.

A Java 3D application builds and manipulates a scene graph by constructing

Java 3D objects and then later modifying those objects by using their methods. A

2.1.1 Constructing a Simple Scene Graph JAVA 3D CONCEPTS

12 The Java 3D API Specification

Java 3D program first constructs a scene graph, then, once built, hands that scene

graph to Java 3D for processing.

The structure of a scene graph determines the relationships among the objects in

the graph and determines which objects a programmer can manipulate as a single

entity. Group nodes provide a single point for handling or manipulating all the

nodes beneath it. A programmer can tune a scene graph appropriately by thinking

about what manipulations an application will need to perform. He or she can make

a particular manipulation easy or difficult by grouping or regrouping nodes in various

ways.