Simple3D – a simple way to play with Java 3D

Parts


Andrew Davison
ad@fivedots.coe.psu.ac.th

Installing Simple3D Simple3D Pic

The easiest way to get started is to download this zip file (22 MB) containing Simple3D, Java 3D, JOGL, along with examples.

Java 3D and JOGL are included as JAR files, and should run on MS Windows, Linux, and Mac OS. However, I've only tested them on Windows 10, Windows 7, and Ubuntu, so would welcome feedback about any problems you've had getting things to work. Unzip the file and follow the instructions in readme.txt for compiling and running the examples.

Incidentally, the Simple3D.jar file contains both compiled code and the Java source files, so you can look at how things are implemented if you're so inclined.

Getting Java 3D and JOGL Yourself

If the versions of Java 3D and JOGL I've included with Simple3D aren't suitable for some reason then please tell me, and you can of course download other releases from the JOGAMP website.

There are a few ways to obtain the necessary JARs; my suggestion is to visit the JOGAMP deployment directory, and search for the latest build in the java3d/ subdirectory. As I write this in October 2021, that's a folder labelled v 1.7.1. You should download all of its JAR files, or just the zip file that contains everything in one place.

You can use a similar technique for JOGL -- in the deployment/ folder look for the most recent version (that's v 2.4.0 from 2021 at the moment), then move down to its fat/ folder, and download jogamp-fat.jar.

The Java 3D JAR files and the "fat" JOGL JAR file should be placed in the lib/ folder in Simple3D, replacing the JARs that are currently there.

Learning Java 3D

JOGAMP's top-level Wiki page contains a Java 3D subsection, which includes a tutorial maintained at java3d.org, a FAQ, and the API documentation.

One great learning resource is an online version of Daniel Selman's "Java 3D Programming" textbook from 2002. The source code can be obtained from the book's official web page at Manning Pub. I'd also like to mention the online version of my "Killer Game Programming in Java" book from 2004, which dedicates many chapters to Java 3D.

The 1999 tutorial on Java 3D by Dennis Bouvier no longer seems to be online, so I've zipped up the eight chapters and the code as a file. However, Oracle does still maintain the Java 3D API specification from that time. I suspect they've simply forgotten to delete it.

If you think 1999 is the distant past, another helpful aid is a set of slides (500+ pages) from SIGGRAPH 99.

A collection of (somewhat dated) Java 3D links are gathered together on a dedicated GitHub page. Another site of this type is java3d.org.

One surprising source of many Java 3D examples is the Java 3D subsection of java2s.com; strangely, it isn't accessible from the site's main page.

One problem with all of these resources is that their examples will NOT compile with Java 3D v 1.7. The maintainers renamed the packages in that version to better match the package structure used by JOGL. The good news is that only the package names were changed; the classes and methods are the same. This means that most programs only require the adjustment of their import lines in order to get them to compile. More specifically, the following changes are needed:

Old imports New imports (since Java 3D 1.7)
import com.sun.j3d.*; import org.jogamp.java3d.*;
import javax.media.j3d.*; import org.jogamp.java3d.*;
import javax.vecmath.*; import org.jogamp.vecmath.*;

One of the Java 3D JAR files at JOGAMP contains examples, but only the ".class" code. This can be decompiled of course (e.g. I use JD-GUI), but it's generally easier to start with the Java text. Philip Jordan has a GitHub site for those files, and has also edited their import lines so the code is ready for v 1.7.

Java 3D for Computer Graphics

In my completely unbiased opinion, the scene graph mechanism in Java 3D makes it a much better starting point for learning computer graphics than beginning at the OpenGL level, as offered by JOGL. In the past, I've used two textbooks that employ that approach:

Sadly, I've been unable to find the source code used in Zhang and Liang's book, but Klawonn's site is full of good stuff.

Help with Java 3D Problems

The great age of Java 3D means that there's a lot of forum posts, web sites, and blogs that describe it. The easiest way of finding these is with Google search (or equivalent), and the material on Stack Overflow is usually of a high standard. There's also a Java 3D Forum over at JOGAMP, which is the best place for questions and answers about the current version of Java 3D.