Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

3D graphics programming in Java, Part 1: Java 3D

Get a head start with this introduction to the Java 3D API

  • Print
  • Feedback

Page 2 of 5

  • 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.



Installing Java 3D

Now that we understand the major features and constraints of Java 3D, let's get ready to try out some example code.

Java 3D is available in beta for Win32 and Solaris. The more mature of Sun's implementations of Java 3D is built on top of OpenGL. An alpha-quality Direct3D implementation is also available for Win32. All require Java 1.2, with the latest Java 3D beta corresponding to Java 1.2 Beta 4. Sun has promised to release the final Java 3D implementation shortly after it releases Java 1.2, which is currently scheduled for December 1998.

A slightly confusing aside: Sun released Java 3D 1.0 alpha implementations, which corresponded to the Java 3D 1.0 API, but it never released anything beyond alpha for the 1.0 API. Sun then modified the API, releasing the modified version as the Java 3D 1.1 API. This version was followed with releases of what it called 1.1 beta implementations, two so far. Sun has promised to release a final API and implementation shortly after the final release of the Java 1.2 platform. Hopefully, the API has stabilized and won't be revved, yet again, with the world still waiting on a bonafide final release of an implementation.

  • Print
  • Feedback

Resources
  • A good place to start is the Introduction to Programming with Java 3D course tutorial put together by Sun and the San Diego Supercomputer Center. http://www.sdsc.edu/~nadeau/Courses/SDSCjava3d/
  • Sun's Java 3D API page documents the API and its use. It contains javadocs for the API, the mailing list archive, Sun's Java 3D FAQ, and more. http://java.sun.com/products/java-media/3D/
  • The API is specified in Sun's Java 3D API Specification document. http://java.sun.com/products/java-media/3D/forDevelopers/j3dguide/j3dTOC.doc.html
  • The specification is also available in book format from Addison-Wesley's Java Series. Please note that the version of the API this printed specification corresponds to may be somewhat out of date The online specification is always kept up to date for the latest API release. http://www.amazon.com/exec/obidos/ASIN/0201325764/billday/
  • Sun makes its Win32 and Solaris implementations (as opposed to the API specification itself) available from a separate, product Web site. This site also contains the example code for Sun Java 3D training courses, demos from the Java 3D programming contest Sun hosted earlier in 1998, case studies with Sun's Java 3D customers, and lists of Java 3D related papers and Web pages. http://www.sun.com/desktop/java3d/index.html
  • Sun's Java 3D product site links to the course notes for its "Java 3D Roadshow." This is the crash course Sun representatives have been teaching to interested developers around the world in 1998. http://www.sun.com/desktop/java3d/collateral/j3d_clas.pdf
  • The OpenGL Consortium's Web site is the complete resource for OpenGL. http://www.opengl.org/
  • The Java 3D FAQ is maintained by Steve Pietrowicz, a project manager of the Java 3D group at NCSA. It is an excellent third-party resource for Java 3D information. http://tintoy.ncsa.uiuc.edu/~srp/java3d/faq.html
  • Read more about Java 3D's heavyweight components and Sun's thoughts on integrating them with Swing lightweight components. http://java.sun.com/products/java-media/mail-archive/3D/1520.html
  • Follow-up on Sun's plans for Java 3D vis-a-vis lightweight components and Swing. http://java.sun.com/products/java-media/mail-archive/3D/1557.html
  • "Progress on the media front at Siggraph '98" sizes up the state of Java Media in general and Java 3D in particular at this year's premier computer graphics conference. http://www.javaworld.com/javaworld/jw-10-1998/jw-10-media.html
  • Download source code and classes for this column. http://www.javaworld.com/jw-12-1998/media/jw-12-media.jar
  • Bill has archived Media Programming resources on his Web site. This archive contains the up-to-date media.jar file with code fixes for all of the examples in the column. http://reality.sgi.com/bday/Work/index.html
  • Read Bill's previous Media Programming columns. http://www.javaworld.com/topicalindex/jw-ti-media.html