java 3d programming
September 28, 2006 4:52am CST
how to get started
28 Sep 06
Java 3D has a lot of pros, but what about the cons? They include: Java 3D is a standard extension API. Java platform licensees are given the option to implement the API if they like, but they're not required to implement it. Java 3D's positioning as a standard extension runs the risk of reducing the portability of Java 3D code across platforms -- most vendors have to struggle to keep up with changes and additions to the core platform alone. Java 3D has severe availability constraints. These are the result of Java 3D's status as an extension API. The only major vendor currently providing a Java 3D implementation is Sun, with its implementations for Solaris and Win32. Compared to OpenGL, which is available for every flavor of Unix, Windows, and many other operating systems, the cross-platform portability of Java 3D code looks questionable. Along with software availability problems come documentation deficits. Sun is making a valiant effort to provide developer training and support for Java 3D, but it is still falling short compared to the rest of the industry's efforts in documenting OpenGL and its use. The OpenGL Consortium's Web site is far deeper and broader than anything Sun has managed to put together for Java 3D so far. This is not a minor point: the relative complexity of 3D graphics APIs make good documentation a necessity. Java 3D hides rendering-pipeline details from the developer. Because Java 3D is a high-level API, it intentionally hides details of the rendering pipeline from the developer, which makes it unsuitable for a significant number of problems where such details are important. (We'll discuss OpenGL's lower-level model and access to the rendering pipeline later in this 3D series.) Java 3D components are heavyweight. That is, they have a native (non-Java) peer that actually does the rendering. This can complicate your GUI development if you use Java Swing and its all-Java, or lightweight, components. There are some special workarounds, but in general, lightweight and heavyweight components don't mix well in the same container objects and windows. More information on lightweight-heavyweight component problems is available from the Resources at the end of this article.
28 Sep 06
Selling points for Java 3D: It provides a high-level, object-oriented view of 3D graphics. Java 3D accomplishes this in part by using a scene graph-based 3D graphics model. (We'll discuss this concept in more detail later in the article.) This approach is intended to help programmers without much graphics or multimedia programming experience use 3D in their applications. In stark contrast to lower-level, procedural 3D APIs like OpenGL, which are designed to optimize for the best possible speed and give programmers the greatest possible control over the rendering process, Java 3D is meant to be straightforward enough for any experienced Java programmer to learn. If you don't need low-level access to rendering operations, Java 3D may be an option. Rendering access is limited to requests via attributes and capability bits, similar in form and function to Java 2D's rendering hints. (See Resources for links to my previous series on Java 2D, which included discussion and examples of 2D's rendering hints). Java 3D is optimized for speed where possible. The runtime uses rendering capability bits, in fact, to optimize the scene graph for the fastest possible renders. This approach makes Java 3D more applicable to interactive graphics environments (games, simulations, low-latency situations) than to offline, high-quality graphics applications (like render farms). A large and growing number of 3D loaders are available to import content into the Java 3D runtime. Sun has made a Java 3D VRML97 file loader and browser freely available with code. Look for next month's Media Programming column to explore Java 3D loaders in more detail. Java 3D requires vector math capabilities not available elsewhere in the Java platform. These math operations are currently located in the javax.vecmath package and may be moved into the core platform in the future. Java 3D supports a number of exotic devices (wands, data gloves, and headsets, for example). The com.sun.j3d.utils.trackers package included with Sun's implementation provides classes for Fakespace, Logitech, and Polhemus devices. These devices are not widely used, however, so I will not discuss them in great detail. If you're interested in finding out more about device support, please refer to Sun's Java 3D sites and the Java 3D mailing list archive (both available from the main Sun Java 3D URLs included in the Resources below).
28 Sep 06
n order to build a true Java platform, Sun realized early on that it needed to fill out the API picture beyond the limited functionality available in the Java 1.0 core platform. Sun has grown the core a great deal with the 1.1 and impending 1.2 releases, but there are still some pieces missing from the Java puzzle. Sun and its partners developed the Java Media and Communication APIs to provide the missing multimedia programming pieces. Two of the biggest pieces, 2D and 3D graphics, are targeted with the Java 2D and 3D APIs, respectively. Java 2D is a core platform API beginning with Java 1.2, while Java 3D will be released as an Extension API shortly after the 1.2 platform becomes available. We have recently finished a series of columns on Java 2D; now we turn our attention to Java 3D. Java 3D is meant to give Java developers the ability to write applets and applications that provide three dimensional, interactive content to users. Sun has some heavy competition from other 3D graphics technologies in this arena, and Java 3D has an uphill battle ahead of it if it's to defeat the incumbent graphics standard, OpenGL. A request for reader comments on 3D graphics APIs for Java indicated serious interest in Java 3D and Java OpenGL bindings, so I've decided to concentrate my efforts on these technologies in the coming months. A more limited amount of interest was expressed in VRML. Consequently, I am going to deal with VRML by demonstrating its use in Java 3D with VRML97 content loaders and Sun's Java 3D VRML97 browser. Direct3D received very little interest, so I've decided not to pursue this path, except to mention where one of the other technologies may support or interoperate with it.