Interface

InterpolatorInterpolator {
  eventIn  SFFloat set_fraction
  eventIn  MFFloat set_key
  field    MFFloat key           []
  eventOut MFFloat key_changed
  eventOut SFFloat value_changed
}

Description

The dolphin is now spastic.
InterpolatorInterpolator Preview

The InterpolatorInterpolator isn't quite as ridiculous as its name implies, but it will take some explaining. The idea is to allow you to easily repeat an animation at variable rates using a single TimeSensor. A more accurate name would probably be “IntervalInterpolator”, but “InterpolatorInterpolator” just rolls off the tongue.

Unlike the conventional interpolator nodes, InterpolatorInterpolator has a key field, but no keyValue field. It doesn't need one because the values sent are implied by the key field.

The key field expresses a series of intervals, which become subintervals of the interval as received by the set_fraction eventIn. For example, key [ 0, 1 ] doesn't do anything interesting, since it doesn't subdivide the interval. key [ 0, 0.5, 1 ] creates two subdivisions to the interval, which will cause the InterpolatorInterpolator to send fraction_changed events corresponding to two intervals for each interval it receives via set_fraction. What that means is that over the same time period the received interval elapses, the InterpolatorInterpolator will send events corresponding to two intervals: the animation will play twice in the same time period. Since the interval has been evenly divided in this case, the two animations will play at exactly the same speed. But that doesn't have to be the case. Consider the following example.

DEF DOLPHIN Dolphin {}

DEF II InterpolatorInterpolator {
    key [ 0 0.25 1 ]
}

DEF TIME TimeSensor {
    cycleInterval 5
    loop TRUE
}

ROUTE TIME.fraction_changed TO II.set_fraction
ROUTE II.value_changed TO DOLPHIN.set_fraction

This is the interesting fragment from the VRML file that's used in the sample with the spastic dolphin. Note that the dolphin flips its tail once quickly, and once slowly. The quick movement corresponds to the first sub-interval expressed, from 0 to 0.25. Since, in the TimeSensor I've specified that the primary interval will take 5 seconds, the quick movement occurs in 1.25 seconds. The slow movement corresponds to the subinterval from 0.25 to 1, and it takes the remaining 3.75 seconds.

The InterpolatorInterpolator is not limited to two intervals—you should be able to use as many as you like. I've found this PROTO useful for synchronizing animations and compactly expressing similar (but not identical) animations without using lots of TimeSensors.

Download