Class SoTrackFollower

  • All Implemented Interfaces:
    SafeDisposable

    public class SoTrackFollower
    extends SoEngine
    Animates an object or camera along a track. This engine is designed to add animations to a scene graph. It manages a track that can be followed either by an object (a sub scene graph) or by a camera. The track is defined by a set of control points. Each control point can be associated with a time stamp, a turn angle, roll information, and a head rotation. Only the points field is required. All other data fields are optional.

    The input that drives the animation is the alpha field. This value should vary between 0 and 1, assuming 0 as the position and orientation at the first control point, and 1 as the position and orientation at the last control point. Alpha values are clamped to the interval [0,1]. An SoTimerSensor or other engines can be used to dynamically modify the alpha value.

    The outputs are a position field and an orientation field that can be connected directly to the corresponding fields of an SoCamera or SoTransform node (see SoField.connectFrom). The values of these fields are computed by interpolating the track points with the alpha field value.

    The rollAngle values are only used if the track specified by the points field is curved.

    An example .iv file using SoTrackFollower is provided in the directory $OIVHOME/data/models/toys/TrackSample.

    File format/default:

    TrackFollower {

      points 0 0 0
      timeStamps 0
      radius 0
      rollAngle 0
      rollSpeed 0
      keepRollAngle false
      headRotation 0 0 1 0
      alpha 0
      loop true
      useHeadRotationOnly false
    }

    See Also:
    SoInterpolate
    • Field Detail

      • points

        public final SoMFVec3f points
        Coordinates of the control points.
      • timeStamps

        public final SoMFFloat timeStamps
        Time stamps associated with the control points. A time stamp represents the time at which a control point must be reached; the "scale" of the time is independent of the animation time. However, it is proportional to it. For example, if point 1 has a time stamp value of 10, point 2 has a time stamp value of 30, and point 3 has a time stamp value of 40, it means that the interpolation will take twice as long to go from point 1 to point 2 (20 time units) as it will to go from point 2 to point 3 (10 time units). The actual time to complete an animation, and therefore the overall speed, is determined by the time it takes for the alpha value to go from 0 to 1. In other words, the overall speed is controlled by the application or another engine which is updating the alpha input.

        If a time stamp has a value of SO_UNDEFINED_TIME_STAMP (default value), then the computed time stamp is proportional to the distance between the previous and the next control point, i.e., speed is constant. If all the time stamps are set to SO_UNDEFINED_TIME_STAMP or are not set at all, they are all computed to be proportional to the distance between the points, and speed is constant over the entire track.

        If the time stamp field contains one more value than the points field, the last time stamp is assumed to apply to the first/last control point in a loop. If fewer than 3 time stamps are provided, the track is interpolated proportional to the distance between control points.

      • radius

        public final SoMFFloat radius
        Radius of the turn at a control point. If radius is zero for a control point (the default), the orientation changes immediately when the animation reachs that point. For many animations this is an unrealistic or undesirable behavior. Radius values allow the orientation to change smoothly, following a curve.

        If there are fewer radius values than control points, the value of the last radius is used for the remaining control points.

      • rollAngle

        public final SoMFFloat rollAngle
        Roll angle during the turn at a control point. The roll angle inclines the track inside the turn. If the specified roll angle is negative, the track is inclined outside the turn.

        If rollAngle is zero for a control point (the default), the animated object will rotate around a vector perpendicular to the plane defined by the preceding and following segments of the track. This is typically the desired behavior, for example, when animating a vehicle on the ground. However rollAngle allows a more realistic animation of a flying vehicle.

        If there are fewer rollAngle values than control points, the value of the last rollAngle is used for the remaining control points.

      • rollSpeed

        public final SoMFFloat rollSpeed
        Speed at which the roll angle is reached during a turn. By default, (value = 0) the roll angle varies from 0 at the beginning of the turn to the specified roll angle value in the middle of the turn and then back to 0 at the end of the turn. A value of 1 means the roll angle is immediately reached at the begining of the turn. Intermediate values vary the point at which the full roll angle is reached.

        If there are fewer rollSpeed values than control points, the value of the last rollSpeed is used for the remaining control points.

      • keepRollAngle

        public final SoMFBool keepRollAngle
        Indicates if the roll angle should be maintained after the middle of the turn. If this flag is set to true for a control point, the roll speed is assumed to be 1 in the second part of the turn for the current control point and in the first part of the turn for the next control point. This allows the roll angle to be maintained between two adjacent turns.

        If there are fewer keepRollAngle values than control points, the value of the last keepRollAngle is used for the remaining control points.

      • headRotation

        public final SoMFRotation headRotation
        The final rotation applied at a control point, which allows the camera or the object to be rotated while following the track. If there are fewer headRotation values than control points, the value of the last headRotation is used for the remaining control points.
      • alpha

        public final SoSFFloat alpha
        The value on which the interpolation is made. It must between 0.0 and 1.0.
      • loop

        public final SoSFBool loop
        If loop is true, the animation will loop. For N control points, there must be N+1 time stamps. The last time stamp is used for interpolating between the last control point and the first control point at the end of the animation loop. For example, if there are four points (P1, P2, P3, and P4), there must be five time stamps (T1,... T5) as shown below:

      • useHeadRotationOnly

        public final SoSFBool useHeadRotationOnly
        If true, the orientation output field is a direct interpolation of headRotation values, without taking into consideration the roll angle or the track itself.
      • orientation

        public final SoEngineOutput orientation
        (SoSFRotation) Rotation interpolated from the alpha value. It's a rotation from the -Z vector to the heading vector, with the initial up vector along the Y vector.
    • Constructor Detail

      • SoTrackFollower

        public SoTrackFollower()
        Constructor.