n extended from its roots as a language for
describing complex 3-D scenes and now includes features that allow those scenes to support animation.
That VRML Look
A VRML program is nothing more than an ASCII file. (VRML is an interpreter; you don't compile VRML programs.) The fundamental building block of a VRML program is called a "node." In a sense, a node describes a kind of object, but it serves more to aggregate than to encapsulate. A node is composed of fields, which are named entries holding data that describes the characteristics of a node. This is best illustrated by an example:
Cube {
width 20
height 5
depth 3
}
The above node describes a cube object. It contains three fields: width, height, and depth. (VRML reminds me of the NewtonScript language: VRML nodes correspond to NewtonScript frames, while VRML fields correspond to NewtonScript slots.)
VRML nodes are typed; each type of node performs a different function. Shape nodes describe 3-D objects that make up a scene--spheres, cones
, cubes, and so forth. (The example above is a shape node.) Property nodes give objects their specific traits--color, texture, size, and so forth. Grouping nodes serve to gather other nodes so that the collection is treated as a single unit.
It's the grouping of nodes that allows the VRML programmer to build complex shapes from simple ones. A robot, for example, would consist of grouped nodes that define its head, torso, arms, and legs. As you might guess, grouping can be nested. Therefore, the robot's arms would in turn consist of grouped nodes defining the upper arm, forearm, and hand; its hand would consist of nodes defining palm and fingers; and so on.
In this way, operations applied to the robot affect the entire robot. If, for example, you wanted the robot to change color, you could apply that operation to the robot node as a single unit rather than painstakingly changing the color for each component shape.
VRML 2.0
VRML 1.0 defined static worlds. It enabled you to create 3-D
objects constructed from elementary shapes, as well as define colors, textures, light sources, and so forth. But it was like creating a 3-D still life. Users could "enter" such a 3-D world and roam through it, viewing it from various angles. But what does any of this have to do with Java?
VRML 2.0 has added script nodes, which can contain executable code, and route statements, which send events from node to node. This combination allows programmers to build dynamic VRML worlds. And here is where Java comes in.
Currently, script nodes can include VRMLScript code (which is similar to JavaScript) or JavaScript code, or they can point to Java class files. In the last case, a script node can call a Java method, and--with the help of the VRML 2.0 Java API--the Java code can access nodes and their fields in the VRML world. In short, a programmer can manipulate the VRML world from Java. Java becomes a
deus ex machina
("a god from a machine").
Hearkening back to the robot example, not only c
an the robot move, but with Java in control, it can move intelligently. The robot can also navigate doorways and halls. It might even chase you.
Author's note:
A number of VRML plug-ins are already available on the Internet. I used Silicon Graphics' Cosmo Player, which is available for Windows 95, NT, and Irix running Netscape Navigator 2.0 or higher and Microsoft Internet Explorer 3.0 or higher. Look for it at
http://vrml.sgi.com
. Also, the VRML 2.0 specification was close to being finalized at the time of this writing. Look for the final specification at
http://vag.vrml.org
.