VRML example: Basic Pyramid

This example shows the basic definition of a polygon based object.

#VRML V1.0 ascii

Separator {
   Material {
      diffuseColor 1.0 1.0 1.0
      ambientColor 0.1 0.1 0.1
   }
Give the object some color and surface properties. The object is white and it is not reflecting any light. The object is mildly lighted (defined by ambientColor), even when there is no light defined in the world.

   Coordinate3 {
      point [
         0    5   0,
        -2.5  0  -2.5,
         2.5  0  -2.5,
         2.5  0   2.5,
        -2.5  0   2.5
      ]
   }
The point field defines the vertices of the object. There are five points defined. The points are labeled from 0 to 4.

   IndexedFaceSet {
      coordIndex [
         0, 4, 3, -1,
         0, 3, 2, -1,
         0, 2, 1, -1,
         0, 1, 4, -1,
         1, 3, 4, -1,
         1, 2, 3, -1
      ]
   }
}
The coordIndex field defines the polygons of the object. There are six polygons defined. Each polygon is a triangle, so three points are named in the vertices list and the -1 terminates the list. A polygon can have an arbitrary number of vertices.