spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / 3d / lesson32

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

Developer News
Intel's Building Blocks Thread Open Source
What Lies Ahead for SOA?
Novell Turns ICE Into Kablink

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.

    #VRML V2.0 utf8 Shape { geometry IndexedFaceSet { # faces: 6 coord Coordinate { point [ -.5 -.5 .5, .5 -.5 .5, .5 .5 .5, -.5 .5 .5, .5 -.5 -.5, .5 .5 -.5, -.5 -.5 -.5, -.5 .5 -.5 ] } coordIndex [ 0, 1, 2, 3, -1, 1, 4, 5, 2, -1, 6, 0, 3, 7, -1, 4, 6, 7, 5, -1, 3, 2, 5, 7, -1, 6, 4, 1, 0, -1 ] }# End of IndexedFaceSet }#End of Shape node

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




JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Simple Comments Release Notes: v.960 · Adding Client Capabilities to Server Controls Using the ASP.NET AJAX Control Toolkit · How to Create an Ajax Autocomplete Text Field: Part 10
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Data Corruption: Dedupe's Achilles Heel · AccessLine Launches SOHO VoIP Product with Costco · Cisco to Acquire Pure Networks

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

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