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
|