Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

Why Java and VRML?

Understand why Java and VRML are uniquely suited to each other

When Java was just getting started, a certain group of marketeers had the bright idea to position VRML as a competing technology. Nothing could be further from the truth. In fact, the two technologies were made for each other. VRML (in case you have been living under a rock for the last year or so) stands for Virtual Reality Modeling Language. Unlike most computer terms, this aptly describes what VRML does: it allows you to layout 3D worlds in such a way that they can be read by any VRML-compliant browser on any platform much like HTML. One feature of VRML 1.0 is its object-oriented nature.

When we embarked on our journey to bring 3D to Java, we were hesitant to jump immediately on the VRML bandwagon. It was almost 10 months ago and its future and support were much less certain. So, we first began creating a 3D API for Java called ICE, the goal behind ICE was a highly portable library, with only the part which could not be done in Java (for performance reasons) written in C. This essentially mirrors the architecture of AWT. We will get into ICE in later columns. After completing this project Chris Laurel started to take a look at VRML, he immediately saw a synergy between VRML and Java. After a long protracted conversation we decided it was worth a shot trying to implement a VRML parser in Java. This is where the real power of Java started to show. A scant few days after Chris started, he had the workings of a VRML parser up and running. How is this possible? Well, for starters there aren't many of the pitfalls of C or C++, no memory errors to track down. In addition, Chris could leverage the base classes he created to easily and quickly build functionality. For instance, let's take a look at SceneNode. Nodes are what we call objects in VRML, and a SceneNode provides the core functionality for a Node in a scene, like geometry information. Below we have the class hierarchy for IndexedFaceSetNode. Notice we are reusing quite a bit of code. Now realize that we have over 40 classes which reuse the functionality in SceneNode. This makes doing development more productive given the class design is correct.

java.lang.Object
| +----ice.scene.SceneNode
| +----ice.scene.ShapeNode
| +----ice.scene.IndexedShapeNode
| +----ice.scene.IndexedFaceSetNode


Below is some code which will put a sphere on your screen. If you have a VRML-capable browser you can see it here. Note: the code below is meant for example only. There is some code you need in order to be able to see this in most VRML browsers (like lights and cameras), but I did not want to take up the space. You can see the full code here.

#VRML V1.0 ascii
Separator {
   Sphere { radius 1.1 }
}


So, you say, what's so special about that? The Sphere node (we call objects in VRML nodes) has a corresponding Java class. As a matter of fact all VRML nodes in Liquid Reality have a corresponding Java class. The SphereNode has an interface it inherits from the ShapeNode. For those who are asking themselves if the braces surrounding the Cone node mean the same as they do in Java or other languages, give yourself a gold star. Those braces represent something called scope (or in English the fact that anything done inside of those braces only applies to what is inside the braces). Ohhh, kind of like an object. Well, not exactly. They act more like scoping operators in VRML 1.0. Of course this is one of the things being fixed in the VRML 2.0 specification and isn't worth getting into here. So let's take a look at how Separators act somewhat like objects. Notice the Translation applied to the sphere does not affect the cone below it. Why? Because it is inside the Separator. For those of you with VRML browsers you can see this here. You may see the full code listing here.

1 | 2 |  Next >
Resources