by Jim O'Donnell
For information distribution on the Internet, the next big step beyond HTML may be the Virtual Reality Modeling Language (VRML). HTML's hypertext links, and the Web browsers that make use of them, create a two-dimensional interface to Internet information. VRML expands this by allowing the creation of three-dimensional worlds on the Web, offering a much more intricate way of presenting information. The advent of VRML 2.0 has expanded the use of VRML from static worlds to ones with interactivity, motion, and sound.
The process of creating a VRML world involves several steps, from the creation of VRML objects to their placement and assembly into a complete VRML world. Then, using VRML 2.0 or Java, it is possible to bring that world alive. This chapter discusses the lowest level step in this process, the creation of VRML objects.
The VRML is a language intended for the design and use of three-dimensional, multi-person, distributed interactive simulations. To put it in simpler language, VRML's designers intend it to become the building block of cyberspace.
The World Wide Web is based on HTML (Hypertext Markup Language),
which was developed from the SGML (Standard General Markup Language)
standard. SGML and HTML are fundamentally designed as two-dimensional
text formatting toolsets. Mark D. Pesce, Peter Kennard, and Anthony
S. Parisi presented a paper called Cyberspace at the First
International Conference on the Web in May 1994, in which they
argued that, because humans are superb visualizers and live and
work in three dimensions, extending the Web with a third dimension
would allow for better organization of the masses of data already
on the Web. They called this idea the Virtual Reality Markup Language.
The concept was welcomed and the participants immediately began
searching for a format to use as a data standard. Subsequently,
the M in VRML was changed from Markup to Modeling
to accentuate the difference between the text-based nature of
the Web and VRML.
| NOTE |
Cyberspace is available over the Web at http://www.hyperreal.com/~mpesce/www.html |
Silicon Graphics' Open Inventor was settled on as the basis for creating the VRML standard. Open Inventor is an object-oriented (C++) developer's toolkit used for rapid development of three-dimensional graphic environments. Open Inventor has provided the basis for a number of standards, including the Keystone Interchange Format used in the entertainment industry and the ANSI/ISO's X3H3 3D Metafile specification.
VRML's design specifications were guided by the following three goals:
The building blocks of VRML creations, usually called VRML worlds,
are objects created in VRML. The VRML language specification contains
a collection of commands, called nodes, for the creation of a
variety of simple objects such as spheres, cubes, and cylinders,
as well as objects consisting of an arbitrary collection of vertices
and faces.
| NOTE |
For a three-dimensional object, faces are the flat surfaces that make up the object and vertices are where the faces meet. A cube, for instance, has six faces and eight vertices |
VRML allows for the creation of more complex objects through the combination of simple objects. It is a hierarchical language, with child objects inheriting the properties of their parents. For instance, if a complex object is defined to create a model of a human body, by default, any properties defined for the body as a whole (such as color) also apply to the simple objects that make up the body, such as the head, arms, legs, and so on. The rest of this chapter focuses on the creation of VRML objects.
The assemblage of VRML objects into a coherent whole defines a VRML world. There are many example VRML worlds on the Web that use the three-dimensional paradigm for different purposes. To define the placement and relationship of different objects to one another, you need to be able to specify their relative sizes and positions, using VRML's different coordinate systems. Additionally, VRML allows you to define what lighting sources are present in your world and what preset views are included.
Chapter 53, "Creating VRML Worlds," discusses the steps necessary to go from a collection of VRML objects to a VRML world.
VRML 1.0 worlds are static. The only motion within them is the movement of the viewpoint representing the user as he or she uses a VRML browser to traverse through the VRML world. With the definition of VRML 2.0, VRML's capabilities were extended to allow the creation of dynamic worlds.
VRML 2.0 objects can now be given movement of their own, and three-dimensional sound (audio that sounds different depending on the position of the listener with respect to the source) can be added. Another new capability introduced with VRML 2.0 is the ability to add behaviors to VRML objects. Behaviors-which can be scripted or specified in Java applets, for instance-are characteristics of objects that depend on their relationship to other objects on the VRML world, to the viewer, or to other parameters, such as time. For instance, a VRML 2.0 fish in an aquarium might swim away if you get too close to it.
The additional capabilities of VRML 2.0 are discussed in Chapter 54, "VRML 2.0: Moving Worlds," and Chapter 55, "Java and VRML."
As a Web author interested in VRML, you need to ask yourself what you would like to achieve with it. Unfortunately, there are two important characteristics of VRML that restrict its usefulness at the current time. The first is that VRML worlds tend to be big. Specifying three-dimensional objects as a collection of flat surfaces can lead to very large object descriptions, particularly when trying to model a curved surface. The other important characteristic is that the connection speed of the majority of people on the Internet is still limited to no higher than that achieved with a 28.8Kbps modem.
Full-blown VRML worlds can take a long time to be transmitted over the Internet, which very often limits the audience to only those people looking for cool VRML worlds to look at. These worlds can also be extremely complicated to define and set up, requiring a lot more discussion than the space we have here. (Something more along the lines of Que's Special Edition Using VRML is needed to adequately cover the subject.)
However, a very good use for VRML (one that doesn't have the problems of requiring huge files to be downloaded) is to add special effects to HTML Web pages. This is particularly true now that Netscape's Live3D plug-in, which adds Moving Worlds-based VRML capabilities to Netscape Navigator, is being distributed along with Netscape Navigator 3. This fact, and the ability to embed small VRML scenes into HTML Web pages, makes VRML an ideal addition to the Web author's bag of tricks.
Because of this, the primary focus of the VRML section of this book will be to familiarize you with enough VRML that you can create small VRML scenes to achieve specific special effects within your Web pages. In the course of doing so, you will also learn enough of VRML and its syntax to give you a good grasp on the language fundamentals so that you can move on to the creation of larger VRML worlds, if you so desire.
The final version of the VRML 2.0 specification, released on August 4, 1996, is based on the Moving Worlds proposal submitted to the VRML Architecture Group by a consortium led by Silicon Graphics. While similar in many respects to VRML 1.0 and required to be backwards-compatible with that specification, VRML 2.0 changes, deletes, and creates many different nodes to the VRML language. The increased functionality of these new nodes includes the ability to add movement, sounds, animation, and behaviors to VRML objects.
Although the VRML 2.0 specification has been finalized, VRML authoring and viewing tools that support the VRML 2.0 specification are still few and far between. If you are creating VRML objects, scenes, or worlds for the Web-either as worlds on their own or as special effects embedded within a Web page-you need to be aware that the audience of people with VRML 2.0-compatible browsers is still very limited. If you have a special need for a feature of VRML 2.0, then you obviously need to use VRML 2.0. Otherwise, VRML 1.0 is still a good choice.
Because there is a dearth of tools supporting VRML 2.0, this chapter and the next one will primarily concentrate on VRML 1.0 and use VRML 1.0 syntax for the examples. All the examples created will be supported by VRML browsers that fully support the VRML 2.0 specification because they must be backwards-compatible. Also, the syntax for most of the nodes used is exactly the same in VRML 1.0 as it is in VRML 2.0.
In Chapter 54, "VRML 2.0: Moving Worlds," VRML 2.0 and Moving Worlds-compatible browsers are used to illustrate the abilities of VRML 2.0.
VRML files are plain ASCII (though they are often gzipped to make them easier to transmit over the Internet), which means that you can create them using ordinary text editors. It is quite likely that you will decide to use a VRML authoring program if you want to create a very large, complex VRML world-and even smaller worlds, if you have an authoring program available-in which case the details of VRML syntax will be hidden from you. It is a good idea to get a basic grasp of the important VRML language elements, though. Later, this will help you get the results you want.
Listing 52.1 shows a simple VRML file that will display a red sphere on a white background (see Figure 52.1).
Figure 52.1 : Specifying simple objects can be done with just a few lines of VRML code.
Listing 52.1 Redball.wrl-A Red VRML Sphere
#VRML V1.0 ascii
Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Separator {
Material {
diffuseColor 1 0 0 # the color red
}
Sphere { }
}
}
The VRML comment character is the #; everything after a # on any line is a comment (such as the color red). The first line of the file begins with a #, so it is a comment. Unlike other comments in the file, this one is necessary. It identifies the file as being VRML and gives the version number of VRML used. VRML browsers require this information to be located at the start of any VRML file.
The first line of the file shown in Listing 52.1 reads #VRML V1.0 ascii, meaning the file conforms to version 1.0 of the VRML specification. The word "ascii" means the standard ASCII character set is used in the file. VRML 2.0 files will generally have the comment #VRML V2.0 utf8 in their first line, indicating conformance to the VRML 2.0 specification and that an international character set based on ASCII is being used.
Other than ignoring comments, the file format is entirely free-form. Anywhere there is white space-tabs, spaces, or carriage returns-you can have as much or as little space as you'd like. For instance, an equivalent listing to the one shown in Listing 52.1 would be
#VRML V1.0 ascii
Separator{Info{string "Platinum Edition, Using HTML, Java, and CGI"}
DEF BackgroundColor Info{string "1 1 1"}Separator{Material{diffuseColor 1 0 0}
Sphere{}}}
| TIP |
As with any programming language, you should structure and comment your VRML files well enough that they can be easily read and understood |
If you are familiar with the C, C++, or Java programming languages, you will recognize the braces ({ and }) to define blocks of related information. VRML files are made up of nodes, which look like the following:
NodeType { configuration information }
The NodeType refers to one of the types of nodes that is supported by the VRML specification. The full VRML 1.0 and 2.0 specifications can be found on the CD-ROMs that accompany this book. The example shown in Listing 52.1 uses four different kinds of nodes: Info, Separator, Material, and Sphere.
Configuring Nodes with Fields The configuration information inside the braces consists mainly of fields. In the example, the two Info nodes have string fields, and the Material node has a field called diffuseColor. In general, each field will have a name and a value. For the diffuseColor field, the value is 100, a set of three numbers that indicate the color to use for the Sphere, which follows (the three numbers list the color's components in the order red, green, blue).
Field values can be simple numbers, groups of numbers, strings, keywords, images, boolean values, and more. Some fields can have multiple values, in which case the values are separated by commas and surrounded by square brackets. For example, you could specify three colors for the diffuseColor field of the Material node as
Material { diffuseColor [1 0 0,0.5 0.5 0,0 1 0] }
Naming Nodes Any node can be assigned a name by which it can be referred to later. This is done with the DEF prefix
DEF BackgroundColor Info { string "1 0 0" }
In this case, BackgroundColor is a special, predefined
node name used to specify a background color. In general, though,
you can assign any name to any node.
| CAUTION |
Specifying a background color, as shown previously, is not a standard part of VRML 1.0-it is an extension to the specification supported by some VRML browsers. If you are using a VRML browser that does not support this extension, the node will be ignored and the background will remain the default color used by the browser (usually black). This background color node is used in the examples shown in this book because there is no official way in VRML 1.0 to set a background color, and it is necessary to do so to enable the examples shown to be clearly reproduced in printed form |
A VRML world can be thought of as a hierarchy of simple VRML objects. In VRML, the Separator node is used as the container for an object. Not all Separator nodes contain any geometry (vertices and faces of VRML objects); some are used for grouping other objects together into a more complex object. This is how object hierarchies are specified in VRML. The attachment information is specified by placing objects within other objects, using the Separator node. In other words, the Separator node can contain children nodes to describe objects that are attached to it.
Grouping VRML objects into hierarchies and building them into full VRML worlds will be discussed in greater depth in Chapter 53, "Creating VRML Worlds."
The VRML 1.0 specification includes eight nodes that let you specify geometric shapes. All VRML 1.0 objects will be made up of one or more of these nodes. The nodes and syntax for each, along with an example VRML file, are shown as follows:
The Sphere node is very simple; it has only one field, called radius, that gives the radius of the sphere (the default radius is 1). Listing 52.2 shows an example of the default sphere, which is shown, as rendered by Live3D within Netscape Navigator, in Figure 52.2.
Figure 52.2 : A standard VRML sphere of radius 1.
Listing 52.2 Sphere.wrl-A Simple VRML Sphere
#VRML V1.0 ascii
Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Sphere {
radius 1
}
}
A VRML Cone node is made up of two parts: the sides and the bottom. Both of these parts are optional. By default, a cone has both, but the parts field can specify one or the other by setting it to a value of SIDES or BOTTOM (instead of ALL, or omitting it altogether). A cone has two other fields: height, specifying the height of the cone sides, and bottomRadius, specifying the radius of the bottom. The default values for these are a bottomRadius of 1 and a height of 2.
Listing 52.3 shows an example of a VRML cone, with sides but no bottom. As shown in Figure 52.3, when this cone is rotated to where you could normally see its bottom, nothing is shown there.
Listing 52.3 Cone.wrl-A Simple VRML Cone
#VRML V1.0 ascii
Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Cone {
bottomRadius 2
height 6
parts SIDES
}
}
A cylinder created by the VRML Cylinder node has three parts: the sides, the bottom, and the top. Its fields are the same as that of a cone and have the same default values, except that the parts field can also have the TOP value. A longer, fatter cylinder is created through Listing 52.4, as shown in Figure 52.4.
Figure 52.4 : A standard VRML cylinder.
Listing 52.4 Cylinder.wrl-A Simple VRML Cylinder
#VRML V1.0 ascii
Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Cylinder {
radius 2
height 6
parts ALL
}
}
| NOTE |
Whereas the Sphere, Cone, and Cylinder nodes seem to specify curved surfaces in VRML, when the VRML file is parsed by a VRML browser, the objects are converted into vertices and faces through a process called tessellation. To see this for yourself, load a VRML example showing one of these curved surfaces into a VRML browser and switch the browser into flat-shading mode (in Live3D, you do this by right-clicking in the VRML scene and selecting Lights, Flat Shading) to see the individual faces |
A VRML Cube node creates a simple three-dimensional rectangular solid. Its fields are width, height, and depth (all of which have a default value of 2). Listing 52.5 shows an example of a more coffin-shaped VRML cube (see Figure 52.5).
Listing 52.5 Cube.wrl-A Simple VRML Cube
#VRML V1.0 ascii
Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Cube {
width 2
height 6
depth 2
}
}
The AsciiText node allows you to create flat text objects in VRML. Because the resulting text is flat, it is possible that it might not be visible when viewed, if looked at edge on. The AsciiText node has four fields: string, spacing, justification, and width.
The string field specifies the string or strings to be displayed. Strings are specified in double quotes-if multiple strings are desired, each string is specified in double quotes, separated by commas, and enclosed in square brackets. The spacing and width fields control vertical and horizontal spacing of the strings, respectively; the default value of 0 for each indicates the natural spacing of the font and text used. For AsciiText nodes that have a string field with multiple strings, the justification field, with possible values of LEFT, RIGHT, or CENTER, specifies how each line is justified with respect to the others.
Listing 52.6 shows an example of the use of the AsciiText field, with the results shown in Figure 52.6.
Listing 52.6 Ascii.wrl-Two-Dimensional VRML ASCII Text
#VRML V1.0 ascii
Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
AsciiText {
string ["This Is","A Test","Of AsciiText"]
spacing 2
justification CENTER
width [0,0,0]
}
}
The nodes discussed so far are a useful start, especially if you're building simple worlds by hand. Most VRML files, however, make extensive use of another node, IndexedFaceSet. An IndexedFaceSet node is a way of describing an object using a set or vertices that are joined together by faces. Listing 52.7 shows an example of this, which creates a pyramid using five vertices and five faces to create the four sides and the base (see Figure 52.7).
Figure 52.7 : VRML indexed face sets can be used to construct arbitrary three-dimensional solids.
Listing 52.7 Pyramid1.wrl-Arbitrary Objects with VRML's IndexedFaceSet Node
#VRML V1.0 ascii
DEF Pyramid Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Coordinate3 {
point [-1 0 -1,
1 0 -1,
1 0 1,
-1 0 1,
0 2 0]
}
IndexedFaceSet {
coordIndex [0, 4, 1, -1,
1, 4, 2, -1,
2, 4, 3, -1,
3, 4, 0, -1,
0, 1, 2, 3, -1]
}
}
The array of vertex coordinates is specified using the Coordinate3 node and its field, point. The point field takes multiple values, each of which is a triplet of numbers giving the x, y, and z coordinates of one vertex. (Chapter 53 discusses VRML coordinate systems in greater detail.) There can be as many vertices as you need. Keep in mind, though, that each vertex needs to be specified only once, no matter how many faces it is used in.
The actual IndexedFaceSet node contains a field called
coordIndex that stores a list of faces, as specified
by the indices of vertices in the order they are used for each
face. For instance, the sequence 0, 4, 1, -1 is used
to create one face from the 0th, 4th, and 1st vertices (vertices
are numbered from 0). The -1 signifies the end of the
current face and the next face can begin with the next number.
| Some Hints on Using IndexedFaceSet |
Although IndexedFaceSet is a very powerful tool, there are some things to watch out for when you are using it Make sure all the vertices in a given face are coplanar, meaning that the face is flat (this will be true if either the x, y, or z component of each vertex in the face is equal). If one or more of the vertices are not in the same plane, then the object will look very strange when viewed from certain angles. Avoid T-intersections. Two faces should always meet at a shared edge. If you have a face that touches another face without sharing common vertices, the round-off errors in the VRML browser will cause viewing problems. Avoid using too many faces, when possible, since that will slow down rendering more than any other factor. |
Sometimes, you do not want to create polygon-based figures but, instead, are satisfied to use lines. For example, the spokes of a bicycle wheel might best be represented by simple lines rather than Cylinder nodes. Not only is it easier, it will also render much faster.
To create sets of lines, use IndexedLineSet. The syntax is exactly the same as the IndexedFaceSet node. Listing 52.8 and Figure 52.8 show the same pyramid figure created in Listing 52.7, using IndexedLineSet instead.
Figure 52.8 : Indexed line sets in VRML define lines between vertices in three-dimensional space.
Listing 52.8 Pyramid2.wrl-Collections of Lines with VRML's IndexedLineSet Node
#VRML V1.0 ascii
DEF Pyramid Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Coordinate3 {
point [-1 0 -1,
1 0 -1,
1 0 1,
-1 0 1,
0 2 0]
}
IndexedLineSet {
coordIndex [0, 4, 1, -1,
1, 4, 2, -1,
2, 4, 3, -1,
3, 4, 0, -1,
0, 1, 2, 3, -1]
}
}
One last geometric node in VRML is PointSet. This is used to represent individual points rather than shapes, solids, or lines. PointSet is also used in conjunction with the Coordinate3 node, and uses the two fields startIndex and numPoints to determine which vertices it uses (the default values are 0 and -1, which means start at the 0th vertex, and use all of them). Listing 52.9 shows an example of a PointSet. The usefulness of the PointSet node can be quite limited because the appearance of the point is browser dependent, and there is no way for the VRML author to make them larger.
Listing 52.9 Points.wrl-Collections of Points with VRML's PointSet Node
#VRML V1.0 ascii
Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Coordinate3 {
point [-1 -1 -1,-1 0 -1,-1 1 -1,
1 -1 -1, 1 0 -1, 1 1 -1,
1 -1 1, 1 0 1, 1 1 1,
-1 -1 1,-1 0 1,-1 1 1]
}
PointSet { }
}
VRML offers several different ways of changing the appearance of its objects. One of these, the Material node, is shown in Listing 52.1, and was used to create a red sphere. Two nodes in particular can be used to affect the color, texture, and general appearance of VRML objects: the Material and Texture2 nodes.
One other important way to affect the appearance of VRML objects is through the lighting that is used. Specifying direction, type, color, and intensity of light sources placed within a VRML world can greatly influence how the objects within it appear. This is discussed in Chapter 53.
The most common use of the Material node is the one shown in Listing 52.1-using its diffuseColor field to specify the color of an object. The fields that are supported by the Material node are as follows:
In spite of all the options presented, you will rarely want to make use of them. Most of the time, specifying a diffuseColor is enough, perhaps adding a non-default shininess or transparency value to achieve a special effect. Listing 52.10 shows the pyramid example with the Material node used to specify colors and transparency values for each face of the pyramid.
Listing 52.10 pyramidm.wrl-Adding Color and Other Effects with VRML's Material Node
#VRML V1.0 ascii
DEF Pyramid Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Material {
diffuseColor [1 0 0,0 1 0,0 0 1,1 1 0,0 0 1]
transparency [0,0,0,0,0.5]
}
MaterialBinding { value PER_FACE_INDEXED }
Coordinate3 {
point [-1 0 -1,
1 0 -1,
1 0 1,
-1 0 1,
0 2 0]
}
IndexedFaceSet {
coordIndex [0, 4, 1, -1,
1, 4, 2, -1,
2, 4, 3, -1,
3, 4, 0, -1,
0, 1, 2, 3, -1]
materialIndex [0,1,2,3,4]
}
}
Each face of the pyramid is given a different material value through the addition of the Material node, the MaterialBinding node, and the materialIndex field to the IndexedFaceSet node. The functions performed by each are as follows:
Figure 52.9 shows the result of this. While it is difficult to see the result when printed in black and white, it is clear when the VRML file is loaded into a VRML browser. (Note that VR Scout was used to render this example because it was not rendered properly by Live3D.) Each triangular face of the pyramid has one of the first four colors, rendered opaquely. The bottom of the pyramid is cyan but also half-clear. This means that when you look up through the bottom of the pyramid, you can see the sides, and their colors are affected by being filtered through the cyan.
With the Texture2 node, it is possible to achieve a much wider variety of effects. The Texture2 node maps an image file to a VRML object. Listing 52.11 shows an example with a photograph mapped onto a VRML cube (see Figure 52.10).
Figure 52.10 : Images can be mapped to the faces of VRML objects.
Listing 52.11 Cubet.wrl-Mapping an Image to an Object with VRML's Texture 2 Node
#VRML V1.0 ascii
Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Texture2 {
filename "jod.jpg"
}
Cube { }
}
Because all the faces are all flat in this example, the image isn't noticeably distorted. That isn't the case when images are mapped to curved surfaces, such as those created by the Sphere, Cone, or Cylinder nodes. Listing 52.12 shows another example, this time with an image mapped to a cylinder. As shown in Figure 52.11, the image appears undistorted on the top and bottom of the cylinder, but on the sides it is wrapped around the surface. Note that different graphics formats can be used as textures; which formats are supported is VRML-browser specific.
Figure 52.11 : Images mapped to curved surfaces are distorted as they are mapped to the surface.
| NOTE |
Live3D, while it supports textures, seems to be quite temperamental in which ones it will show correctly. The examples using textures in this chapter and the next, which work fine with VR Scout, may not work for you using Live3D |
Listing 52.12 Cylindet.wrl-Mapping Images to Curved Surfaces Results in a Distorted Image
#VRML V1.0 ascii
Separator {
Info {
string "Platinum Edition, Using HTML, Java, and CGI"
}
DEF BackgroundColor Info {
string "1 1 1"
}
Texture2 {
filename "billy.jpg"
}
Cylinder { }
}
As shown in the previous sections, creating simple VRML objects by hand is relatively easy. In Chapter 53, the discussion will focus on taking these simple objects, combining them into more complex ones, and assembling them into VRML worlds.
When creating a complicated VRML world, it is usually easier to do so using a VRML authoring program. Even for the creation of simple VRML objects, the task is made very easy using a modeling program. As with any program of this type, what you lose in precise control of your VRML world, you usually more than make up for in increased productivity and ability.
There are an increasingly large number of VRML and other three-dimensional
modelers and authoring programs available. Each program has its
strengths and weaknesses. Information about many of them can be
obtained through the VRML Repository, located at http://rosebud.sdsc.edu/vrml/.
For the purposes of illustrating some of the capabilities of such
programs, Pioneer, a VRML authoring program from the Caligari
Corporation, will be used.
| NOTE |
What follows is not a tutorial on how to use Pioneer. It is instead meant to show some of the capabilities of VRML authoring programs in general and Pioneer in particular |
Pioneer and a higher-end program called Pioneer Pro are commercial programs offered by the Caligari Corporation. Pioneer is available for download and a free 14-day trial evaluation through the Caligari home page at http://www.caligari.com/. Once the self-extracting archive is downloaded (version 1.0 of the program comes in an archive called Cp10.exe), it should be placed in a temporary directory and executed. This extracts the files of the archive-executing the resulting Setup.exe file will install Caligari Pioneer on your computer.
When you start Pioneer, you are first greeted with a sample three-dimensional world created with Pioneer. To get to a blank slate for creation of your own VRML objects, select File, World, New. You will see the screen shown in Figure 52.12.
| NOTE |
To make the examples more visible for this book, the background was changed to white by selecting File, Render Options, and clicking the Background button |
There are many buttons shown in the toolbar in Figure 52.12. For the examples shown in this chapter, only three will be used. By clicking the Primitives Panel button, the Primitives Panel shown in Figure 52.13 appears. This is how the simple VRML objects can be created.
Figure 52.13 : Pioneer's Primitives Panel gives quick access to three-dimensional shapes.
Creating a Sphere To create a VRML sphere, simply click the Add Sphere button in the Primitives Panel, and a sphere appears (see Figure 52.14). Pioneer has many options for resizing and moving the sphere, as well as applying colors, materials, and textures to it. Once you are happy with your VRML sphere, you can select File, World, Save to save it in Pioneer's own format or File, World, Save As to save it as a VRML file.
The VRML file for the simple sphere shown in Figure 52.14 is on the CD-ROMs that accompany this book as Cpsphere.wrl. If you look at this listing, and view it with a VRML browser, you will notice a few interesting things:
Three-Dimensional Text Some of the power of programs like Pioneer over VRML object and world creation by hand is shown in this example, which shows how to create three-dimensional text. You can create a three-dimensional rendering of any string by following these steps:
This three-dimensional text object can then be saved as a VRML object using File, World, Save As (and the example is included on the CD-ROMs in the file Cpjod.wrl). When viewed with VR Scout, it appears as shown in Figure 52.17.
As previously discussed, lighting and viewing angles can also be specified in Pioneer (and will be discussed in Chapter 53). The defaults saved along with this text object are obviously not that great. Use VR Scout to move the object around (see Figure 52.18).
If you are interested in creating VRML objects for use in a VRML world or with an embedded VRML special effect in a Web page, you should probably take a look around on the Web before starting from scratch. There are many places to get three-dimensional objects that you can use for your purposes, both in VRML files and in other formats that can be converted to VRML.
Probably the central clearinghouse of all things VRML, appropriately called the VRML Repository, is located at http://rosebud.sdsc.edu/vrml/ (see Figure 52.19). This Web site contains a vast array of information about VRML, links to sites containing VRML browser and authoring software and just about anything else you can think of that has to do with VRML. The site maintains a library of example applications, categorized by topic, that can be examined through the Web page at http://rosebud.sdsc.edu/vrml/worlds.html (see Figure 52.20).
Among the many other sites featuring VRML examples, applications, and objects, one is the VRML Models site shown in Figure 52.21, located at http://www.ocnus.com/models/models.html. This site, like the VRML Repository library, features an indexed list of VRML objects and worlds. A unique feature of the VRML Models site is its VRML Mall, which is an actual three-dimensional gallery through which you can view all of their VRML objects.
Finally, the Mesh Mart, located at http://cedar.cic.net/~rtilmann/mm/, was set up as a source of three-dimensional objects (see Figure 52.22). While most of their objects are not in VRML format, they are available in formats that can be easily converted to VRML. Through the Mesh Mart, a program called Wcvt2pov.exe is available which can convert between many different three-dimensional formats. It can read in files with the following formats:
And write out files in these formats: