The street light at the left will be created in this first tutorial. The model will
be a made from a collection of seven geometric objects, which are cylinders, cones and a sphere.
Each of these objects will be placed into a Transform node that will be used to move it into position.
The objects themselves will be Shape nodes.
Every Shape node is divided into two parts: its geometry and its appearance. The geometry field of a
Shape node contains the physical form of the object. In this example the contents of the geometry
field will be a Cylinder, Cone or Sphere, but there are many other geometry nodes, such as IndexedFaceSet.
The appearance field of a Shape node contains an Appearance node. In this tutorial, the Appearance nodes
will contain Material nodes which will be used to add color. The illustration at the left shows the basic
tree structure of the VRML file.
The structure of the file can also be seen in the user interface of SwirlX3D. Each node
in the tree has fields that describe the node. In this case the Material node has been selected
and the fields for this node are shown below. The diffuseColor field will be used later to
apply color to the objects.
The base of the lamp is a cylinder of radius 0.5 with a thickness of 0.1. Within a VRML file
the object is expressed as follows.
Transform {
children Shape {
appearance Appearance {
material Material {
diffuseColor 0 1 0
}
}
geometry {
Cylinder {
height 0.1
radius 0.5
}
}
}
}
The names of the fields start with small letters and the type of nodes placed into them
start with Captial letters. The colors are in RGB format with each color parameter between 0 and 1.
Thus the cylinder here willl be green. This object will look the same in a VRML97 file, which has
extension .wrl, or in a VRML 3.0 file, which has extension .x3dv. The X3D format is a type of
XML with file extension .x3d. The contents of the file in either case is same but in a different format
as can be seen from the following.
The main column is a cylinder of radius 0.1 and height 2. The Transform node has a translation
added to position the cylinder above the base. The y axis is the vertical axis in X3D.
Transform {
translation 0 1 0
children
Shape {
appearance Appearance {
material Material {
diffuseColor 0 1 0
}
}
geometry Cylinder {
radius 0.1
}
}
}
There are two other cylinders and a cone for the cover, that are made in a similar fashion.
The glass window is a cone also but it has been rotated by 180 degrees about the z axis to
turn it upside down. The z axis points toward the viewer, and all angles are given in radians.
The color has been made white and the material is partially transparent.