VRML : Data Types

There are a range of differant data types used in the VRML language. They can be split into 2 general groups: single value types and multiple value types.


Single Value Data Types

Bool
Contains a single boolean value. FALSE is represented by the number 0, and TRUE by the value 1.
Example: on TRUE - the light is on.
Colour
Contains three floating point numbers in the range 0.0 to 1.0 inclusive. It represents the amount of Red, Green, and Blue component in a colour. The greater the value, the more of that component there will be.
Example: diffuseColor 1 0 0 - a pure red is used.
Enumerated
Contains an enumerated data type. For the available values, see the appropriate object (node).
Example: justification LEFT - set's text justification to the left hand edge.
Float
Contains a single floating point number, which can be writen in standard scientific notation.
Example: height 4.7 - set's a cube's height to 4.7 units.
Long
Contains a single long (32-bit) integer. It can either be writen in decimal form, hexadecimal form, or octal form. Hexidecimal numbers have a '0x' prefix (e.g. 0x1F8), and octal numbers have a '0' prefix (e.g. 0376). Decimal form requires no prefix (but shouldn't have leading 0's).
Example: coordindex 0x7B - uses' the 7Bth (=123) point from the indexed set.
Rotation
Defines a rotation around the point (0,0,0) (which can be changed using a 'Translation'). It is formed by 4 floating point numbers: the first 3 define the axis around which the rotation takes place, and the final value set's the angle (in radians).
Example: rotation 1 0 0 1.5708 - a rotation of .5 radians or 90 degrees about the x axis.
String
Contains a string made up of ASCII characters. The string should be enclosed in double qoutes, and can contain any ASCII characters, even whitespace and newlines. The double quota character can be included by using \".
Example: string "Chemistry is Great!" - (well, I think it's great).
Vector3D
Represents a 3-dimensional vector. You should note that in the full VRML V1.0 specification there is one node which uses a 2D vector, but this is not covered in this introduction.
Example: direction 0 0 -1 - sets the light so that it comes from z = (+)infinity.


Multiple Value Data Types
Multiple Value data types do not always need to contain multiple values. However, if more than one value is used then all the values must be contained in square brackets [].

MColour
Contains a number of RGB colours. This data type is writen as a set of Colour data types, separated by commas.
Example: ambientColor [1 0 0, 0 1 0, 0 0 1, 1 1 1] - defines the colours red, green. blue, and white.
MFoat
Contains a number of floating point numbers. This data type is writen as a set of Float data types, separated by commas.
Example: shininess [0.4, 0.2, 0.6] - defines the shininess of three materials
MLong
Contains a number of long integer numbers. This data type is writen as a set of Long data types, separated by commas.
Example: coordIndex [0, 1, 2, 3, -1] - uses the coresponding points as defined below to produce as shape.
MVector3D
Contains a number of 3D-vectors. This data type is writen as a set of Vector3D data types, separated by commas.
Example: point [0 0 0, 1 0 0, 1 1 0, 0 1 0] - sets up four points for use in the "MLong" example.

Next Topic (Shapes)
Previous Topic (The Basics)
Back to the VRML Reference
Back to the Main Page

©Tom Thurston, 1997
Please feel free to use and redistribute this NONcommercially!