Chapter 28

Virtual Reality Modeling Language


CONTENTS


Virtual Reality Modeling Language (VRML) is the open standard for virtual reality on the Internet. VRML is to immersive 3-D on the Internet what HTML is to 2-D. Instead of having a flat page, there is a world you can move around in (see Fig. 28.1).

Figure 28.1: Above and Below--a VRML world created by Dennis McKenzie (http://www.aereal.com/worlds/ab.wrl.gz).

VRML currently is moving from the 1.0 specification to the 2.0 specification. VRML 1.0 browsers are common; in fact, Netscape now has a VRML browser built into the standard edition of Netscape Navigator. VRML 2.0 browsers are starting to appear as the 2.0 specification settles down. Worlds written in VRML 2.0 can have a variety of interactivity, behaviors, multiuser capability, sound, and more.

History of VRML

VRML started out in the minds of Mark Pesce, Tony Parisi, and others. Pesce and Parisi wanted to create a way to do 3-D over the World Wide Web. They brought their first demo to the World Wide Web conference in 1994 and showed it as part of a Birds of a Feather session set up by Tim Berners-Lee, the inventor of HTML and the Web, and Dave Raggett, the man who coined the term VRML (often pronounced ver-mul).

After the Birds of a Feather session, Brian Behlendorf of Organic Online and Mark Pesce set up an e-mail list called www-vrml for discussing VRML. The list was swamped with thousands of subscribers right from the start. Quickly developing into a community, the list led a request for proposals for a VRML 1.0 specification. Proposals were turned in by many groups of people and companies. Eventually, the VRML community settled on the proposal submitted by Silicon Graphics, based on a subset of its Open Inventor language with extensions to the Web. After revisions and clarifications, the VRML 1.0 specification became final in June 1995. Silicon Graphics created and released a VRML 1.0 parser called qvlib and also placed its contributions to the VRML 1.0 specification in the public domain.

Parisi and Pesce had built a pre-VRML 1.0 simplified browser. Things started moving as SGI came out with its WebSpace VRML browser, and Template Graphics released a Windows 95/NT version of WebSpace. VRML entered the masses when Intervista, Parisi's company, released WorldView for Windows 3.1.

The air was charged with excitement at the first gathering of the VRML community at Siggraph in August 1995. To add to the excitement, a newcomer called Paper Software had just released its first version of WebFX, a VRML browser for Windows 3.1, days before Siggraph. The VRML community had a Birds of a Feather session, which included a discussion of the status of VRML, what should be included in VRML 1.1 (which never came to be), and VRML 2.0. Companies gave demos of their first VRML products and worlds.

The VRML community pushed forward toward the next generation of VRML, even as many of the 1.0 browsers did not fully implement the VRML 1.0 specification. The next physical gathering took place at the first VRML symposium hosted by the San Diego Supercomputing Center, also the home of the VRML Repository Web site. Lectures were given demonstrating software and proposing new techniques for the future. In a small room in another building, VRML companies exhibited demos of their software in cramped cubicles.

The following year, the pace increased as Netscape acquired Paper Software, whose WebFX VRML browser was the most popular, and incorporated its technology into Netscape Navigator under the name Live3D. In the meantime, the VRML community was moving forward with VRML 2.0. The VRML Architecture Group (VAG), a self-appointed group of VRML community shepherds, formed and issued a request for proposals for VRML 2.0. The proposals came in again, this time from companies including Sony & SGI, IBM Japan, Apple, Sun Microsystems, and Microsoft. Votes were taken at the VAG's Web site. The clear winner was the Moving Worlds proposal-a collaboration of SGI, Sony, Mitra, and other members of the community.

At this point, VRML 1.0 worlds are appearing all over the World Wide Web, and VRML 2.0 software and sites are starting to appear.

Installing a VRML Browser

To get started with VRML, you need to have a VRML browser or viewer. In this section, I introduce the most popular or new browsers, including Netscape's Live3D, SGI's Cosmo Player, and Sony's CyberPassage. If the VRML browser you use is a Netscape plug-in, you also can view VRML worlds in the middle of HTML pages. This is known as embedding (and uses the <EMBED> tag in HTML).

Netscape's Live3D

You already might have a VRML browser. Netscape Navigator 3.0 Standard Edition for Windows PCs includes Netscape's Live3D VRML capability built into Netscape (see Fig. 28.2). Netscape has a new version of Live3D available for PowerMacs. It also is in the process of porting Live3D to UNIX. For the latest Live3D availability, refer to http://www.netscape.com/eng/live3d.

Figure 28.2: Netscape Live 3D.

Live3D includes extensions to VRML 1.0 for spinning objects, animated textures (images), and objects that always face the viewer. In addition, new versions of Live3D include support for LiveConnect, which means that web developers can communicate with the Live3D plug-in using JavaScript or Java. See Aereal's LiveConnect page at http://www.aereal.com/liveconnect for examples. This means that different media inside an HTML can interact with the VRML world nicely. It also provides some functionality similar to VRML 2.0.

As of this writing, Live3D does not support VRML 2.0, also known as Moving Worlds. Some of the marketing Web pages on the Netscape site might make you think otherwise.

SGI's Cosmo Player

Cosmo Player is Silicon Graphics's new VRML 2.0 browser (see Fig. 28.3). Amazingly, Cosmo Player was available for Windows PCs even before it became available on Silicon Graphics machines. Cosmo Player includes support for a significant portion of the VRML 2.0 specification. It uses a variant of JavaScript called VRMLScript to define behaviors and interactions between VRML 2.0 elements. It also includes a built-in VRML-1.0-to-2.0 converter so that 1.0 worlds can be viewed.

Figure 28.3: Cosmo Player.

Sony's CyberPassage

CyberPassage from Sony (http://sonypic.com/vs) is a new VRML 2.0 browser with extensions for multiuser support (see Fig. 28.4). This means that you can see other people in the VRML worlds and interact with them. Instead of using VRMLScript, CyberPassage uses Java as a scripting language for interactivity in VRML 2.0 worlds. This gives web developers the capability to create more advanced applications and worlds, using advanced features of Java that are not in VRMLScript, such as networking.

Figure 28.4: Sony's CyberPassage

Switching Between Browsers

Unfortunately, Netscape Navigator does not provide plugin management software. This means that if you want to switch between different VRML browsers, it can get difficult. As a worst case scenario, you can try uninstalling one VRML browser and installing another. However, there is another way. You can rename the DLL file containing the VRML browser. Netscape Navigator looks for the first VRML DLL alphabetically. When I want to switch from Cosmo Player to Live3D in Windows 95, I choose Find from the Start menu, choose Files or Folders, and search for the file npcosmop.dll. After it is found, I rename it xnpcosmop.dll. The letter x in front places the DLL after the Live3D DLL in the alphabet so that Netscape will start the Live3D VRML plugin when it is rendering a VRML world.

Navigating in VRML Worlds

You might be familiar with using a mouse and windowed operating system now, but when they first were released, they took some time to learn. Similarly, navigation in three dimensions can be quite a challenge at first. In addition, the VRML browser companies still are learning how to design good user interfaces for easy use.

Live3D

Live3D's user interface is evolving continually. The Live3D team at Netscape uses the computer games Duke Nukem, DOOM, and Descent as their inspiration for 3-D user interfaces.

Live3D features a variety of navigation modes and options highlighted in a navigation bar at the bottom of the screen. You also can access these mode and options by using a pop-up menu that you access by clicking the right button inside the VRML world.

The current navigation mode is indicated by a bright green highlighting of the word. Point and Lamp are options that can be turned on or off independently of the navigation mode. When they are on, they are highlighted in yellow.

Walk

The default navigation mode is Walk. You can use the mouse or keyboard to move around. You can press the up- and down-arrow keys to move forward or backward. You press the left- and right-arrow keys to move left or right. To float upward, hold down the Alt key and press the up-arrow key. Similarly, to float downward, hold down the Alt key and press the down-arrow key. Be careful not to hold down the Alt key and press the left-arrow key, because this brings you to the previous URL (like the Back button).

When you click and drag the mouse, you move forward or backward while turning to the left or right, as applicable. To float upward or downward, you can hold down the Alt key while dragging the mouse.

Spin

Spin mode is good for when you want to examine a 3-D object from different angles or viewpoints. You need to use the mouse, however, because the keyboard functions like Walk mode.

Clicking with the left button and dragging the mouse up or down rotates the object around the horizontal axis. Dragging the mouse left or right rotates the object around the vertical axis.

Look

The idea of Look mode is that you, the viewer, are stationary, and you are moving your eyes and head around. You look around by clicking and dragging the mouse, or by using the keyboard.

Slide

Slide lets you move around very easily. When you move left or right (with the mouse or arrow keys), you remain looking in the same direction; just your virtual body moves. Using the up- or down-arrow key moves you up or down. Left-clicking and moving the mouse forward or backward also moves you up or down.

Point

Point mode can be toggled on or off by clicking the word point. It is active by default, which is indicated by its yellow color. When Point mode is on, you can click on an object and move toward it. If you have trouble activating a link (by clicking on the object), try turning off Point mode.

Lamp

Clicking the word lamp turns on a headlamp that illuminates the world in front of you. One of the challenges of creating VRML worlds is setting up lighting properly. The Lamp option lets you make sure that you can see a world, even if it doesn't have light at all. You can click the up and down arrows to the left of the word lamp to adjust the intensity of the headlamp.

View

A world can have preset viewpoints of interest to visitors. A VRML art gallery, for example, might have viewpoints in front of each work of art. Clicking the word view selects the original starting point you are at when you first view the world. This can be useful if you have navigation problems and want to return to your entry point.

To move between different viewpoints, you can click the up and down arrows to the left of the word view. Or, you can hold down the Ctrl key and press the left- or right-arrow key.

Help

You can click the question mark (?) at the right end of the navigation toolbar to display an overlay at the bottom left of the screen that explains navigation using both the mouse and keyboard for the current navigation mode.

Advanced Options

If you place your mouse inside the world and click the right arrow button, a menu pops up with a variety of options. Most of the options can be selected using the navigation bar. The Options submenu contains two neat options for displaying VRML.

Fast Rendering makes movement much quicker, with a trade-off in graphics quality. This is useful if you want to be able to move around the world quickly. The Motion Blur setting makes the world blur when you move around; it's almost a psychedelic effect in some worlds.

Getting Lost

It's easy to get lost in 3-D worlds, and it's a challenge to find a map or a local gas station where you can ask for directions. Here are some simple methods for finding your way back to where you started:

Click the ? on the navigation bar for instructions.
Click view on the navigation bar to return to the starting point in the world.
Select a viewpoint from the Viewpoints submenu of Live3D's pop-up menu (activated by clicking the right mouse button inside the world).

Cosmo Player

Cosmo Player has just two navigation modes: Walk and Examiner. The default mode can be set by the world creator in the VRML file. Both modes have three 3-D navigation tools. Note that the 3-D-looking SGI logo at the right end of the navigation bar is not a navigation tool!

Examiner

Examiner mode is the default navigation mode. Examiner mode is designed for looking at objects from various angles. The three tools are, from left to right, the "Dolly," Rotator Ball, and Pan tool. The Dolly acts like a mechanic's dolly, letting you slide into and away from the object. Click the Dolly and drag it forward to move forward, or drag it backward to move backward.

The Rotator Ball lets you rotate the whole object around. Just click the ball and drag the mouse in the direction in which you want to rotate the object. If you continue to move the mouse while you release the mouse button, you can cause the object to keep spinning after you let go of the mouse button.

The Pan tool lets you slide left or right by dragging the mouse left or right. To move up and down, drag the mouse forward or backward.

You also can perform these actions without having to click these tools by using some shortcuts. For the Dolly tool, hold down the Ctrl and Alt keys and drag the mouse forward or backward. For the Rotator Ball, hold down the Alt key and drag the mouse. To use the Pan tool, hold down the Ctrl key and drag the mouse. These shortcuts can significantly reduce the number of mouse movements you need in order to move the world.

Walk

You can switch to Walk mode by clicking the right mouse button to bring up Cosmo Player's menu. Then choose Walk from the Viewer submenu (or press the hot keys V and W). The three tools in Walk mode are the Look Target, the Mover arrow, and the Pan tool.

The Look Target lets you remain in the same location while looking around. Click the Look Target and drag your mouse in the direction you'd like to look. You can click the Mover arrow to move around. Just click and drag the mouse in the direction you want to move. The Pan tool works the same as in Examiner mode.

The shortcuts for the Pan tool are the same: hold down the Ctrl key and drag while holding down the left mouse button. To move, hold down the Alt key and drag the mouse. To use the Look Target, hold down both the Ctrl and Alt keys and drag the mouse.

Other Features

You can explore the other options of the menu that come up after you click the right mouse button. If you are proficient with the shortcuts, you can turn off the navigation bar display (the dashboard) by clicking Show Dashboard in the pop-up menu.

When a world creator sets up predefined viewpoints, you can cycle among them by using the Page Up and Page Down keys. Cosmo Player also has an excellent link to on-line help pages through the pop-up menu.

CyberPassage

CyberPassage has a curious but neat navigation methodology. The great part of it is that you get feedback on where your mouse drags are taking you. Arrows at the bottom of the window are highlighted when you are moving in their direction.

To move around, you click and drag with the mouse. CyberPassage draws a line from your clickpoint to where you've dragged the mouse. This lets you know what direction you're dragging in and how fast you're moving.

A variety of buttons are available on the right of the window, including Jump! Jump moves you up into the air and lets you look down on the world. Clicking Jump again (the wings at the right side of the screen) turns off Jump mode and returns you to the ground.

When you move the mouse over objects that have actions, the mouse icon changes to a hand. CyberPassage comes with several exciting demos, including a dune buggy that drives around a course. You click the dune buggy to get it started and then click it again to stop it. The demos can be hard to find on your computer. Windows 95 users can look in the C:/Program Files/Sony/CyberPassage/contents/ directory.

Cool VRML Sites

Finding interesting VRML sites on the Web can be a challenge. At this point, most VRML worlds are linked to from HTML sites. It will be exciting when you can find VRML worlds from other VRML worlds.

Proteinman's Top 10 VRML Worlds

Proteinman's Top 10 VRML Worlds (http://www.virtpark.com/theme/proteinman/home.wrl.gz) is one of the first worlds that has links to other worlds from a VRML world (see Fig. 28.5). This Top 10 list is the first top 10 list of VRML Worlds. It is updated regularly, and you can enter Planet Proteinman, another VRML world, to get links to previous top 10 lists. Each world features Proteinman in it somewhere, doing something interesting, whether it's watching fireworks or tossing Easter eggs.

Figure 28.5: Proteinman's Top Ten VRML Worlds.

The VRML Repository

The VRML Repository (http://www.sdsc.edu/vrml) contains links and information on a variety of VRML information, including VRML browsers, converters, and examples (see Fig. 28.6). It was the first significant place for information on VRML.

Figure 28.6: The VRML Repository

The VRML Architecture Group

If you're interested in the latest information on the VRML specification and where it's headed, the VRML Architecture Group's Web site (http://vag.vrml.org) has links to the VRML specifications (see Fig. 28.7). It also periodically holds Web-based polls on the future of VRML.

Figure 28.7: The VRML Architecture Group Web site.

VRML at SGI

Silicon Graphics VRML site (http://vrml.sgi.com) focuses on its new VRML product, Cosmo Player (a VRML 2.0 browser) as well as its multimedia authoring environment, Cosmo Create. The site includes VRML examples, especially VRML 2.0 examples, plus links to other resources, such as VRML tutorials (see Fig. 28.8).

Figure 28.8: SIG's VRML site.

Aereal BOOM!

Aereal BOOM! (http://www.aereal.com/boom) is built on a database of more than 1,000 VRML URLs. Visitors get a random VRML URL from the database and can rate the world, giving it one to five stars (see Fig. 28.9). Their rating is entered into the database, and they receive a new world. The randomization is skewed toward worlds that other people have rated highly.

Figure 28.9: Aereal BOOM!

Creating a VRML World

Putting your first VRML URL up on the Web and telling your friends about it is even cooler than when you created your first HTML home page. To get started, you can use authoring tools (which are covered in the "VRML Authoring Tools" section, later in this chapter), learn to type VRML source by hand, or use Instant VRML Home World.

Instant VRML Home World

Instant VRML Home World (http://www.aereal.com/instant) lets you create a simple VRML world by filling out two HTML forms (see Fig. 28.10). In addition, you get it automatically published on a Web server, so you don't have to worry about configuring your Web server.

Figure 28.10: A VRML world created with Instant VRML Home World.

Hand Coding a VRML 2.0 World

Here is a step-by-step look at building a simple geometry-based VRML 2.0 world. It should work in the latest versions of Cosmo Player and CyberPassage.

To create a simple VRML world, start off with the VRML 2.0 header and a VRML node. The Transform node lets you group other nodes within it (see Listing 28.1).

Note
VRML is case-sensitive, so it is vital that you type in the examples exactly as given


Listing 28.1. A minimal VRML 2.0 file.
#VRML V2.0 utf8
Transform { }

Save this file with an extension of .wrl. Test it by loading it into your Web browser. Nothing will appear, but the browser should start up a VRML plugin and load without errors. At each of the following steps, save the VRML file and try loading it into your browser. Next, you can add some simple geometry, like a sphere. To do this, use the children field of the Transform node. Add a node called Shape as a value of the Transform node's children field. The Shape node itself contains a geometry field; give this field the value of a Sphere node (see Listing 28.2).


Listing 28.2. A simple VRML 2.0 file with a sphere.
#VRML V2.0 utf8
Transform {
  children [
    Shape {
      geometry Sphere { }
    }
  ]
}

Suppose that you want to make the sphere a red sphere. You can add in an Appearance node with a Material node inside it just before the Sphere node. Make sure to put a comma after the Appearance node, because there is now more than one node inside the Transform node's children field. The Material node uses the diffuseColor field with RGB value 1 0 0, indicating that the color is full of red, but totally lacking in green and blue (see Listing 28.3).


Listing 28.3. A VRML 2.0 world with a red sphere.
#VRML V2.0 utf8
Transform {
  children [
    Shape {
      geometry Sphere { }
      appearance Appearance {
        material Material { diffuseColor .7 0 0 }
      }
    }
  ]
}

Next, you can add another object, such as a cube. You can set the cube to be in a different location than the sphere using another Transform node with a translation field. The cube itself is created with the Box node inside another Shape node. The translation field is given a value of 4 0 0, indicating that the cube is placed four meters to the right of the center of the sphere (see Listing 28.4).


Listing 28.4. A VRML world with a red sphere and a cube.
#VRML V2.0 utf8
Transform {
  children [
    Shape {
      geometry Sphere { }
      appearance Appearance {
        material Material { diffuseColor .7 0 0 }
      }
    }
  ]
}
Transform {
  translation 4 0 0
  children [
    Shape {
      geometry Box { }
    }
  ]
}

As a final step, you can texture an image onto the cube. A sample URL of an image file is given, but you can substitute your own image URL. Again, the Appearance node is used-this time with the texture field set. The texture field contains an ImageTexture node, which contains the URL of the image file (see Listing 28.5).


Listing 28.5. A VRML 2.0 world with a red sphere and texture-mapped cube.
#VRML V2.0 utf8
Transform {
  children [
    Shape {
      geometry Sphere { }
      appearance Appearance {
        material Material { diffuseColor .7 0 0 }
      }
    }
  ]
}
Transform {
  translation 4 0 0
  children [
    Shape {
      geometry Box { }
      appearance Appearance {
        texture ImageTexture { url "http://www.aereal.com/logomi.jpg" }
      }
    }
  ]
}

Figure 28.11 shows the result of Listing 28.5.

Figure 28.11: A hand-coded VRML 2.0 world with a red sphere and a texture-mapped cube.

Now that you have your own VRML world, you might want to add it to your Web site.

Configuring Your Web Server

After you create a VRML world, you can FTP it up to your Web server and configure the server so that it will transmit VRML worlds properly. Configuring your Web server software lets it know which files will be VRML files so that it can transmit them with the proper MIME type and HTTP header. The VRML MIME type is x-world/x-vrml. When a visitor to your site requests your VRML URL, the Web server looks for the file and then looks at the end of the file name to figure out what kind of file it is. For a VRML file, it inserts the following line in the header of the message it sends to the visitor's browser:

Content-Type: x-world/x-vrml

This tells the browser to use the VRML plugin to render the VRML instead of displaying it as text. Refer to the documentation of your Web server on how to add MIME types. Generally, it requires adding a line in one of your httpd's conf subdirectory files, like the following line:

AddContentType x-world/x-vrml .wrl

If you want to reduce the size of your VRML files, you can compress them with gzip compression. There is gzip software available for PCs. Most people using gzip run the compression on a UNIX machine. In UNIX, just type the following to gzip compress a VRML file:

gzip filename.wrl

Note that when gzip compresses a file, it deletes the original file and saves a new file with the extension .gz. To uncompress the file and get the original back, type the following:

gunzip filename.wrl.gz

Using gzip compression can reduce the file size of your VRML world by 60 percent or even more. After you place VRML worlds on your server that have been compressed with gzip, there is one more addition to make to your server configuration. Refer to your Web server's documentation on the exact way to add support for gzip content encoding. After it is set up properly, the HTTP server transmits the following header when it transfers a gzip-compressed VRML file:

Content-Type: x-world/x-vrml
Content-Encoding: x-gzip

Some Web masters mistakenly try to set up gzip as a MIME type rather than as a content-encoding method. On most Web servers, you again will update a file in the httpd's conf subdirectory to add a line like this:

AddContentEncoding x-gzip .gz

VRML 2.0 Capabilities

VRML 2.0 brings new capabilities to 3-D on the Internet. These include interactivity, 3-D sound, behaviors, and multiuser worlds. Behaviors are algorithms that describe movement and change in 3-D objects. A VRML dog might have behaviors like walking, running, eating, and chasing cats, for example. Interactivity means that the user can affect the world by moving around inside it and taking actions like clicking on objects. Sound inside the world can be spatialized in 3-D so that sounds are louder when you are closer to them. Some worlds may be multiuser so that you can see and interact with other people's avatars-their 3-D representations in cyberspace.

Some of these new features use scripting languages, such as Java and JavaScript. Multiuser worlds, for example, can use Java's networking capabilities to communicate the 3-D positions of avatars to everyone in the room.

Integrating VRML with Other Media

VRML worlds can be most exciting when used with other forms of media. VRML 2.0 makes it easy for people to use other media types like images, movies, and sound inside the 3-D world.

Images

Creating 3-D objects is a challenge, but there already are vast libraries of 2-D images in existence. You can use these images in 3-D worlds by pasting or wallpapering them onto 3-D objects such as walls. This technique is called texture-mapping.

Browsers will support standard image formats-most notably, GIF, JPEG, and PNG. The nice thing about PNG is that you can have varying levels of transparency in your images. Transparency can be used to great effect. You might take a picture of a person and make the background of the image transparent, for example. When you stick this inside the VRML world mapped onto a polygon, it can look quite realistic. In addition, texture-mapping a simple image can be used to simulate complex 3-D surfaces such as brick walls and cloth.

Besides static texture-mapping of images, you also can create animated images in VRML 2.0. And these animations can be taking place on the surface of 3-D objects. Essentially, what happens is that you replace a static texture-mapped image with a new image after a certain amount of time passes.

In the future, expect to be able to texture objects with Java applets, Shockwave files, and GIF89 animations.

Movies

Besides texturing 2-D images onto objects, you also can texture movies. The VRML 2.0 specification requires support for MPEG1-Systems and MPEG1-Video formats. It is likely that VRML 2.0 browsers also will develop support for other formats like QuickTime and AVI.

This capability means that your virtual world can have TVs and movies inside it. At some point, it also might be possible to texture-map streamed video onto 3-D objects, so that you could have videophones or virtual videoconferences inside the VRML 2.0 world.

Sound

Sound definitely was missing in 1.0 worlds. VRML 2.0 lets you integrate audio media into the virtual world in three important ways. First, you can have background sounds in the world, helping to shape the emotional environment of the world. You also can have spatialized sound, such as voices or speakers, in the world. Also, these sounds can be keyed to interactivity, so that actions have audio and not just visual feedback.

An Overview of VRML 2.0 Syntax and Nodes

A detailed tutorial on VRML 2.0 is beyond the scope of this chapter, but this section will introduce the VRML 2.0 nodes and file structure. VRML 2.0 files consist of a header, PROTO or EXTERNPROTO definitions, one or more nodes, and ROUTE statements at the end of the file. The VRML header (#VRML V2.0 utf8) tells the VRML browser that it is a VRML file and also gives the version number. If it is a 1.0 file, a VRML 2.0 browser might be able to convert it to VRML 2.0 to read it. PROTO and EXTERNPROTO definitions can be used like objects. Instead of having to re-create the whole geometry every time you use a table, you might use PROTO to define a table and then just give the table's color and height each time you want to use it.

Nodes are the building blocks of VRML worlds. They specify geometry, properties of the world, sound, and more. Finally, ROUTE statements at the end of a VRML file are like wires between electrical components on a circuitboard. They are the communication paths for information to flow between different nodes and parts of nodes. These are needed for the interactivity and complex behaviors that are possible in VRML 2.0 worlds.

When you're authoring or debugging VRML 2.0 worlds, you'll want to avoid some common mistakes. Make sure that both square and curly brackets are matched properly. In addition, unlike HTML, the case of letters is important. Nodes and field names must be written using exactly the same combination of uppercase and lowercase letters as given in the VRML 2.0 specification. When two words make up the name of the node, the two words are compounded into one word, and the first letters of both words are capitalized.

Nodes have parameters of various types, such as fields and events. The names of these parameters start with a lowercase letter. If they are a compound of more than one word (or abbreviation), the first letter of the second word usually is capitalized.

The rest of this section describes the parts and nodes in a VRML 2.0 file.

Prototypes

VRML 2.0 is designed for extensibility. You can define new kinds of nodes. The definitions of the new nodes can be contained inside the same VRML file with a PROTO statement, or in an external VRML file. If you refer to a node type defined in another VRML file, you use the EXTERNPROTO keyword.

New nodes are defined in terms of other VRML 2.0 nodes, and also can refer to Script nodes. You name the fields and events of the new node and then relate those parameters to other VRML 2.0 nodes that define the node. You could PROTO a Speaker node for an audio speaker, for example, with fields relating to the speaker's size, its volume, and the sound file that it plays. The Speaker node also could have events attached to it, such as being turned on or off.

Grouping Nodes

Grouping nodes are a class of nodes that can have several nodes inside them. In addition, they usually define some kind of coordinate system or property for the nodes inside them, which are called children.

The Anchor node defines a way to load in new URLs. When the children of an Anchor node are selected (usually by clicking), the new URL is loaded. The URL can be any kind of URL, whether it is VRML, HTML, or anything else. In addition, the Anchor node is built for extensibility because of its parameter field. This node allows for extensions like frame targeting and JavaScripting. In VRML 1.0, there was a problem when frames were invented, because there wasn't an easy way to accommodate frame targeting from within VRML without breaking some browsers. In VRML 2.0, you can have as many parameters as your browser can understand, just like in HTML tags. You therefore can attach parameters like target, onclick, name, and more.

The Billboard node lets you create objects that always face a certain direction in relation to the viewer! This can be useful for trees. To create a tree, you can have a transparent 2-D image of a tree and use a Billboard node to have the 2-D image always pointing in the world's up direction, but with the 2-D picture always directed toward you. This can help you avoid creating an elaborate 3-D object. The Billboard node also is useful for creating 2-D text in a 3-D world.

The Collision node turns on collision detection for children of the node. Collision detection can use significant computer processing power, so the Collision node lets you optimize by requiring detection only where needed.

The Transform node is the most commonly used grouping node. Transform defines a new coordinate system for its children in terms of the parent coordinate system. In simple terms, this means that you'll use the Transform node with its translation field when you want to create an object in a different location from the previous object you created.

Special Groups

The special group nodes let you do even more sophisticated things in your VRML 2.0 world. Inline is a powerful node, because it (like EXTERNPROTO) uses the network to bring in part of the VRML world from another part of the World Wide Web. With Inline, you can place another VRML world inside your world. You might have your neighborhood as one VRML file, for example. That file could contain the geometry for roads and the surrounding area. But maybe you already have a VRML world of your house. In your neighborhood world, you can insert an Inline node that brings in your house VRML world.

The LOD node is for level of detail-a concept that lets you display alternate representations of objects based on the distance away from the object. Your world might include a building that can be viewed from different distances, for example. You might set up different representations with a LOD node, so that from far away, the building is a simple box. When you get a little closer, the building is made up of several boxes, and you can distinguish an entrance. At even closer range, windows become distinguishable. Finally, pigeons roosting on the building are visible and audible, and you even can see inside the building's windows.

The Switch node is powerful, although you generally need to use ROUTEs and Scripts to take advantage of it. The Switch node contains a number of children, one of which can be active at a time. A simple example is a door. The door might have different representations, like closed and open. The Switch node might be affected by a script that looks to see whether a person has clicked on the door.

Sensors

Sensors generate events that then can be passed on to change other values using ROUTEs (see "ROUTEs," later in this chapter). These events can be generated by physical actions by the user in the world or by the passage of time.

CylinderSensor, PlaneSensor, and SphereSensor are called drag sensors because they start generating events after people click on them and hold down the mouse. CylinderSensor transmits the value of rotations of an imaginary cylinder, as if a wand were being rotated. PlaneSensor interprets post-click draggings as movement along a plane and transmits the value of the relative translations (movements). SphereSensor transmits the value of rotations of an imaginary ball, as if you were using Live3D's Spin navigation node.

ProximitySensor creates an imaginary box around geometry and triggers an event when the user enters that geometry. TimeSensor is like a stopwatch-starting and stopping and sending out time values in between. TouchSensor generates an event when its geometry is touched or clicked. (You can think of TouchSensor as being part of the Anchor node.) VisibilitySensor generates an event when its geometry is within the user's field of view.

Appearance

A variety of nodes affect the appearance of geometry nodes that are rendered. The Appearance node lets you set the current color and texture using Material and Texture nodes as the value of its fields. The Material node gives the current color, as defined by VRML 2.0's lighting model. The lighting model includes elements of ambient light, diffuse light, emissive light emitted by the object, the object's shininess, specular highlights in the object, and transparency. Colors in the Material node are given by RGB values, which indicate the amount of red, green, and blue in a color.

The Texture nodes include ImageTexture, MovieTexture, and PixelTexture. The ImageTexture node lets you wallpaper a 2-D image onto a 3-D object. MovieTexture lets you map a series of video frames in a format like MPEG onto VRML geometry. Both ImageTexture and MovieTexture use an externally referenced URL as their source data. PixelTexture lets you define a texture map within the VRML file as a sequence of numbers giving RGB values and the amount of transparency for each pixel in the texture. The TextureTransform node can be used to make textures repeat with scaling. You also can rotate and translate the position of the textures.

The last appearance node is FontStyle, which applies to text geometry specified with the Text node. FontStyle can be used to choose bold or italics lettering, and also to set properties like the size and spacing of the font. You even can select the direction in which text is placed.

Geometry

Geometry nodes let you create 3-D geometry that will be rendered in the VRML world. Geometry nodes can be used only as a value of the Shape node. Some geometry nodes are called primitives, because they draw simple 3-D shapes. Box, Cone, Cylinder, Sphere, and Text are the geometry primitives in VRML 2.0. Using primitives takes up minimal file size, as compared to other geometry nodes. People hand coding VRML have been able to create nice VRML worlds with very small file sizes using primitives, whereas world creators exporting from 3-D modeling software often end up with huge files.

Note
If you are familiar with VRML 1.0, you will notice that the Cube node now is named Box. Also, the Text node replaces 1.0's AsciiText node

.

Box creates a 3-D box or cube-like structure. Cone creates a cone, like a megaphone. Cylinder is useful for creating columns or cans. Sphere creates a 3-D ball. You can get neat effects texturing images onto Sphere nodes. The Text node allows for multilingual text in a 3-D space. Text nodes usually are rendered as 2-D text, like a texture.

Extrusion and ElevationGrid are two new nodes in VRML 2.0. Extrusion lets you create fancy surfaces by defining a 2-D cross-section and then twisting it out into a third dimension. Extrusion is a common tool in CAD and 3-D modeling software. ElevationGrid creates a 3-D surface like a landscape but uses little file space. Instead of giving a list of all the polygons making up the landscape (using IndexedFaceSet), you only need to give the value of the heights at various points.

For the other geometry nodes, you will not want to type them by hand. They most likely will be used in VRML files as geometry that has been exported from 3-D authoring tools.

IndexedFaceSet, IndexedLineSet, and PointSet are three geometry nodes that depend heavily on the geometry property nodes discussed in the next section-in particular, the Coordinate node. IndexedFaceSet creates flat polygons. These can be combined to create all kinds of objects-even to give an appearance of curvature. IndexedLineSet creates 3-D lines, which is great for creating grids. PointSet lets you create clusters of points.

Geometric Properties

The Geometric Property nodes apply to objects created with IndexedFaceSet, IndexedLineSet, and PointSet. The browser stores the current values of the Color, Coordinate, Normal, and TextureCoordinate nodes and then applies them when you use one of the previously mentioned geometry nodes. The Coordinate node is the easiest to understand. It lists the 3-D coordinates for the points that will be used in drawing polygon faces with an IndexedFaceSet node, for example. TextureCoordinate is the second most important node, because it maps square 2-D images onto non-square 3-D objects. The Color node lets you have a piece of geometry with several colors on a single polygon. The Normal node is not often used, although it can be used to affect lighting.

Interpolators

Interpolators are a class of nodes that do not create any rendered geometry. They are used for keyframe animation-a kind of animation where you give the position of an object at different times and the computer calculates the positions in between.

The ColorInterpolator is used for gradual changes between different colors. You could change a cube from red to green abruptly, or you could use a ColorInterpolator to make the change gradually. OrientationInterpolator allows for keyframe animation based on the rotation of an object. PositionInterpolator is useful for changing the location of objects-for example, moving a robot along a path.

CoordinateInterpolator is somewhat similar to PositionInterpolator, in that it deals with 3-D vectors; however, it interpolates several at one time-ideal for morphing objects! ScalarInterpolator causes shifts between single-value numbers. You could use a ScalarInterpolator to change the transparency of an object from visible to invisible, for example.

Leaf Nodes

Leaf nodes are nodes that can be children of grouping nodes. The leaf nodes include three lighting nodes: DirectionalLight, PointLight, and SpotLight. SpotLight radiates in a cone, like a car headlight or a spotlight in a theater. PointLights radiate in all directions, like bare lightbulbs. DirectionalLight radiates in a parallel direction, like a wall of light.

The Shape node is used to create geometry. It takes an Appearance node and a Geometry node as the value of its fields. Sound and AudioClip nodes are used to bring sound to VRML worlds. The sounds can be spatialized, located in 3-D space, and in formats like WAV, MID, or even MPEG.

Bindable Nodes

Bindable nodes include Background, NavigationInfo, Fog, and Viewpoint. Only one of each of these nodes can be active at one time. Background lets you create an elaborate background for the world, which can include a variety of ground and sky colors, plus background images. NavigationInfo sets what navigation mode the viewer is using. Viewpoint nodes are predefined cameras where viewers can move to and look through. Fog sets the background blurriness-the point at which objects blend in with the color of the fog, given in the Fog node's color field.

Global Nodes

WorldInfo gives general information about the VRML world-in particular, the title, creator, and copyright information. This node is not rendered.

The Script node references programs written in Java, JavaScript, or other languages. On occasion, these programs can be inside the VRML file, or they can be in another URL. The node also defines the inputs, outputs, and properties associated with the script. In the VRML 2.0 specification, there will be no required language that a VRML 2.0 browser must support. However, if it does support Java, JavaScript, or C, the browser must implement the API specified in the VRML 2.0 specification.

ROUTEs

ROUTE statements are at the end of the VRML file and indicate the connections between different nodes. You can think of ROUTEs as wires between different components on a circuit board or as roads between cities. ROUTEs can be used to connect sensor nodes with timers, geometry locations, and rotations.

VRML Authoring Tools

When you want to build 3-D objects in VRML, you can use standard 3-D modeling software or special VRML authoring tools optimized for VRML. If you use 3-D modeling software, you might be able to export the object to VRML format. Alternatively, you can save the object in a common format like 3DS or DXF and then convert it to VRML using conversion software. Two popular VRML authoring tools are Paragraph's Virtual Home Space Builder and Caligari's Pioneer.

Paragraph's Virtual Home Space Builder

Virtual Home Space Builder is VRML authoring software from Paragraph designed to let people create a simple world quickly (see Fig. 28.12). Users can save the world in VRML 1.0 format or in Paragraph's own MUS format, which has sound capabilities. VHSB is a lot of fun for an affordable price and is a nice way to put a first world together. It is oriented primarily toward building worlds out of cubes.

Figure 28.12: Paragraph's Virtual Home Space Builder VRML authoring software.

VHSB has a very cool user interface, including a first-person view window, a 2-D architectural overview, tool panels, and a camera panel that lets you visually set the properties of the camera looking at the first-person view window. There is also a pictures window that lets you select pictures, movies, and textures to wallpaper on surfaces.

Caligari's Pioneer

Pioneer, from Caligari, is a VRML 3-D modeling tool based on Caligari's popular Truespace 3-D modeling software (see Fig. 28.13). Instead of using building blocks, you can start with geometric primitives like spheres, cubes, and doughnuts. You even can subtract objects from other objects (take a bite out of a ball). Pioneer also lets you paint faces of an object with different materials. These materials can be colors or image textures.

Figure 28.13: Caligari's Pioneer VRML authoring software.

Pioneer also has great 3-D text. You use the text primitive to write some letters, use the Sweep tool to turn the text into 3-D, and then twist it out as far as you want. It's fun to paint the 3-D text with different materials.

When it comes to saving your file, Pioneer has a great setting that lets you optimize the VRML file size by doing such things as trimming the decimal places off of numbers. You also can choose whether to have nice spacing in the VRML file-a choice between easy source file readability and file size. There also is a special tool for wrapping an anchor onto an object so that it is a link to another URL.

Both Pioneer and Virtual Home Space Builder create bigger file sizes than editing VRML by hand, but they are much quicker!

Business Applications of VRML

VRML lets you do interesting things, but you might wonder how it can be useful in a business context. Pepsi is interested in VRML for marketing its brand. Price Waterhouse is looking to combine VRML and Java as a 3-D interface to its knowledge warehouses and information databases. Japanese companies like Mitsubishi and NTT are developing VRML prototypes for multiuser collaboration. Sony Pictures is using VRML worlds to promote its movies.

Other companies, like IBM, are looking to VRML as a standard format for communicating 3-D data and objects. A company in Israel uses VRML to display the cables it makes over the World Wide Web. A robot company's Web site provides VRML versions of its robots and manufacturing plant configurations. And videogame companies are looking to VRML as an environment for multiuser, networked games.

In the long term, VRML and networked 3-D have immense business possibilities, such as these:

Financial visualization
Data/Information visualization
Computer-aided design
Architecture
Marketing at an emotional level
Entertainment
Social computing
Education
Advertising
Multiuser environments

In the short term, here are simple ways to include VRML in a Web site. You might include directions to a geographic location, such as company headquarters, on your Web site in VRML. Or, you could have a 3-D representation of an office building or factory floor to help people find their way around. For products that require installation, such as computers and printers, you can create a 3-D installation demonstration. And nothing in 3-D is easier for people to understand than a 3-D spinning corporate logo.

VRML Resources

Here are pointers to VRML resources on the Web, including VRML browsers, authoring tools, information sites, and tutorials.

Browsers

Black Sun CyberGate  http://www.blacksun.com  A VRML 1.0 browser with extensions for multiuser interaction.

Cosmo Player  http://vrml.sgi.com  A VRML 2.0 browser from Silicon Graphics, which uses VRMLScript as its scripting language.

CyberPassage  http://sonypic.com/vs  A VRML 2.0 browser from Sony, which uses Java as its scripting language and has extensions for multiuser interaction.

Live3D  http://www.netscape.com/eng/live3d  A VRML 1.0 browser from Netscape, which is built into the standard edition of Netscape Navigator 3.0.

Onlive Traveller  http://www.onlive.com  A VRML 1.0 browser with extensions for multiuser interaction and multiuser sound.

Authoring Tools

Caligari Pioneer  http://www.caligari.com  A 3-D modeler for VRML authoring.

Paragraph Virtual Home Space Builder  http://www.paragraph.com  A VRML authoring tool for designing simple VRML worlds, buildings, and art galleries.

VRML Information

Live3D/LiveConnect Examples  http://www.aereal.com/liveconnect  Contains examples of how to use LiveConnect and JavaScript to communicate with the Live3D VRML plugin.

ORC Models Site  http://www.ocnus.com  Has several hundred VRML models.

VRML/Java/JavaScript FAQ  http://www.aereal.com/faq  Contains answers to frequently asked questions about the intersection of VRML with Java and JavaScript.

VRMLSite Magazine  http://www.vrmlsite.com  The first VRML Web magazine.

VRML 2.0 Tutorials

Matt's VRML 2.0 Tutorial
http://stripe.colorado.edu/~leonarm/vrml2.0/tutorial.html

Vijay Mukhi's Computer Institute's VRML 2.0 Tutorial
http://www.neca.com/~vmis/sgivrml.htm

Westlake's VRML 2.0 Tutorial
http://demo.westlake.com/vrml2/index.html

ActiveVRML

As part of the Request for Proposals for the VRML 2.0 specification, Microsoft submitted a proposal called ActiveVRML. Since then, Microsoft has announced that it will support the VRML 2.0 specification as decided on by the VRML community, and it has licensed Dimension X's Liquid Reality Java/VRML technology. ActiveVRML is a technology that integrates a variety of multimedia types, which can include 3-D.

The Future of VRML

What's next in VRML? VRML 2.0 brings in a whole variety of new features and capabilities that will take some time for browser developers, tool developers, and content creators to explore. Some members of the VRML community even ask if there'll be a need for a VRML 3.0 with significant changes. The main standardization still off in the future is a requirement for a scripting language in VRML 2.0.

There also may be agreements and standard protocols for multiuser worlds, although that does not need to affect the VRML specification directly.

Moving forward, VRML will reach into visualizing the dataspaces of information and the Internet, and also visualizing the real world itself. VRML authoring tools will exist inside the VRML browser itself. Standard extensions will be developed for combining CAD parts databases with VRML. Standard protocols for multiuser interaction and conferencing will be developed. It's been just more than a year between the finalization of VRML 1.0 and VRML 2.0. One can only guess where the Web will be five years from now.