Dateline: 6/14/00

This week I'd like to start a little series on some manipulations with and of the Indexed Face Set also known as the IFS, node of VRML. The IFS is the basic low level way of dealing with polygons. I'd also recommend using a tool like parallelgraphics VRMLPad as the text editor as it helps with silly syntax problems and is inexpensive anyway ($29.95).

First a little background, the IndexedFaceSet Node is one of several basic "geometry" descriptions. Geometry is how to specify a "shape". There are other ways of specifying geometry such as using a Box, Cone or Cylinder nodes. We must however start with a Shape node, then specify a Geometry node and then specify an IndexedFaceSet node. The basic structure of our VRML file for such a Shape might look like:

INCORRECT SYNTAX

Shape { Geometry { IndexedFaceSet {} } }

However the problem is that the geometry we need to author is a field of the shape node. A shape node is specified with two fields, an "appearance" and "geometry".

Shape{ appearance geometry }

Notice that the appearance and geometry fields are specified in lower-case. Case matters!

We will ignore the appearance field and just accept the defaults for this tutorial. Now let's start to build up the geometry, with an IndexedFaceSet. Our file fragment now looks like:

Shape{ geometry IndexedFaceSet { } }

The IndexedFaceSet node itself consists of quite a few fields however we will only deal with the "coord" and "coordIndex" fields and use the default values for everything else. Before we just to the details understand what exactly and IFS is. The IFS is a collection of 3D coordinates, points in space. We create polygons in space by connecting those points, via indexes to the points. The "coord" field contains the values for the, sometimes large, collection of 3D coordinates. The coorIndex specifies how those points should be connected to create a series of polygons.

The "coord" field requires a Coordinate node and the "coordIndex" field requires a list of integer values. Let's first define the Coordinate node. Keep in mind that the coordinate system for VRML has the X axis increasing to the right, the Y axis increasing upwards and the Z axis increasing towards the viewer (the Z is a little backwards for my brain). Let's define the points for two squares one on top of each other. We can do this with only six points. Arranged like:

5 6 3 4 1 2

The Coordinate node requires a series of 3 valued vectors (MFVec3f), which specifies the x,y,z values for the points. The actual coord Node with x,y,z specification could be defined as:

coord Coordinate { point [ [ 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,2,0, 1,2,0 ]

We now use the coordIndex field (of the IndexFaceSet node) to index into the collection of points. Counting however starts with index 0 not 1. So in this example the point specified as 1,1,0 would be selected via an index of 2. The coordIndex field would look like:

coordIndex [ 0,1,2,3,-1 ]

To create a square. The -1 tells the browser that it is the end of the polygon and the VRML browser automatically connects the last point specified to the first point. The entire geometry node looks like: <

geometry IndexedFaceSet { coord DEF MYPOINTS Coordinate { point [ 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,2,0, 1,2,0 ] } coordIndex [ 0,1,2,3,-1 ] }

Let's put all we've learned together now. ZZZPOLLBEGIN161314134POLLENDZZZ

**Next page**
**
Putting it All Together**
>Page **1**,2