up

VRML Overview

This document is based on the VRML 1.0 spec. The first version of VRML only describes geometry, transformations, surface properties, lights, and viewing. One book on VRML 1.0 is VRML: Browsing and Building Cyberspace by Mark Pesce (New Riders, 1995).

The next version of VRML will support dynamic, interactive models. One proposal for VRML 2.0 is Moving Worlds, which provides support for object "behaviors" (in Java), 3D sound, collision detection and more. In the following, however, VRML 1.0 is discussed.

Viewing a VRML model requires a VRML browser. The browser displays the model, allowing the user to "fly through" or manipulate the model. The browser can also transfer models from remote servers using the HTTP protocol. Portions of the model can be specified as "links" to other hypermedia objects (HTML, audio, etc): when the user clicks on such a "link" object, the browser obtains the referenced document from the indicated server.

VRML is designed to be platform independent, extensible, and usable over low-bandwidth connections.

Language Basics

A VRML object is described by a scene graph, a hierarchical structure built from nodes. The scene graph is represented as ascii text. The scene graph has state: nodes effect other nodes that appear later in the scene graph description (similar to the way graphics libraries treat attributes like "current color"). For example, a Rotation node affects all objects after it in the scene. Separator nodes can be used to limit the effects of property changes.

Each node has these characteristics:

Syntax:
DEF objectname objecttype { fields children } (only the type and braces are required)

Every VRML file begins with the line:
#VRML V1.0 ascii
Comments start with '#'. White space is used as to separate tokens.

The coordinate system is a Cartesion and right-handed. By default, objects are displayed by projecting along the positive z axis, with x to the right and y up.

Fields are defined to contain either a single value or multiple values. Multiple values are enclosed in square braces and separated by commas. Single values are separated by white space. Multiple fields are used when any number of values can be specified (eg, a list of 3D coordinates). Single fields are used when a specific number of values are to be specified (eg, a single 3D coordinate always has 3 values). For example, a rotation is described with a "single field" (containing 4 values):
0 1 0 3.14159 describes a rotation about the y axis by 180 degrees (in radians). A list of vertices uses a multiple field:
[ 0 0 0, 0 1 0, 1 0 0 ] describes 3 points in the z=0 plane.

Fields are defined for colors, rotations, strings, matrices, etc.

Nodes can be classified into 3 categories:

Nodes can contain fields. The order in which the fields are specified is not important (e.g., Cube {width 1 height 2 depth 6} is the same as Cube {height 2 width 1 depth 6})

The 36 nodes, grouped by type

Examples

A Sphere, its Material, and a Light

#VRML V1.0 ascii
Separator {
  DirectionalLight {
    color 1 1 1
    direction 1 0 0
  }
  DEF MySphere Separator {
    Material {
      diffuseColor 1 1 1
      shininess 0.0
    }
    Sphere { radius 1 }
  }
}

Transformation and Instancing (and texture)

The Transform node lets you specify the parameters for the following sequence of operations: A Transform node like this: (from Pesce's book)
Transform {
  translation T1
  rotation R1
  scaleFactor S
  scaleOrientation R2
  center T2
}
is equivalent to the following sequence:
Translation { translation T1 }
Translation { translation T2 }
Rotation { rotation R1 }
Rotation { rotation R2 }
Scale { scaleFactor S }
Rotation { rotation -R2 }
Translation { translation -T2}
An example:
#VRML V1.0 ascii
Separator {
  DirectionalLight {
    color 1 1 1
    direction 1 0 0
  }

  Texture2 {
    # not all browsers will accept gif files for textures....
    filename "http://tesla.csuhayward.edu/~tebo/tinywindow.gif"
  }

  DEF MySphere Separator {
    Material {
      diffuseColor 1 1 1
      shininess 0.0
    }
    Sphere { radius 1 }
  }

  Texture2 {
    filename "http://tesla.csuhayward.edu/~tebo/GrandCanyon.gif"
  }

  Transform {
    translation 3 0 0
    scaleFactor 0.2 0.2 0.1
    center 3 0 0
  }

  USE MySphere
}

Polygons

#VRML V1.0 ascii
Separator {
  Coordinate3 {
     point [ 0 0 0,
	     1 0 0,
	     0 1 0,
	     0 0 1 ]
  }
  IndexedFaceSet {
	coordIndex [ 
		0,1,3,-1,
		0,3,2,-1,
		0,2,1,-1,
		1,2,3,-1
	]
  }
}

CSUH World

#VRML V1.0 ascii

DEF CSUHside Separator {
  Material {
    diffuseColor 1 0 0
  }
  AsciiText {
    string "CSUH"
    justification CENTER
  }
}

DEF CSUH Separator {
  USE CSUHside
  Transform {
    rotation 0 1 0 3.14159
  }
  USE CSUHside
}

DEF CSUHcross Separator {
  USE CSUH
  Transform {
    rotation 0 1 0 1.57
  }
  USE CSUH
}

DEF Tower Separator {
  Transform {
    scaleFactor 0.35 1.0 0.35
    translation 0 4.5 0
  }
  WWWAnchor {
    name "http://www.csuhayward.edu/"
    Cube {}
  }
}

DEF BigWorld Separator {
  Texture2 {
    filename "http://tesla.csuhayward.edu/~tebo/wavy1.gif"
  }
  Sphere {radius 15}
}

DEF SmallWorldAfterAll Separator {
  Texture2 {
    filename "http://tesla.csuhayward.edu/~tebo/wavy1.gif"
  }
  Transform { translation 0 4 0 }
  Sphere {}
}

Bill Thibault <william.thibault ayat csueastbay dawt edu>
Last modified: Thu Feb 29 11:27:26 1996