|
|
Key Concepts
In addition to ending with .wrl, your VRML files will have to tell the browser what kind of content it has in it. Like any Perl script you may run across, VRML has its own type of pound bang line:
#VRML V2.0 utf8
And so the interpretation begins, with these three things:
- The browser finds out that it's been requested to display a file with VRML code in it.
- That code inside the file is VRML 2.0.
- It uses the UTF-8 character set. This means that the file can be written in English, along with other international languages.
Past the header you'll find the main code of your file. VRML is organized into objects called nodes, which have their own fields and attributes. These nodes can also go inside of fields of other nodes, and so on. Most of these nodes represent something you can actually see in your browser, but others, like the ColorInterpolator node for example, have no immediate visual effect themselves but can control other nodes.
If you're a native to HTML, you'll find that these nodes have a remarkable similarity to tags. Some tags manipulate text directly, while others may center the entire document, controlling the output of other tags. Java and C++ natives would connect with the object-oriented base of those languages, where the nodes are objects with methods, attributes, and fields.
Take a look at this Shape node:
Shape {
appearance Appearance {
material Material {
diffuseColor 0.6 0.4 0.0
}
}
geometry Text {
string "Microgoodies"
}
}
Now let's break it down:
- You can see where the
Shape node begins with "Shape" and the opening bracket ("{") afterwards. All nodes, minus a few exceptions, have this basic structure.
- It may get tricky when you run into the first field,
appearance. This is one of those times where a node, in this case the Appearance node, can be inserted as a field value for another node. You'll find that fields have a lowercase first letter, while nodes will have an uppercase first letter.
- The second field,
geometry, also takes a node as its value.
- Finally, the
Shape node is ended with the closing curly bracket ("}").
The resulting world contains the brown text string "Microgoodies."
Next: Intro to the tutorials
|