The Java 3D API is an application programming interface used for writing three-dimensional graphics applications and applets. It gives developers high-level constructs for creating and manipulating 3D geometry and for constructing the structures used in rendering that geometry. Application developers can describe very large virtual worlds using these constructs, which provide Java 3D with enough information to render these worlds efficiently.
Java 3D delivers Java's "write once, run anywhere" benefit to developers of 3D graphics applications. Java 3D is part of the JavaMedia suite of APIs, making it available on a wide range of platforms. It also integrates well with the Internet because applications and applets written using the Java 3D API have access to the entire set of Java classes.
The Java 3D API draws its ideas from existing graphics APIs and from new technologies. Java 3D's low-level graphics constructs synthesize the best ideas found in low-level APIs such as Direct3D, OpenGL, QuickDraw3D, and XGL. Similarly, its higher-level constructs synthesize the best ideas found in several scene graph-based systems. Java 3D introduces some concepts not commonly considered part of the graphics environment, such as 3D spatial sound. Java 3D's sound capabilities help to provide a more immersive experience for the user.
The Scene Graph Programming Model
Java 3D's scene graph-based programming model provides a simple and flexible mechanism for representing and rendering scenes. The scene graph contains a complete description of the entire scene, or virtual universe. This includes the geometric data, the attribute information, and the viewing information needed to render the scene from a particular point of view.
The Java 3D API improves on previous graphics APIs by eliminating many of the bookkeeping and programming chores that those APIs impose. Java 3D allows the programmer to think about geometric objects rather than about triangles-about the scene and its composition rather than about how to write the rendering code for efficiently displaying the scene.
Rendering Modes
Java 3D includes three different rendering modes: immediate mode, retained mode, and compiled-retained mode Each successive rendering mode allows Java 3D more freedom in optimizing an application's execution. Most Java 3D applications will want to take advantage of the convenience and performance benefits that the retained and compiled-retained modes provide.
Immediate Mode
Immediate mode leaves little room for global optimization at the scene graph level. Even so, Java 3D has raised the level of abstraction and accelerates immediate mode rendering on a per-object basis. An application must provide a Java 3D draw method with a complete set of points, lines, or triangles, which are then rendered by the high-speed Java 3D renderer. Of course, the application can build these lists of points, lines, or triangles in any manner it chooses.
Retained Mode
Retained mode requires an application to construct a scene graph and specify which elements of that scene graph may change during rendering. The scene graph describes the objects in the virtual universe, the arrangement of those objects, and how the application animates those objects.
Compiled-Retained Mode
Compiled-retained mode, like retained mode, requires the application to construct a scene graph and specify which elements of the scene graph may change during rendering. Additionally, the application can compile some or all of the subgraphs that make up a complete scene graph. Java 3D compiles these graphs into an internal format. The compiled representation of the scene graph may bear little resemblance to the original tree structure provided by the application, however, it is functionally equivalent. Compiled-retained mode provides the highest performance.
Extensibility
Most Java 3D classes expose only accessor and mutator methods. Those methods operate only on that object's internal state, making it meaningless for an application to override them. Therefore, Java 3D declares most methods as final.
Applications can extend Java 3D's classes and add their own methods. However, they may not override Java 3D's scene graph traversal semantics because the nodes do not contain explicit traversal and draw methods. Java 3D's renderer retains those semantics internally.
Java 3D does provide hooks for mixing Java 3D-controlled scene graph rendering and user-controlled rendering using Java 3D's immediate mode constructs. Alternatively, the application can stop Java 3D's renderer and do all its drawing in immediate mode.
Behaviors require applications to extend the Behavior object and to override its methods with user-written Java code. These extended objects should contain references to those scene graph objects that they will manipulate at run time." describes Java 3D's behavior model.
High Performance
Java 3D's programming model allows the Java 3D API to do the mundane tasks, such as scene graph traversal, managing attribute state changes, and so forth, thereby simplifying the application's job. Java 3D does this without sacrificing performance. At first glance, it might appear that this approach would create more work for the API, however, it actually has the opposite effect. Java 3D's higher level of abstraction not only changes the amount but, more important, also the kind of work the API must perform. Java 3D does not need to impose the same type of constraints as do APIs with a lower level of abstraction, thus allowing Java 3D to introduce optimizations not possible with these lower-level APIs.
Additionally, leaving the details of rendering to Java 3D allows it to tune the rendering to the underlying hardware. For example, relaxing the strict rendering order imposed by other APIs allows parallel traversal as well as parallel rendering. Knowing which portions of the scene graph cannot be modified at run time allows Java 3D to flatten the tree, pretransform geometry, or represent the geometry in a native hardware format without the need to keep the original data.
Layered Implementation
Besides optimizations at the scene graph level, one of the more important factors that determines the performance of Java 3D is the time it takes to render the visible geometry. Java 3D implementations are layered to take advantage of the native, low-level API that is available on a given system. In particular, we anticipate that Java 3D implementations that use Direct3D, OpenGL, and QuickDraw3D will become available. This means that Java 3D rendering will be accelerated across the same wide range of systems that are supported by these lower-level APIs.
Target Hardware Platforms
Java 3D is aimed at a wide range of 3D-capable hardware and software platforms, from low-cost PC game cards and software renderers at the low end, through midrange workstations, all the way up to very high-performance specialized 3D image generators.
Java 3D implementations are expected to provide useful rendering rates on most modern PCs, especially those with 3D graphics accelerator cards. On midrange workstations, Java 3D is expected to provide applications with nearly full-speed hardware performance.
Finally, Java 3D is designed to scale as the underlying hardware platforms increase in speed over time. Tomorrow's 3D PC game accelerators will support more complex virtual worlds than high-priced workstations of a few years ago. Java 3D is prepared to meet this increase in hardware performance.
Support for Building Applications and Applets
Java 3D neither anticipates nor directly supports every possible 3D need. Instead it provides support for adding those features through Java code.
Objects defined using a computer-aided design (CAD) system or an animation system may be included in a Java 3D-based application. Most such modeling packages have an external format (sometimes proprietary). Designers can export geometry designed using an external modeler to a file. Java 3D can use that geometric information, but only if an application provides a means for reading and translating the modeler's file format into Java 3D primitives.
Similarly, VRML loaders will parse and translate VRML files and generate the appropriate Java 3D objects and Java code necessary to support the file's contents.
Browsers
Today's Internet browsers support 3D content by passing such data to plug-in 3D viewers that render into their own window. It is anticipated that, over time, the display of 3D content will become integrated into the main browser display. In fact, some of today's 3D browsers display 2D content as 2D objects within a 3D world.
Games
Developers of 3D game software have typically attempted to wring out every last ounce of performance from the hardware. Historically they have been quite willing to use hardware-specific, nonportable optimizations to get the best performance possible. As such, in the past, game developers have tended to program below the level of easy-to-use software such as Java 3D. However, the trend in 3D games today is to leverage general-purpose 3D hardware accelerators and to use fewer "tricks" in rendering.
So, while Java 3D was not explicitly designed to match the game developer's every expectation, Java 3D's sophisticated implementation techniques should provide more than enough performance to support many game applications. One might argue that applications written using a general API like Java 3D may have a slight performance penalty over those employing special, nonportable techniques. However, other factors such as portability, time to market, and development cost must be weighed against absolute peak performance.
0 comments:
Post a Comment