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.31 NormalInterpolator

NormalInterpolator { 
  eventIn      SFFloat set_fraction       # (-INF,INF)
  exposedField MFFloat key           []   # (-INF,INF)
  exposedField MFVec3f keyValue      []   # (-INF,INF)
  eventOut     MFVec3f value_changed
}

The NormalInterpolator node interpolates among a list of normal vector sets specified by the keyValue field. The output vector, value_changed, shall be a set of normalized vectors.

The number of normals in the keyValue field shall be an integer multiple of the number of keyframes in the key field. That integer multiple defines how many normals will be contained in the value_changed events.

Normal interpolation shall be performed on the surface of the unit sphere. That is, the output values for a linear interpolation from a point P on the unit sphere to a point Q also on the unit sphere shall lie along the shortest arc (on the unit sphere) connecting points P and Q. Also, equally spaced input fractions shall result in arcs of equal length. If P and Q are diagonally opposite, results are undefined.

A more detailed discussion of interpolators is provided in "2.6.8 Interpolators".

TIP: NomalInterpolator is an advanced node and is only used in fairly obscure cases. The NormalInterpolator node is needed when a CoordinateInterpolator is being used to morph coordinates and normals are not being automatically generated. If you have two shapes with the same topology (coordinate and normal indices), you can easily morph between them by using coordinate and normal interpolators driven by TimeSensors. Various effects are also possible by varying only the normals of an object, changing the shading of the object over time.

TIP: Remember that TimeSensor outputs fraction_changed events in the 0.0 to 1.0 range, and that interpolator nodes routed from TimeSensors should restrict their key field values to the 0.0 to 1.0 range to match the TimeSensor output and thus produce a full interpolation sequence.

EXAMPLE (click to run) : The following example illustrates a simple case of the NormalInterpolator node. A TouchSensor triggers the interpolation when it is clicked. The TimeSensor drives the NormalInterpolator, which in turn modifies the normals of the IndexedFaceSet, producing a rather strange effect:

#VRML V2.0 utf8
Group { children [
  DEF NI NormalInterpolator {
    key [ 0.0, 1.0 ]
    keyValue [ .707 0 .707, .707 0 -.707,
               -.707 0 -.707, -.707 0 .707, 0 1 0,
               1 0 0, 1 0 0, -1 0 0, -1 0 0, 0 1 0 ]
  }
  Shape {
    geometry IndexedFaceSet {
      coord 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 DEF N Normal {
        vector [ .707 0  .707,  .707 0 -.707,
                -.707 0 -.707, -.707 0  .707, 0 1 0 ]
      }
    }
    appearance Appearance {
      material Material { diffuseColor 1 1 1 }
    }
  }
  DEF T TouchSensor {}  # Click to start the morph
  DEF TS TimeSensor {   # Drives the interpolator
    cycleInterval 3.0   # 3 second normal morph
    loop TRUE
  }
  Background { skyColor 1 1 1 }
] }
ROUTE NI.value_changed TO N.vector
ROUTE T.touchTime TO TS.startTime
ROUTE TS.fraction_changed TO NI.set_fraction