
The acronym VRML (pronounced 'vermal") stands for "Virtual Reality Modeling Language." VRML is simply a way for making three-dimensional objects. In VRML, you can do anything you want. All of the shapes made in VRML are specified with objects inside the VRML code. These objects are called nodes. If you have done programming languages like C++ or Java, you will see how these nodes are like functions. Overall this is very easy language to learn.
Nodes are written in different levels, and sets of these are structures called scene graphs. Scene graphs are more than just a collection of nodes; it defines an ordering for the nodes. Nodes that appear earlier in the world can affect nodes that appear later inside the VRML world. A mechanism is defined to limit the effects of properties (separator nodes). A separator node tells the VRML browser to stop a certain scene graph and to start another one.
There are many different kinds of nodes and they have many characteristics about them. A node can specify the following:
The code used these pieces of information is straightforward:
DEF objectname objecttype { fields children }
|
Only the object type and curly braces are needed. They may or may not have a name, fields, and children.
Names of nodes can't start with a number, and can't contain spaces or control characters, single or double quote characters, \, {}, + character or the period character.
#VRML V1.0 ascii
This line must be at the very top of every VRML file so it is easily identified.
The pound sign ("#") starts a comment. Every thing after this is ignored. This helps you understand the code better. In the first example the comments let you see where the sphere was and where the cube was. There are exceptions with certain characters and you'll see them later.
After the required line, a VRML file contains exactly one VRML node. That one node can be a group node so other nodes can be put inside it.
VRML is case-sensitive; 'Sphere' is different from 'sphere'.
Field names start with lower case letters, Node types start with upper case. The remainder of the characters may be any printable ascii (21H-7EH) except curly braces { }, square brackets [ ], single ' or double " quotes, pound #, backslash \ \ plus +, period . or ampersand &.
VRML uses a 3-dimensional coordinate system in which the coordinates X, Y, and Z are used. The objects that are created are projected on a 2-dimensional plane (your screen) and the depth is showed by making the object smaller as the Z increases positivley. If the camera is rotated, then the output mechanism is the same.
The standard units used in VRML for distance are meters and angles are measured in radians.
There are two general classes of fields; fields that contain a single value (where a value may be a single number, a vector, or even an image), and fields that contain multiple values. Single-valued fields all have names that begin with "SF", multiple-valued fields have names that begin with "MF". Each field type defines the format for the values it writes.
Multiple-valued fields are written as a series of values separated by commas, inside a set of square brackets. If the field has zero values then only the square brackets ("[]") can be used. If the field has one value, the brackets can be left out and the number can be written without anything else. You can see below how "123" can be written in many ways.
123
[123,]
[ 123 ]
There are many other kinds of fields and as you keep going through this tutorial you will come into contact with them.