TAPESTRY: The Art of Representation and Abstraction
The Web: VRML
What's it all About?
VRML is a cross-platform, application-independent file format. Many applications can be sued to create models and save them to the VRML format, but there is no definitive VRML application that provides access to all VRML features. Thus, no matter where your data starts, it makes some sense to learn about the "native" VRML representation so that you can make minor fixes or modifications directly to the VRML file.
Nodes
VRML describes the model in a series of lumps, or nodes, that look something like this:DEF WhiteBackground Background { skyColor [ 1.0 1.0 1.0, ] skyAngle [ 1.309, 1.571 ] groundColor [ 1.0 1.0 1.0, 0.9 0.9 0.9, 0.7 0.7 0.7 ] groundAngle [ 1.309, 1.571 ] }As with HTML, white space (spaces, carriage returns, tabs, etc.) aren't important. Note that the brackets and braces are balanced. All edits of the VRML file must be done such that this remains true.
Backgrounds
The "Node" example above represents a background node. The number triplets represent RGB color values on a scale of 0 to 1.0. If you wish to add a Background node to your VRML file, insert text such as that above into the VRML before the first node or between any two existing nodes.Defining and Applying Textures
The modeling application may create textures for you automatically, but you may wish to apply image textures independently of the modeling program. This is easy to do. The following two nodes create the texture using one ImageTexture node and one Appearance node per texture.DEF tex1 ImageTexture { <-- "tex1" is the name of the texture. url [ "face1.jpg" <-- The image file ] repeatS FALSE <-- Use TRUE if the pattern repeats repeatT FALSE <-- Use TRUE if the pattern repeats } DEF tex_style_1 Appearance { <-- This name will be used later. material Material { ambientIntensity 1 diffuseColor 0 0 0 shininess 1 specularColor 0 0 0 transparency 0 } texture USE tex1 <-- This name links to the ImageTexture node. }Having established the texture, you apply it to the model through the Appearance attribute of geometry nodes. Now, look down in the geometry definition for the file. Look for appearance and change the name to that of the Appearance node you created previously.
} appearance USE tex_style_1 <-- The name from the Appearance node. }
Establishing Links
formZ saves the geometry data as a series of "Transform" nodes, such as this (the Transform node shown here has been truncated):DEF object_1 Transform { children [ Shape { geometry IndexedFaceSet { coord Coordinate { point [ 2.39002 0 -2.39664 2.39002 0 2.41357 -2.41935 0 2.41357 -2.41935 0 -2.39664 ] (snip)To make this into a link analagous to the HTML link <A href="top.html" target=_blank> which opens a new window to show the document (relative URL) "top.html", replace the red text above with the text shown in red below, so that the node reads as follows:
DEF object_1 Anchor { url "top.html" parameter "target=_blank" children [ Shape { geometry IndexedFaceSet { coord Coordinate { point [ 2.39002 0 -2.39664 2.39002 0 2.41357 -2.41935 0 2.41357 -2.41935 0 -2.39664 ] (snip)
Transparency
The surface characteristics of a VRML object are defined indirectly through use of an Appearance node which is referenced in the Transform node. If you examine a VRML file you'll find references in the Transforms to appearance USE tex_style_14. Elsewhere in the file, you'll find an Appearance definition such as the following:DEF tex_style_22 Appearance { material Material { ambientIntensity 1 diffuseColor 0 0 0 shininess 1 specularColor 0 0 0 transparency .9 } texture USE tex21 }The transparency term sets the surface transparency on a scale of 0 to 1 (with 1 being fully transparent). The texture term refers to a texture definition node (and through it to an image URL).
Last updated: April, 2014