Interface

VcrControlSensor {
    eventIn     SFTime      set_duration
    eventIn     SFFloat     set_fraction
    eventIn     SFBool      set_loop
    eventIn     SFBool      set_play
    field       SFTime      duration            1.0   # (0, ∞)
    field       SFFloat     fraction            0.0   # [0, ∞)
    field       SFBool      loop                FALSE
    field       SFBool      play                FALSE
    eventOut    SFTime      cycleTime
    eventOut    SFTime      duration_changed
    eventOut    SFFloat     fraction_changed
    eventOut    SFBool      isActive
    eventOut    SFBool      loop_changed
    eventOut    SFBool      play_changed
    eventOut    SFTime      time
}

Description

Cute cetacean courtesy of Bob Crispen and Viewpoint Datalabs' Avalon archive. The TrackingViewpoint PROTO used in this example is the work of Tom Kaye.
VcrControlSensor Preview

The VcrControlSensor is a drop-in replacement for a TimeSensor which can be paused and resumed arbitrarily.

The duration field specifies the duration, in seconds, for the behavior the VcrControlSensor will be driving. The fraction field sets the fraction of the behavior that should have elapsed prior to playing. If loop is TRUE, the behavior will restart from the beginning and repeat after it has reached the end of its duration.

When play is TRUE, the behavior will play; when FALSE, the behavior is paused.

While play is TRUE, the VcrControlSensor will continue sending fraction_changed events. If the VcrControlSensor receives FALSE via set_play, it will suspend sending fraction_changed events. If it then subsequently receives TRUE via set_play, it will resume sending fraction_changed events wherever it left off.

If the VcrControlSensor reaches the end of its duration, and loop is set to FALSE, play will be set to FALSE.

Download