Reference: Animation

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 three interpolation modes are linear, bezier, and cubic bezier. Linear interpolation is, as it sounds, a direct and uniform interpolation between the control points. The bezier mode uses the first and last control points as anchors and constructs a smooth path that, although defined by the control points, will not necessarily go through all of them. 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 travelling along the path will stay pointed down the path's trajectory. Note: applying automatic rotations will override whatever rotations are specified at individual control points.

 

#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.add('ball.wrl')
    b.setPosition(pos)
    b.alpha(0.2)
    #Add the control point to the animation path.
    cp = viz.addControlPoint()
    cp.setPosition(pos)
    path.add(cp,x+1)

#Set the loop mode to circular
path.loop(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.add('ball.wrl')
#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('b',path.setTranslateMode,viz.BEZIER)
vizact.onkeydown('c',path.setTranslateMode,viz.CUBIC_BEZIER)

 

 

Interpolation modes

Argument

Description

viz.LINEAR

Interpolate linearly between control points.

viz.BEZIER

Use bezier interpolation between control points. Note: Bezier interpolation guarantees that the path will go through the first and last control point, but not the control points in between. Control times are ignored with bezier interpolation. They are only used to order the control points. To give a control point more weight, add it multiple times to the path.

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.BEZIER

Use bezier interpolation for this 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 command table

Other sections:

Action basics

Linking basics

Physics basics

Viewpoint basics

Example scripts:

Animation paths