elieve it or not, the Jet Propulsion Laboratory (JPL) from NASA is actually developing Java capabilities. The JPL is a division of NASA responsible for the robotic exploration of the solar system. Household names such as the Mars Pathfinder and the Voyager explorers are products of JPL.
One of their Java capabilities is the FastScript3D library for Java3D, and it is a technology that really shows some promise.
This technology could be used to render and display three-dimensional models on your Web site, in much the same way that VRML (Virtual Reality Modeling Language) did. The nice thing about FastScript3D is that it doesn't have a proprietary file format, and that it can load the model description files from a variety of 3D modeling applications.
In this article you will step through the basics of the FastScript3D API, and build some Web pages that render different 3D models. You will begin by looking at how to install the API, and from there will build three-dimensional models using the built in primitives. Then you'll see how to load and render a 3D model from the popular Lightwave 3D modeling application. By the end of the tutorial you will have covered the basic operations offered by the API and will be prepared to look into some of the more complex aspects, such as extending the API and animating your 3D worlds.
You will need a J2SE SDK version 1.4 or later, and the Java 3D API version 1.3.1 or later. These may be downloaded from http://java.sun.com. Make sure that you are using the correct Java plug-in for your browser by opening Control Panel and selecting the 'Java Plug-in' Applet. On the 'Advanced' tab, select the correct runtime. This should read something like 'SDK 1.4.2_01 in C:\j2sdk1.4.2_01.'
Close down and restart your browser, and then browse to http://fastscript3d.jpl.nasa.gov/HelloUniverse.html. You should see a spinning multicolored cube. If you do, then you are ready to go with fastScript3D.
Setting Up Your Development System
|Figure 1. Picture This: Here's the easy FastScript3D application in action.|
On the PC platform the JAR file containing LiveConnect is called jaws.jar, and on the Sun platform it is called java40.jar. Find the appropriate jar for your platform and add it to your classpath.
The next thing you will need is the JAR file containing the supporting files for FastScript, fs.jar, which is available for download on the JPL site. This needs to be placed in the directory on your Web server where the HTML files containing the 3D applets will reside. Under this directory create the following subdirectories: FS_MODEL, FS_TEXTURE, FS_SIM, and FS_DEMO.
The JPL has provided a very basic example which has three cubesa red one, a green one, and a blue onefloating in 3D space. The source code for which (easy.java) is included in the download for this article. To compile this you must have references to the java3d JARs (usually found in jre\lib\ext\j3dutils.jar) and the FastScript JAR that you downloaded earlier.
Once this is compiled into easy.class, place it in the directory on your Web server that you created earlier. Finally, take the HTML file from the download with this article (easy.htm) and put it in the same directory. Browse to the HTML, and you should see something like that shown in Figure 1.
| Author's Note: If you follow the example on the JPL site directly you will get an error, as the JAR file for FastScript3D that you download is newer than the one referenced in their example. Use the ones in the download with this article and it should work easily.