3D Animation Workshop: Lesson 32: VRML 97--Using Authoring Tools | WebReference

3D Animation Workshop: Lesson 32: VRML 97--Using Authoring Tools


Lesson 32 - VRML 97--Using Authoring Tools - Part 1

I've been having so much fun with the new VRML, it's scary.

Our past few lessons focusing on VRML 2 (VRML 97) technology have worked directly with the code, developed by hand. This enabled us to understand some of the basic principles and keep things as simple as possible. It also limited us to very crude models and scenes. We used default primitive shapes, like the Box and Sphere nodes, in our examples because these objects can be defined in just a few lines of code.

More sophisticated geometry requires code that explicitly defines all the points and polygons in an object. Take a cube. To define it explicitly (instead of using the Box primitive) we must use the IndexedFaceSet node. The full definition of the node is quite complex, but at a bare minimum, it contains a list of all the points that constitute the vertices of the all the polygons in the mesh and a list defining all of the polygons themselves using the vertex list.

Take a look at the following code, defining a 1 meter cube.

The basic idea is not all that hard to understand, and is essentially the concept used in most polygonal geometry files. All the vertices are listed, defined by their x,y,z coordinates. Note that there are eight points listed, constituting the eight corners of a cube. Then these points are connected to make the rectangular faces. (Using the typical programming convention, the points in the lists are numbered 0-7, rather than 1-8) Thus the first polygon face is created by linking points 0, 1, 2 and 3 from the list. (The -1 is a delimiter, closing a face.) The second face connects points 1, 4, 5 and 2. This method of storing point and polygon information saves space because the same points are used multiple times in different polygons.

Note some classic VRML peculiarities in this code. The coordIndex field lists the polygons directly. But coord field (containing the points) is more complex. The coord field calls for a Coordinate node, which in turn contains a point field with the list of points enclosed. This allows these points to be referenced in other models. We've seen the same idea in previous lessons used to reference a single color for multiple models.

Just a quick look at this method of defining geometry should alert us to at least two important considerations. The first is that models with any degree of complexity will require many, many lines of code. Gzip compression can greatly reduce file size for modem transmission purposes, but the developer seeking to read his or her own code can face a difficult time. Even relatively simple objects can run for pages of VRML code and make the file difficult to edit and comprehend.

The second consideration follows naturally. It would obviously be impossible to create anything more than the simplest models by writing the code. We need interactive tools to create the models and scenes.

To Continue to Parts 2 and 3, Use Arrow Buttons

Created: January 19, 1998
Revised: January 19, 1998

URL: https://webreference.com/3d/lesson32/