The Annotated VRML 97 Reference

1 Intro     Concepts     3 Nodes     4 Fields/Events    Conformance
A Grammar     B Java     C JavaScript     D Examples     E Related Info    References
Quick Java         Quick JavaScript         Quick Nodes   
 

  About the Book
  
Help
  Copyright © 1997-99
  Purchase the book from Amazon.com

Chapter 3:
Node Reference


Intro
Anchor
Appearance
AudioClip
Background
Billboard
Box
Collision
Color
ColorInterpolator
Cone
Coordinate
CoordinateInterpolator
Cylinder
CylinderSensor
DirectionalLight
ElevationGrid
Extrusion
Fog
FontStyle
Group
ImageTexture
IndexedFaceSet
IndexedLineSet
Inline
LOD
Material
MovieTexture
NavigationInfo
Normal
NormalInterpolator
OrientationInterpolator
PixelTexture
PlaneSensor
PointLight
PointSet
PositionInterpolator
ProximitySensor
ScalarInterpolator
Script
Shape
Sound
Sphere
SphereSensor
SpotLight
Switch
Text
TextureCoordinate
TextureTransform
TimeSensor
TouchSensor
Transform
Viewpoint
VisibilitySensor
WorldInfo

+3.3 Appearance

Appearance { 
  exposedField SFNode material          NULL
  exposedField SFNode texture           NULL
  exposedField SFNode textureTransform  NULL
}

The Appearance node specifies the visual properties of geometry by defining the Material and texture nodes. The value for each of the fields in this node can be NULL. However, if the field is non-NULL, it shall contain one node of the appropriate type.

The material field, if specified, shall contain a Material node. If the material field is NULL or unspecified, lighting is off (all lights are ignored during rendering of the object that references this Appearance) and the unlit object colour is (1, 1, 1). Details of the VRML lighting model are in "2.14 Lighting model."

The texture field, if specified, shall contain one of the various types of texture nodes (ImageTexture, MovieTexture, or PixelTexture). If the texture node is NULL or the texture field is unspecified, the object that references this Appearance is not textured.

The textureTransform field, if specified, shall contain a TextureTransform node. If the texture field is NULL or unspecified, or if the textureTransform is NULL or unspecified, the textureTransform field has no effect.

TIP: Appearance nodes should be shared whenever possible. DEF the first use of an Appearance node in the file and USE it for all subsequent Shapes with identical appearance values. This can result in memory savings and performance gains (depending on the browser implementation). If the world is large and Appearance nodes are frequently shared, it may be handy to create a separate VRML file that contains all of the Appearance nodes, each with a PROTO name (e.g., A1, A2, GOLD, Shiny_Red). In the world file that contains the Shape nodes, insert one EXTERNPROTO at the top of the file for each Appearance to be used and then use the EXTERNPROTO name in the Shape definition. For example, the following file is the Appearance library (AppearanceLibrary.wrl) defining the Appearances to be used by another VRML file:

     #VRML V2.0 utf8 
     PROTO A1[] { Appearance {...} } 
     PROTO A2[] { Appearance {...} } 
     ... 

And here's how the Appearance library would be used:

     #VRML V2.0 utf8 
     EXTERNPROTO A1 [] "AppearanceLibrary.wrl#A1" # List each one... 
     EXTERNPROTO A2 [] "AppearanceLibrary.wrl#A2" 
     ... 
     Shape { 
       appearance A1 { } 
       ... 
     }

Note that this scheme can be used for a variety of different node types (e.g., Material).


EXAMPLE (click to run): The following example illustrates typical use of the Appearance node (see Figure 3-1):

#VRML V2.0 utf8 
Shape { 
  appearance Appearance { 
    material Material { 
      specularColor 1 1 1 
      shininess 0.2 
    } 
    texture ImageTexture { url "marble.gif" } 
  } 
  geometry Sphere { radius 1.3 } 
} 
Shape { 
  appearance Appearance { 
    material Material { diffuseColor 0.9 0.9 0.9 } 
  } 
  geometry Box {} 
} 
Background { skyColor 1 1 1 } 

Appearance node example

Figure 3-1: Appearance Node Example