3D Modeling and Visualization with Java 3D

-Dr. Alejandro Terrazas

Java 3D is an object-oriented, scene-graph–based API for programming interactive 3D content on multiple platforms. Quite a lot of information is in the preceding sentence, so we will spend some time trying to unpack that statement.

Two basic flavors of Java 3D exist: OpenGL and DirectX. Java 3D takes advantage of these lower-level 3D APIs to do rendering; however, it is definitely a mistake to think that Java 3D simply makes bindings to the low-level API. It turns out that calls to OpenGL and DirectX are done through native interface calls, JNI, which are computationally expensive. Therefore, Java 3D performs a large number of optimizations and work in its own renderer before making the precious few calls to the low-level API.

Scene-graph API

One of the most important innovations to occur in 3D graphics programming in the last several years is the development of the scene graph. Two early adoptors of the scene graph are OpenInventor and VRML.

Generally speaking, the scene graph is a formal way to organize your 3D content, and as such it enables a number of optimizations. A full description of the advantages of the scene graph is given in Chapter 10, “3D Graphics, Virtual Reality, and Visualization.” For now, consider that the scene graph organizes the data largely along the spatial dimension. Therefore, culling and other spatial optimizations that reduce the number of computations required for rendering a scene can eliminate entire branches of the tree structure.

Another major advantage of the scene graph approach is that the state of various attributes can be handed down to the children within the hierarchy.

Finally, the scene graph is a structure for managing content. The value of this function becomes apparent when developing a large project.

Object-Oriented 3D Graphics

Object-oriented programming is a natural way to think about 3D graphics. It is much preferable (from a content development and management perspective) than thinking about vertices and triangles. Nevertheless, the 3D content has to come from somewhere. Java 3D allows the developer to get down to the level of the vertices or to import pre-built geometry through loaders.

The other advantage to using object-oriented 3D graphics is extensibility. Java 3D provides a rich mechanism for extension. Developers will find themselves using extension time and time again.

Interactive Graphics

As already stated, Java 3D is generally for interactive graphics. Interactive refers to the fact that the user can make changes to the scene in near real-time. In other words, the model exists to be played with, and the user can create a totally novel view of the model by moving the mouse or interacting with the model in some way. Interactive graphics enable visualization and virtual navigation.

Getting the Java 3D API

Java 3D is freely downloadable from the java.sun.com Web site. There are a number of options for downloading the software. One of the first questions is whether the user wants OpenGL or DirectX versions. Like other Java APIs, there is a runtime version and an SDK. The runtime is there for any user to download and run Java 3D applets and applications. There is no facility for compiling Java 3D programs in the runtime. To write and compile a Java 3D program, the user will need to download the SDK. The most current version of Java 3D is FCS J3D1.3 v1.3 beta2. The Java 3D download includes a set of utilities that will be used extensively throughout the Java 3D section of the book.

Assuming that you already have Java installed, download and install the Java 3D SDK. The instructions are pretty straightforward. The only real trick is to put the java3d-utils-src.jar in the classpath.

You might also want to download the J3DFly examples. These examples are in addition to the Java 3D examples that come with the download, and they can be found at

http://java.sun.com/products/java-media/3D/

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset