Last Modified: 11/07/99
[Previous] [Home] [Next]

Utilities and File Structure



Representations of VRML

3D scenes in VRML have one or two representations: one is the representation found in a particular program which creates VRML code. In our case we are using V*RealmBuilder and it constructs VRML worlds using a node tree, where the "+" and "-" elements allow subtrees to be expanded or contracted in a manner similar to many file structure displays in PCs. Here is an example of a simple box type object and the node tree in VRML which constructs it:

The "Transform" node at the top controls the positional, size, and rotational values of all of the "children" below it. The "children" node contains one or more objects whose appearance and geometrical properties are controlled by sub-nodes.

While this representation is specific to one particular implementation of VRML, its heirarchical structure and naming conventions apply to all implementations of VRML. In particular, the file format for VRML is fixed and consists of a pure ascii representation which closely mimics the node tree above. Only those values which differ from the defaults are included, however. Here is the ascii representaton of the above node tree:

VRML V2.0 utf8
#Created with V-Realm Builder v2.1
#Ligos Corporation
#www.ligos.com

Transform {
  translation   0.178859 0 -1.62681
  scale    2.47535 6.83595 2.47535
  children Shape {
     appearance     Appearance {
          material  Material {
              diffuseColor  0.8 0.643179 0.139978
          }
     }
     geometry       Box {
     }
  }
}

Creating Scenes in VRML

The above VRML code displays a single object. The VRML tree below shows two totally independent objects in a single VRML "world". Here I have renamed the "{} Transform" nodes as "Sphere" and "Box". These two transforms are completely independent and can be moved, rotated, scaled, etc separately:

The next picture shows how we can fuse two objects together. I highlighted the Sphere object, and then executed an "Edit > Cut" operation, then highligted the children part of the Box node and executed an "Edit > Paste". Now the Box and Sphere both belong to the children part of the Box node, so any rotate, scale, move, etc operation applies to both of them, so they always move together. Note, however, that other properties, such as their color, texture, etc remain independent. I could easily separate them again by cutting and pasting the Sphere to the main world node named "temp.wrl".

VRML Utilities

A handy utility function is named USE . It is invoked thru a "hand" icon in the bottom toolbar near the right (note: this is NOT the same "hand" icon that rotates a scene: that one is near the left side of the middle toolbar). You can use "USE" to duplicate objects as follows:
  • Highlight some object, e.g., "Box"
  • Click on the "USE" icon in the bottom toolbar: this adds a node to the tree named "USE: Nothing" and at the same time pops up a menu that lets you select the object you want to use. Two important points to note are this:
    • Any object that you use must have an explicit unique name that you have keyed in: objects that have the default "{} Transform" named cannot be used.
    • Also insert the USE icon at the very bottom of the node tree because it is only aware of those named nodes that are above it.
  • Then highlight the new node, and then execute a cut-and-paste operation to place it where you want in the tree. Note that it is initially invisible so you need to move it as it occupies the exact same place as the original object.
After you have made it visible, you can then alter any of its properties uniquely.

Moving VRML Scenes to the WWW

Once you have created a scene, you can save it to a file with the extension .wrl. If you are on the same machine as your browser, and if you have Cosmo Player or some other VRML browser installed, you can simply move the file over a browser window to see the complete scene. However, if you wish to make it available on the WWW to other people, and if your scene contains textures, audio clips, movies, backgrounds, etc, then you need to complete these steps:
  • Save the file with the ".wrl" extension; let us call it "my.wrl"
  • Copy "my.wrl" to your web server
  • Include the statement <A HREF="my.wrl">A VRML Scene </A> in your HTML code
  • If you have audio clips store them in a directory named "audio/" in the same directory; store any textures in a directory named "texture/", and make the first letter of each file in this directory uppercase; movies are stored in a directory named "movies/"

Viewing VRML Scenes with Cosmo Player

There are just a few things to note about viewing VRML in Cosmo Player:
  • Below is a picture of a scene viewed with Cosmo Player. The controls to manipulate the picture are in the lower part of the screen. Note the yellow arrow that points to a little gray switch: click on this switch to change the controls from one type to another -- in particular the initial setting does not allow you rotate a scene in 3D, so you need to click here to rotate it.
  • Also note the red arrow: this points to a set of viewpoints which are available in some scenes that move you to specific locations.
  • Also note that in some scenes the controls are *very* sensitive, so moving something slightly may send you so far that you end up very disoriented.


[Previous] [Home] [Next]