TIP:
One nonobvious use for a ScalarInterpolator is to modify the fraction_changed
values of a TimeSensor before they are sent to another interpolator.
Normally the fraction_changed events will range from 0
to 1 in a linear ramp, but a ScalarInterpolator can be used to
modify them in interesting ways. For example, you can map the
normal 0 to 1 "sawtooth" ramp of a TimeSensor into a 0 to 1 to
0 "triangle" ramp by doing this:
DEF TS TimeSensor { }
DEF SI ScalarInterpolator {
key [ 0, 0.5, 1 ]
keyValue [ 0, 1, 0 ]
}
DEF PI PositionInterpolator { ... }
ROUTE TS.fraction_changed TO SI.set_fraction
ROUTE SI.value_changed TO PI.set_fraction
Generating
events that run from 1 to 0 instead of 0 to 1 is just as easy.
Simply use keys of [ 0, 1 ] and keyValues of [ 1,
0 ]. Ease-in and ease-out effects (where objects move slowly when
starting, speed up, then slow down to stop) are also easy to approximate
using appropriate keyframes.
|