Virtual Reality Toolbox    

VRML File Format

You need not have any substantial knowledge of the VRML format to use the VRML authoring tools to create virtual worlds. However, it is useful to have a basic knowledge of VRML scene description. This helps you to create virtual worlds more effectively, and gives you a good understanding of how the virtual world elements can be controlled using the Virtual Reality Toolbox.

This section is an introduction to VRML. For more information, refer to the VRML97 Reference. This reference is available online at http://www.vrml.org/Specifications/VRML97. There are many specialized VRML books that can help you understand VRML concepts and create your own virtual worlds. We recommend the book Teach Yourself VRML2 in 21 days by Chris Marrin and Bruce Campbell (1997).

In VRML, a 3-D scene is described by a hierarchical tree structure of objects (nodes). Every node in the tree represents some functionality of the scene. There are 54 different types of nodes. Some of them are shape nodes (representing real 3-D objects), and some of them are grouping nodes used for holding child nodes. Here are some examples:

Each node contains a list of fields that hold values defining parameters for its function.

Nodes can be placed in the top level of a tree or as children of other nodes in the tree hierarchy. When you change a value in the field of a certain node, all nodes in its subtree are affected. This feature allows you to define relative positions inside complicated compound objects.

You can mark every node with a specific name by using the keyword DEF in the VRML scene syntax. For example, the statement DEF MyNodeName Box sets the name for this box node to MyNodeName. You can only access the fields of those nodes that you name in a virtual world.

In the following example of a simple VRML file, two graphical objects are modeled in a 3-D scene: A floor is represented by a flat box with a red ball above it. Note that VRML file is a readable text file that you can write in any text editor.

The first line is the VRML header line. Every VRML file must start with this header line. It indicates that this is a VRML 2 file and that the text objects in the file are encoded according to the UTF8 standard. You use the number sign (#) to comment VRML worlds. Everything on a line after the # sign is ignored by a VRML viewer, with the exception of the first header line.

Most of the box properties are left at their default values -- distance from the center of coordinate system, material, color, and so on. Only the name Floor and the dimensions are assigned to the box. To be able to control the position and other properties of the ball, it is defined as a child node of a Transform type node. Here, the default unit sphere is assigned a red color and a position 10 m above the floor. In addition, the virtual world title is used by VRML viewers to distinguish between virtual worlds. A suitable initial viewpoint is defined in the virtual world VRML file.

When displayed in V-Realm builder, the floor and red ball look like


  VRML Coordinate System Examples Using the Virtual Reality Toolbox