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 3 of 5

Because we will be covering Java OpenGL bindings in a future column, I have decided to economize and use the OpenGL version of Java 3D in these installation instructions too. If you install the OpenGL version to use with these Java 3D examples, you will have the rendering libraries you need for the Java-OpenGL examples to come later.

The software components you need to use Java 3D are:

  • Java 3D runtime, available from Sun (free Java Developer Connection login required). Be sure to choose the OpenGL version of Java 3D for your platform (I'm using Win32). As of now, the latest Win32 Java 3D for OpenGL is 1.1 Beta 2, in java3d11-beta2-win32-opengl.exe, and weighs in at approximately 1.7 MB.

  • OpenGL 1.1, bundled with Windows NT 4.0 and Windows 95 OSR 2. If you have the OSR 1 release of Windows 95, though, you can download OpenGL support. The latest Windows 95-OpenGL 1.1 implementation is available from Microsoft as opengl95.exe, and is approximately 0.5 MB.

  • Java 1.2, available from Sun. (Note that as I write this, Sun has released a new Java 1.2 -- Release Candidate 1. Examples will be updated for the latest release as soon as possible.) Java 3D is coupled into the 1.2 platform, and Sun has stated on the java3d-interest mailing list that it has no interest in decoupling the API and trying to make it available with previous platform releases.


Optionally, you may also want to download the Java 3D documentation and example code. Both are available from the same link as the Java 3D runtime.

Please note that you are no longer required to set the CLASSPATH environment variables in order for your java or appletviewer executables to find extension libraries. With Java 1.2, Sun has finally created a standard extension directory. This directory is located at /jre/lib/ext/ within your JDK installation directory. For instance, on my system, Java 1.2 Beta 4 is installed at:

C:\jdk1.2beta4\

and the standard extension directory is at:

C:\jdk1.2beta4\jre\lib\ext\

All extension libraries should place their jar archives into this extensions directory at install-time, and all standard JDK tools know to search here for needed class files.

For Sun's Java 3D, these archives include both public (documented in the Java 3D API specification) and private (Sun implementation-specific) classes. Public class archives include:

  • j3dcore.jar -- Contains class files for the public Java 3D package javax.media.j3d.

  • vecmath.jar -- Contains classes for javax.vecmath.


Private archives include:

  • j3daudio.jar -- Archives the com.sun.j3d.audio classes, which build support for spatialized audio on top of a custom copy of the Java portion of the Java Sound, Headspace-based audio engine, debuting in Java 1.2.

  • j3dutils.jar -- Encapsulates a variety of Sun utility classes in 16 total packages and subpackages underneath com.sun.j3d. I will dig deeper into these packages in next month's continuation of our Java 3D discussion.

  • j3dutilscontrib.jar -- Archives useful utilities contributed by others to Sun's efforts. There are seven packages under the com.sun.j3d hierarchy, including the com.sun.j3d.utils.trackers code mentioned above. Again, next month's column will provide more information on the packages in this jar.



Please note that in theory you may instantiate and call methods on any of the classes provided in nonstandard packages like com.sun, but caveat emptor: There is no guarantee they will be available on the platform your code executes on. In current practice, Java 3D is only available from Sun, so a lot of developers do, in fact, use classes within Sun's private archives. You should be aware of the potential portability trade-off entailed in choosing to do so.

  • 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