In August, JavaSoft announced the new media and communications Java APIs, of which ther
e are a passel. They include the following:
- Java 2D and Java 3D (which is what I'll focus on here).
- Java sound, including mixing and MIDI synthesis.
- The Java media framework, which deals with (among other things) audio/video playback and videoconferencing.
- Java animation, which deals with 2-D animation.
- Java telephony, which is self explanatory.
- Java speech, which includes speech recognition and synthesis.
- Java collaboration, which d
eals with data sharing.
I could spend much of the rest of this magazine's pages trying to cover all the APIs, but obviously I don't have enough space for that. Instead, I'll continue my coverage from previous columns, in which I discussed 2-D graphics and VRML, and concentrate on the Java 2D and Java 3D APIs. (You can find and download further information about the other APIs from
http://www.javasoft.com
.)
Java 2D is actually an extension to the Java Abstract Window Toolkit (AWT). Plans are that it will be included as part of the JDK. The additional classes of Java 2D provide such features as arbitrary fills, tiling, Bézier paths, extended font characteristics (which let you define such font features as kerning, glyph substitution, and ligatures), and a variety of transform operations.
More elaborate elements of Java 2D provide for image-processing operations. For example, Java 2D defines the classes and interfaces necessary for constructing convolution kernels, as well as source and destination image buffers. With the added help of the ConvolveOp class, you can easily implement 2-D filter operations, such as blurring, sharpening, edge detection, and so on.
In addition, Java 2D provides greater control over colors. For example, its color-conversion classes provide for converting among RGB, CMYK, gray scale, HLS, HSB, and a half dozen more color spaces (some of whose acronyms I'm not familiar with).
Java 3D (unlike Java 2D) is a "premium" extension to the standard JDK. What that means in terms of availability and distributability is currently unclear. At the time this article was written, JavaSoft representatives were unable to discuss the details of the business model.
Java 3D runs atop standard 3-D rendering engines, such as OpenGL, Direct3D, and QuickDraw 3D. But since
it simply depends on the rendering capabilities of such graphics engines, it can run atop "raw" graphics hardware.
Java 3D is a "scene graphics" API. The virtual universe modeled by Java 3D is stored in a complex tree-like structure that's known as a "scene graph" and is composed of connected objects. Some objects in the scene graph define shapes that are ultimately rendered into the things seen in the virtual world. Other objects define textures, colors, reflectivity, and so forth.
One particular object, called the view object, carries the information needed to render the scene. The view object is itself a composite of other objects. For instance, one of its components is the
PhysicalBody
object, which contains information describing the characteristics of the viewer (i.e., the end user). The information is frighteningly detailed, and it's obviously designed to model the characteristics of a human viewer immersed in a 3-D world. Data in the
PhysicalBody
object defines the locat
ion of the viewer's eyes -- even the interpupillary distance. The idea, of course, is to provide the developer with a framework that has enough richness to capture the widest range of viewing devices.
A unique component of Java 3D is the 3-D sound component. Given that a scene graph includes a view object, the system has all it needs to deduce the location of the viewer and the viewer's relation (in 3-D space) to other objects in the scene. (In addition, the system has information about the geometry of the viewer himself/herself.) This information is used by the sound engine to provide realistic, spatialized 3-D sound with little programmer intervention. If the viewer is close to an object that's emitting a sound, the sound is louder; farther away, the sound is softer.
Finally, even if you're uninterested in 3-D graphics, you should be aware that Java 3D defines a vector-and-matrix math library suitable for general-purpose mathematics programming. These libraries are not part of the Java 3D API pe
r se, although Java 3D depends on them as storage and manipulation classes for data such as coordinates, color information, vector normals, and so on. JavaSoft expects that the members of this library will be removed into a separate java.vecmath package in the future.