5.51. Schedule (element)

<schedule> ‐ A schedule for defining time-dependent animations

5.51.1. Attributes

NameTypeDefaults
beginFLOAT0.0
durFLOAT10.0
coefFLOATNone (dynamically updated)
repeatCountFLOAT100.0
repeatDurFLOAT1000.0
modeSTRINGsinus-periodic
param_sinus_polynomFLOAT1.0
beforeSTRINGshow
fillSTRINGfreeze
iniINTEGER1
endINTEGERsize − 1
isCompletionScriptEnabledBOOLEANtrue
isUpdateScriptEnabledBOOLEANtrue

5.51.2. Description

This element defines a function of time that varies between 0 and 1. It is used to control animated transformations circle transformation, ellipse transformation, spiral transformation, or path transformation), sprite, interpolators, or crowd agents life.

The float attribute begin defines the time at which the schedule is activated, and dur defines its period. The number of cycles is controlled by one of the two mutually exclusive attributes: repeatCount that defines the number of cycles, or repeatDur, that defines the total duration (repeatCount×dur).

The string attribute mode selects the function of time that is used to compute the interpolator coefficient α in [0..1] as a function of time t. In the table below, we define the values of the functions in their first period, the time interval [begin,begin+dur]. If the schedule has more than one cycle, the value of t must be translated to the interval of the first period for computing the value of α. The value of the function for tbegin is 0. The value of the function for tbegin+dur is defined by the fill attribute as indicated below. Figure 5-18 shows the graph of the schedule functions on the interval [begin,begin+dur].

The float value of the coef attribute belongs to [0..1] and refers to the current output α of the schedule function (see Figure 5-18 for examples of α(t) functions). Reading the value of the coef attribute informs about the current output value of the schedule. Setting the value of the coef attribute can be used to take the control on the effect of a schedule function such as the course of an interpolation or a curve-based transformation, the life of agents in a crowd...

The float attribute param_sinus_polynom defines the exponent of the polynom if the mode attribute is equal to polynomial. If this attribute is equal to sinus or sinus-periodic, the param_sinus_polynom attribute can only have three values: 1, 2, or 3. The value 1 does not modify the function; the values 2 and 3 correspond to the composition of the schedule function with itself one or two times.

StringFunctionFormula
linearLinear functionα(t) = (t-begin)/dur
linear-periodicPeriodical linear functionα(t) = min(2×(t-begin)/dur), 2-2×(t-begin)/dur))
sinusSinusoidal functionα(t) = 0.5(cos(((t-begin)×Π/dur) - Π) + 1)
sinus-periodicPeriodic sinusoidal functionα(t) = 0.5(cos(((t-begin)×2Π/dur) - Π) + 1)
polynomialPolynomial functionα(t) = ((t-begin)/dur)n
linear-randomLinear functionSame function as linear, but with random weights for the vertices of the interpolator.
sinus-randomSinusoidal functionSame function as sinus, but with random weights for the vertices of the interpolator.

Figure 5-18. Schedule Functions

The string attribute before defines the effect of the schedule function for tbegin. If the attribute is equal to hide, the objects associated with the path or interpolator to which schedule applies are hidden. They are shown in their initial state if this attribute is equal to show.

The string attribute fill defines the effect and the value of the schedule function for tbegin+dur. If the attribute is equal to hide, the objects associated with the path or interpolator to which the schedule applies are hidden. If the attribute is equal to remove, the schedule function is equal to its initial value α(begin). If the attribute is equal to freeze, the schedule function is equal to its final value α(begin+dur).

The integer attributes ini and end define the scope of the schedule function with respect to the path or interpolator to which it applies. Let size be the number of curves in the path or the number of edges of the interpolation polygon (see Figure 2-4). Let ini and end be the values of the ini and end attributes. The schedule controls the transformation or the interpolator for its sub-part made of the curves or edges from rank ini to rank end.

Schedules can have two associated scripts: a completion script that is executed when the schedule reaches its end time and an update script that can be executed at each update between the begin and end times of the schedule. The execution of the update script is controlled by the value ifv of the attribute interpolation_refreshing_variation of the element UDP Server defined in the configuration file. The value ifv is the threshold of the variation of the interpolator value (a float value between 0 and 1) under which the update script is not executed. The boolean attributes isCompletionScriptEnabled and isUpdateScriptEnabled are used to enable or disable the completion and update scripts (completionScript and updateScript) that are attached to schedulers.

5.51.3. Expected child

The following elements can occur in schedules: a completionScript and an updateScript.

5.51.4. Example

The example below is a scheduler that begins at 0 and terminates at 50+20=70. The first schedule function is a second-degree polynom that controls the interpolation of the first three transformations between time 0 and 50. Before time 0, the interpolated node is hidden. The second schedule function is a sinusoidal function that controls the interpolation from transformation #3 to transformation #4 between time 50 and 70. After time 70, the interpolator returns to its initial state, and displays transformation #1.

<interpolator id="interpolator_agent" type="node" size="4">
  <schedule begin="0" dur="10" repeatCount="5" mode="polynomial"
    param_sinus_polynom="2.0" before="hide" fill="freeze" ini="1" end="3"/>
  <schedule begin="50" dur="20" repeatCount="1" mode="sinus"
    fill="remove" ini="3" end="4">
    <completionScript>
      <command>
        <action>
          <send_message value="start scale" /> 
          <target type="single_node" value="#moving cylinder #{#p}" />
        </action>
        <action>
          <send_message_udp value="source {#r} harmonie 0.00" />
        </action>
      </command>
    </completionScript>
    <updateScript>
      <command>
        <action>
          <send_message_udp value="source {#r} harmonie" />
        </action>
      </command>
    </updateScript>
  </schedule>
  <transformation id="scale_#1" geometry="scale" x="1.0" y="1.0" z="1.0"/>
  <transformation id="scale_#2" geometry="scale" x="2.0" y="2.0" z="2.0"/>
  <transformation id="scale_#3" geometry="scale" x="5.0" y="5.0" z="5.0"/>
  <transformation id="scale_#4" geometry="scale" x="1.0" y="1.0" z="1.0"/>
</interpolator>