Introduction to VRML

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.



VRML Language Basics

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):

  1. a (possibly) non-uniform scale about an arbitrary point
  2. a rotation about an arbitrary point and axis
  3. a translation

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.

Getting Started with CP 2.1

Getting Started with Cosmo Player 2.1

Cosmo Player plugs in to your Web browser to enable you to see and explore 3D worlds. With Cosmo Player you can visit any 3D world authored in the Virtual Reality Modeling Language (VRML). These 3D worlds often include other kinds of multimedia, like sound and movies.

This brief guide shows you the basics of the Cosmo Player main controls so you can get started right away.

On the Dashboard

You use the main controls on the Cosmo Player dashboard to do two things: move around in 3D worlds and examine objects in 3D worlds. (Some worlds don't display the dashboard, but they may provide on-screen cues to navigation.)

If your dashboard looks like this

simplemovedash.gif (18044 bytes)

use Go, Slide, and Tilt to move around in the world. See "Moving Around in a World."

If your dashboard looks like this

examinedash.gif (17917 bytes)


use Rotate, Pan, and Zoom to examine objects in the world. See "Examining Objects."

Some worlds allow you to use only Movement controls (Go, Slide, and Tilt). Other worlds allow you to use only Examine controls (Rotate, Pan, and Zoom). Still other worlds allow you to use both Movement and Examine controls. Even if both sets of controls are available to you, it's usually best to use the controls that are displayed when you first enter a world. You could easily become disoriented by switching randomly from one set of controls to another!

To switch from one set of controls to another, click Change Controls.

examine2.gif (17857 bytes)

Moving Around in a World

To move around in a 3D world, click the Go, Slide, or Tilt button and then drag the pointer in the Cosmo Player window. Once you click a control, it stays selected until you click another.

Go

Go button

Click and then drag to move in any direction.

Slide

Slide button

Click and then drag to slide straight up and down or to slide right or left.

Tilt

Tilt button

Click and then drag to look up or down or from side to side.

Examining Objects

To examine objects in a 3D world, click the Rotate, Pan, or Zoom button and then drag the pointer in the Cosmo Player window. Once you click a control, it stays selected until you click another.

Rotate

Rotate button

Click and then drag to rotate an object.

Pan

Pan button

Click and then drag to pan right, left, up, or down.

Zoom

Zoom button

Click and then drag up to zoom in or drag down to zoom out.

Changed Your Mind?

Use the Undo Move and Redo Move buttons to retrace your steps.