5.42. Path Transformation (transformation)

<transformation geometry="path-transformation"> ‐ A path transformation

5.42.1. Attributes

NameTypeDefaults
idIDNone (required)
sizeINTEGERNone (required)
with_rollBOOLEANtrue
xFLOATNone (read-only)
yFLOATNone (read-only)
zFLOATNone (read-only)
yawFLOATNone (read-only)
pitchFLOATNone (read-only)
rollFLOATNone (read-only)
matrixFLOAT MATRIXNone (read-only)

5.42.2. Description

This transformation is a transformation along a path made of one or more Bezier curves. It expects two entities in its scope: a path and one or more schedules. The path is a set of Bezier curves that defines the curve along which the objects are moved. The schedule defines the time function that controls the motion of the objects along the path. More than one schedule can be defined in order to have separate time functions for different pieces of the path. If the boolean attribute with_roll is on, the transformation along the path is complemented with a rotation that leans the objects in the direction of the turns. The angle of the lean is proportional to the angular speed.

The values of the read-only attributes x, y, z represent the dynamic translation component of the curve transformation. The values of the read-only attributes yaw, pitch, roll represent the dynamic rotation component of the curve transformation. The rotation axes are aligned with the object coordinates and described in Figure 5-4. The values of the read-only attribute yaw, pitch, roll represent the dynamic rotation component of the curve transformation. The rotation axes are aligned with the object coordinates and described in Figure 5-4.

The value of the read-only attribute matrix is a 4x4 float matrix that represents the current curve transformation.

The course of a transformation path can be stopped dynamically by setting to false the updatable attribute of the current node through a set_node_attribute_value command.

5.42.3. Expected children

The following elements must occur in path transformation: schedule, path.

5.42.4. Examples

The example below shows a transformation path made of three Bezier curves. For the sake of concision, the control points of the last two curves are not reported in this example. The motion along the curves is controlled by a sinusoidal time function that begins at time 0, and repeats 100 times with a duration of 20.0. This transformation results in a repeated motion of the viewpoint viewpoint_#1 along the path. The path is green and 0.1 unit wide.

<node id="main_path">
  <transformation id="transf1" geometry="path-transformation" 
    size="3" with_roll="true">
    <schedule begin="0.00" dur="20.00" mode="sinus" fill="freeze" 
      repeatCount="100" ini="1" end="3"/>
    <path id="cam-path" size="3" width="0.1" segments="100">
      <color id="green" r="0." g="1." b="0."/>
      <bezier size="4" location="1"
          x1="5.40" y1="0.10" z1="-6.70"
          x2="5.40" y2="0.10" z2="-5.80"
          x3="5.00" y3="0.10" z3="-4.70"
          x4="4.40" y4="0.10" z4="-4.30" />
      <bezier size="4" location="2" ... />
      <bezier size="4" location="3" ... />
    </path>
  </transformation>
  <node id="viewpoint">
     <viewpoint id="viewpoint_#1" />
  </node>
</node>

The example below defines a path transformation made of three Bezier curves with three associated schedules (one for each curve). Each schedule function lasts one time unit and begins when the preceding one is finished. The completionScript is executed after three times units (when the path has been walked along entirely); it loops over the three schedule functions and increases their begin attribute by 3.0 so that the path transformation can indefinitely loop.


<node id="path_camera">
  <scalar id="g" type="int" value="1" />
  <transformation id="path_camera" geometry="path-transformation" 
                    size="3" with_roll="true">
      <schedule begin="0" dur="1" repeatCount="1" index="1" 
                   mode="linear" fill="freeze" ini="1" end="2"/>
      <schedule begin="1" dur="1" repeatCount="1" index="2" 
                   mode="linear" fill="freeze" ini="2" end="3"/>
      <schedule begin="2" dur="1" repeatCount="1" index="3" 
                   mode="linear" fill="freeze" ini="3" end="3">
      <completionScript>
        <command>
          <repeatAction begin="1" end="3" step="1" id="g">
            <action>
              <set_schedule_attribute_value index="({$path_camera:g})" 
                       operator="+=">
                <schedule begin="3" />
              </set_schedule_attribute_value>
              <target type="single_node" value="#path_camera" />
            </action>
          </repeatAction>
        </command>
      </completionScript>
    </schedule>
    <path id="path_camera" size="3" width="0.1" segments="100">
      <bezier size="4" location="1" x1="0" z1="0" y1="0" 
        x2="0" z2="0" y2="0" x3="0" z3="0" y3="0" x4="0" z4="0" y4="0" />
      <bezier size="4" location="2" x1="0" z1="0" y1="0" 
        x2="0" z2="0" y2="0" x3="0" z3="0" y3="0" x4="0" z4="0" y4="0" />
      <bezier size="4" location="3" x1="0" z1="0" y1="0" 
        x2="0" z2="0" y2="0" x3="0" z3="0" y3="0" x4="0" z4="0" y4="0" />
    </path>
  </transformation>

5.42.5. Access to Children Attributes

The attribute values of one of the schedules that define the transformation temporal function can be accessed through the sequence node:rank:attribute in which node is the graph node ID, rank is rank of the schedule prefixed with s ({s1, s2...sp}), and attribute is the attribute of the corresponding schedule.

The example below accesses the coef attribute (α value) of the first schedule for the path transformation named path_camera.

<action>
  <write_console value="({$path_camera:s1:coef})" />
</action>