Vizard 8 » Reference » Animation » Paths » Animation path modes
8.0

Animation path modes

Animation paths have different modes which specify the nature of the interpolation between points. The scale, position, and orientation modes can all be set for the entire path or for individual control points.

 

The two interpolation modes are linear or cubic bezier. Linear interpolation is, as it sounds, a direct and uniform interpolation between the control points. The cubic bezier mode uses the tangents in and out of the control points to construct a smooth path between control points that going through each of them. The <animationpath>.computeTangents command will automatically compute tangents for the control points on a path, or you can work with individual control point tangents with the <controlpoint>.setPositionIn and <controlpoint>.setPositionOut commands.

 

You can also apply automatic rotations to a control path (<animationpath>.setAutoRotate). With automatic rotations, objects traveling along the path will stay pointed down the paths trajectory. Applying automatic rotations will override whatever rotations are specified at individual control points.

 

Animation paths also support the ability to move along the path at a constant speed. The <animationpath>.setConstantSpeed command allows enabling constant speed movement and specifying the constant velocity. When constant speed is enabled, the control point times are ignored, however they are still used to specify the ordering of the points along the path.

#Create the animation path 
path = viz.addAnimationPath()

#Initialize an array of control points
positions = [ [0,2,10], [2,0,8], [0,0,6], [-2,0,8] ]
for x,pos in enumerate(positions):
    #Add a semi-transparent ball at each control point.
    b = viz.addChild('beachball.osgb')
    b.setPosition(pos)
    b.alpha(0.2)
    #Add the control point to the animation path.
    path.addControlPoint(x+1,pos=pos)

#Set the loop mode to circular
path.setLoopMode(viz.CIRCULAR)
#Automatically compute tangent vectors for cubic bezier translations
path.computeTangents()
#Automatically rotate the path
path.setAutoRotate(viz.ON)

#Add the ball to animate
ball = viz.addChild('beachball.osgb')
#Link the ball to the path
link = viz.link(path,ball)

#Play the animation path
path.play()

#Add keystrokes to change the translation mode of the path.
vizact.onkeydown('l',path.setTranslateMode,viz.LINEAR)
vizact.onkeydown('c',path.setTranslateMode,viz.CUBIC_BEZIER)

Interpolation modes

Argument

Description

viz.LINEAR

Interpolate linearly between control points.

viz.CUBIC_BEZIER

Use cubic bezier interpolation. Cubic bezier uses the control points and their incoming and outgoing tangents to compute a smooth curve between them. This is normally only used with translations.

Interpolation modes for individual control points

Mode

Description

viz.INHERIT

Inherit the interpolation mode of the animation path. (Default)

viz.LINEAR

Interpolate linearly for this control point.

viz.CUBIC_BEZIER

Use cubic bezier interpolation. Cubic bezier uses the control points and their incoming and outgoing tangents to compute a smooth curve between them.

Loop modes

Mode

Description

viz.OFF

No looping. When the path reaches the end it will stop.

viz.LOOP

Standard looping. When the path reaches the end it will go back to the beginning.

viz.SWING

Swing loop. When the path reaches the end it will change direction and go back the other way.

viz.CIRCULAR

Circular loop. When the path reaches the end it will continue on to the first control point. In this case the control time for the first control point will be used to calculate the time between the control points.

See also

In this section:

Animation path basics

Animation path events

Animation path command table

Other sections:

Action basics

Linking basics

Physics basics

Viewpoint basics

Example scripts:

Animation paths