VRML, the Virtual Reality Modeling Language, is a file format for describing interactive three-dimensional objects and worlds . Here a world is a model of a 3D space, which can contain 3D objects, lights, and backgrounds; in other 3D systems this is often called a scene . Objects can be built from solid shapes, from text, or from primitive points, lines, and faces. Objects have optical material properties which affects how they interact with the lights in the world; they can also have textures (2-D pat terns) applied to them.
Objects can be grouped into more complex objects, used multiple times, translated, and rotated. Objects can trigger events, which can be routed to other events or to scripts written in JavaScript or Java . Within VRML you can trigger sounds, move objects along paths, and link to HTML or VRML targets. In JavaScript or Java you can manipulate VRML object properties programmatically and even generate new objects.
The experience for someone browsing a VRML world can be active or passive, depending on how you've scripted the world. VRML can be used to create interactive 3D games (e.g. Chomp! , the Shaft ), simulations of real or imagined devices and buildings or even cities for walk-throughs, i nteractive visualizations of scientific data , advertising banners , art , music , and much more . VRML is a system- and device-independent language, so one VRML world can be viewed on any VRML viewer of the correct vintage.
It's entirely possible to create VRML worlds with nothing more than the VRML specification, a text editor, and a VRML-enabled browser (all of which are free), if you're a programmer with a good grasp of 3D computer graphics concepts. On the other hand, a VRML modeling program or world builder can take a lot of the pain out of the process, and make 3D world creation accessible to non-technical designers.
A VRML file contains a file header, comments, and nodes. Nodes, which describe objects, may have names and contain fields and values. Comments and the file header begin with the pound sign, and curly brackets delimit the hierarchy of nodes and fields. Named nodes may be reused elsewhere in the scene.
VRML files measure distance in meters, angles in radians, time in seconds, and colors as RGB triplets with each value in the range [0.0,1.0]. It uses a Cartesian, right-handed three-dimensional coordinate system. By default, the viewer is positioned along the positive Z-axis so as to look along the -Z direction with +Y-axis up.
VRML files use the .wrl (world) extension and the model/vrml MIME type. The older x-world/x-vrml MIME type is still supported for backward compatibility. VRML source is normally encoded in UTF-8, which is a superset of standard ASCII. You can compress .wrl files for the web with GZIP; this can make a big difference in download times.
The basic node for defining visible VRML objects is the Shape , which in turn contains Geometry and Appearance nodes. So, for example, the following example defines a world containing one cylinder 2 meters high with a 1.5 meter radius with default material properties, meaning that the object will appear to be a glowing white:
#VRML V2.0 utf8
# A Cylinder
Shape {
appearance Appearance {
material Material { }
}
geometry Cylinder {
height 2.0
radius 1.5
}
}
The available geometry nodes are the Box , Cone , Cylinder , ElevationGrid , Extrusion , IndexedFaceSet , IndexedLineSet , PointSet , Sphere , and Text . In addition, you can use nodes created from PROTO s or EXTERNPROTO s, which are essentially custom nodes defined in terms of the primitive nodes.
The Box , Cone , Cylinder , and Sphere are geometric primitives. The Text node displays a string with a specified font style. The WorldInfo node holds the world's title and other information, such as author and copyright. The ElevationGrid node creates surfaces and terrains. The Extrusion node creates solids by sweeping a 2D cross-section though a 3D spine. The IndexedFaceSet , IndexedLineSet , and PointSet nodes use Coordinate nodes to create solid faces, lines, and points, respectively. These raw geometry nodes give you more flexibility than the geometric primitives, and can actually create more efficient VRML worlds.
You can control the diffuse (shading) color, emissive (glow) color, transparency, shininess, and the other optical properties of an object using its Appearance node's Material field. These optical properties interact with the scene lighting to determine the image presented to the viewer. Shadows are not generated automatically, but you can fake them.
Only some kinds of materials are well described by the optical properties specified in the Material field. Metal and glass are; wood, tile, and painted objects are not. You can override optical properties with Color nodes, or wrap textures -- two-dimensional images -- around the 3D shapes. VRML supports three kinds of texture mapping fields: ImageTexture (from JPEG, PNG, and GIF files), PixelTexture (from raw image data), and MovieTexture (from MPEG1 files). If you use an image with an alpha channel for texture, you can create "holes" in the texture mapping that allow the underlying material properties to show through.
Geometry nodes can be grouped several ways. The Group node combines its children, adding a bounding box for the whole. A Transform node is a group plus a geometric 3D transformation that applies to the group, consisting of (in order):
Transform nodes are used extensively in VRML worlds, since all objects are by default constructed at the origin of the space.
DEF defines the name of a node. USE lets you refer to a named node. You can use a named node as many times as you wish.
Ground color, sky color, and background textures are defined by the Background node. Multiple backgrounds can be kept in a stack and bound dynamically. Atmosphere and an increased sense of depth can be created by using a Fog node. You can provide Viewpoint nodes to help the user navigate your world.
By default there is a headlight shining in front of the viewer. In addition, there can be three kinds of light source in the world: directional, point, and spot lights. These lights interact with the colors and material properties of the objects.