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.30 Normal

Normal { 
  exposedField MFVec3f vector  []   # (-INF,INF)
}

This node defines a set of 3D surface normal vectors to be used in the vector field of some geometry nodes (e.g., IndexedFaceSet and ElevationGrid). This node contains one multiple-valued field that contains the normal vectors. Normals shall be of unit length or results are undefined.

TIP: Use default normals whenever possible. Since normals can occupy a large amount of file size, do not specify normals if the default normals (calculated by the browser) are adequate. See "2.6.3, Geometry", for details on default normals calculations.

EXAMPLE (click to run): The following example illustrates three typical uses of the Normal node (see Figure 3-39). The first IndexedFaceSet defines a Normal node that has five normals and uses the normalIndex field to assign the correct normal to the corresponding vertex of each face. The second IndexedFaceSet defaults to using the coordIndex field to index into the Normal node. This is probably the most common use of the Normal node (i.e., one normal for each coordinate). The third IndexedFaceSet applies a Normal node to the faces of the geometry. This produces a faceted polygonal object and may render faster than when specifying normals per vertex:

#VRML V2.0 utf8
Group { children [
  Transform {
    translation -3 0 0
    children Shape {
      appearance DEF A1 Appearance {
        material Material { diffuseColor 1 1 1 }
      }
      geometry IndexedFaceSet {
        coord DEF C1 Coordinate {
          point [ 1 0 1, 1 0 -1, -1 0 -1, -1 0 1, 0 3 0 ]
        }
        coordIndex [ 0 1 4 -1  1 2 4 -1  2 3 4 -1  3 0 4 ]
        normal Normal {
          vector [ .707 0  .707, .707 0 -.707, -.707 0 -.707,
                   -.707 0  .707, .707 .707 0, 0 .707 -.707,
                   -.707 .707 0, 0 .707 .707 ]
        }
        normalIndex [ 0 1 4 -1  1 2 5 -1  2 3 6 -1  3 0 7 ]
      }
    }
  }
  Transform {
    children Shape {
      appearance USE A1
      geometry IndexedFaceSet {
        coord USE C1
        coordIndex [ 0 1 4 -1,  1 2 4 -1,  2 3 4 -1,  3 0 4 ]
        normal Normal {     # use coordIndex for normal indices
          vector [ .707 0  .707,  .707 0 -.707,
                  -.707 0 -.707, -.707 0  .707, 0 1 0 ]
        }
      }
    }
  }
  Transform {
    translation 3 0 0
    children Shape {
      appearance USE A1
      geometry IndexedFaceSet {
        coord USE C1
        coordIndex [ 0 1 4 -1,  1 2 4 -1,  2 3 4 -1,  3 0 4 ]
        normal Normal {
          vector [ .707 .707 0, 0 .707 -.707, -.707 .707 0,
                      0 .707 .707 ]
        }
        normalIndex [ 0, 1, 2, 3 ]
        normalPerVertex FALSE
      }
    }
  }
  DirectionalLight { direction 1 0 0 }
  Background { skyColor 1 1 1 }
] }

 

Normal node example

Figure 3-39: Normal Node Example