Virtual Reality Modeling Language

Ken Webb 2010-02-24T16:58:36Z

The Virtual Reality Modeling Language (VRML) is "a standard file format for representing 3-dimensional (3D) interactive vector graphics". It has been superseded by X3D, an XML version of the VRML text-based language. A VRML or X3D file or stream is a collection of nodes that are organized hierarchically. Each node may have attributes such as shape, position, color, and texture.

Because every Xholon application has the same sort of hierarchical structure as a VRML or X3D file, it is straight forward for any Xholon application to write itself out in one of these 3D formats. There is currently no generic capability in Xholon, although there are support classes in the Java org.primordion.xholon.io.vrml package, and there are examples in the 3d folder. It's easy to program a generic VRML writer, but the result is not very visually appealing. The domain objects in each application need to display themselves in a domain-specific way. For example, a car is visually more than just a bunch of generic boxes inside of other generic boxes.

Two Xholon applications have domain-specific VRML writers, the simple HelloWorld app, and the complex Life model. Both of these writers implement the org.primordion.xholon.io.vrml.IVrmlWriter interface.

Screen captures and additional information about these 3D visualizations are located at the older Primordion website. These images were created around the year 2000, and show the use of the Cortona VRML viewer (Windows with Internet Explorer), and several other VRML tools.

The C++ code that was used to produce the images in that picture gallery, has all been ported to Java and is part of the Xholon project. The Java code that writes the HelloWorld VRML is in the org.primordion.xholon.tutorials.VrmlWriterHelloWorld class. The Java code that writes the Life VRML is in the org.primordion.cellontro.io.vrml.VrmlWriterCell class.

A good example of what the Xholon domain specific writer for the Life model can produce, can be seen in this image from the picture gallery.

The Life VRML writer is basically just a large Java switch statement with cases such as:

case MitochondrialInnerBilayerCE:
  break;
case MitochondrialOuterBilayerCE:
  v.write( "children [\n" );
  v.write( "MitochondrialOuterBilayer { }\n" );
  detailWritten = true;
  break;
case NuclearInnerBilayerCE:
  break;
case NuclearOuterBilayerCE:
  setNucleusVolume( xhNode );	// needed later
  v.write( "children [\n" );
  v.write( "Shape { ");
  v.write( "geometry Sphere { radius ");
  v.write( cellLocations.getRadius() / 3.0 );
  v.write( " } ");
  v.write( "appearance Appearance { ");
  v.write( "material Material { } texture ImageTexture { url \"nucleus.png\" } ");
  v.write( "} }\n");
  detailWritten = true;
  break;
case PeroxisomeBilayerCE:
	break;

Part of the resulting VRML hierarchical structure looks like this.

DEF nuclearOuterMembrane_431 Transform { children [
  DEF nuclearOuterBilayer_432 Transform { children [
    Shape {
      geometry Sphere { radius 4166.666666666667  }
      appearance Appearance { material Material { }
      texture ImageTexture { url "nucleus.png" } } }
  ] }
] }

The following is the complete Xholon-generated VRML scene graph for the simple HelloWorld application.

#VRML V2.0 utf8
#Generated using Xholon
#Wed Jul 12 14:53:39 EDT 2006
DEF NavInfoA NavigationInfo { speed 10000 }
DEF CameraA Viewpoint { position 0 0 50 description "Main" }
WorldInfo { info [  "cortsaver:autorotate   8   0 0.8 -0.6" ] }
DEF ROOT Group {
children [
DEF helloWorldSystem_0 Transform {
children [
DEF hello_1 Transform {
translation -13 0 0
children [
Shape { geometry Sphere { radius 5  } appearance Appearance { material Material { diffuseColor 1.0 0.0 0.0 } } }
Transform {
translation 0 11 0
children [
Shape { geometry Text { string [ "hello_1" ] } } ] }
] }
DEF world_2 Transform {
translation 13 0 0
children [
Shape { geometry Sphere { radius 10  } appearance Appearance { material Material { diffuseColor 0.0 1.0 0.0 } } }
Transform {
translation 0 11 0
children [
Shape { geometry Text { string [ "world_2" ] } } ] }
] }
] }
] }

And here's how the Java open-source Xj3D software displays that VRML scene graph in the year 2010, running on Ubuntu Linux inside version 3.5.8 of the Firefox browser.

return to main page