Tutorial: More Understanding the IndexedFaceSet (IFS)

Dateline: 6/21/00

Last week we started down the path looking at how to create some crude IndexedFaceSets (IFS). Let's examine some of the other features of this most useful VRML Node. The full spec for the IndexFaceSet Node is quite large:

IndexedFaceSet { 
                      eventIn       MFInt32 set_colorIndex
                      eventIn       MFInt32 set_coordIndex
                      eventIn       MFInt32 set_normalIndex
                      eventIn       MFInt32 set_texCoordIndex
                      exposedField  SFNode  color             NULL
                      exposedField  SFNode  coord             NULL
                      exposedField  SFNode  normal            NULL
                      exposedField  SFNode  texCoord          NULL
                      field         SFBool  ccw               TRUE
                      field MFInt32 colorIndex [] 
                      field SFBool colorPerVertex TRUE
                      field SFBool convex TRUE
                      field MFInt32 coordIndex []  
                      field SFFloat creaseAngle 0 
                      field MFInt32 normalIndex [] 
                      field SFBool normalPerVertex TRUE 
					  field SFBool solid TRUE  
                      field MFInt32 texCoordIndex [] 
                    }

Four of the field types deal with arrays of indecies for different aspects of the collection of polygons which is the purpose of the node. The coord fields contains the actual data for the polygons. The color field (and colorIndex fields and event) contains the colors for those faces. The normal field (and normalIndex field and event) contains the data for the "normal" vector a line pointing perpendicular and away from the surface of the polygon. It's useful for lighting calculations. The texCoord field (and texCoorIndex field and event) contains the data for texture coordinates and which can be used as a method of applying textures to the polygons.

Buried in all these fields are a few Boolean fields that specify global characteristics of the entire IFS. These are: ccw, colorPerVertex, convex, normalPerVertex, and solid. Let's examine the solid and ccw boolean fields.

The solid flag specifies whether polygons have one or two sides. This is somewhat counter intuitive. We usually spend so much time making things look realistic that we often forget that polygons aren't real physical objects it's just a figment of your creation. Therefore it's possible to create a polygon with only one visible side. If you set the solid flag to FALSE and create a single polygon, when you flip it around it disappears! By default the solid flag is set to TRUE. It's very odd looking but it can save a whole lot of processing power. There is no reason for your computer system to calculate the visibility of, for example the interior of a box if you don't want people to travel into it.

Let's look at the ccw (which stands for counter clockwise).

Next page The ccw Flag >Page 1,2