Modifying Action Clips with Clip Effects

 
 
 

When an action clip contains animation data from a function curve, you can modify its data in the clip effect's expression. When you do this, you create a clip effect which lets you use a number of variables and functions to modify the data "on top" of the original action source animation.

You may need to edit its animation for a number of reasons:

Moving a key point (in red) results in a peak in the curve.

Clip effects let you change the animation in an individual clip without affecting the action source (thus affecting all clips instantiated from that source) or having to re-create the action source. They do this by adding values to only that clip, such as noise, offsets, and other higher-level operations.

This means you can tweak the individual animation "channels" to change the nature of the motion, using the original source as a base. For example, you can add animation to motion capture curves without having to edit them.

NoteClip effects can be scripted, which allows you to build up very complex behaviors.

How Clip Effects Are Represented

Each clip effect is an independent object, associated with its action clip or a compound clip. It is represented in the animation mixer as a yellow bar above the action clip itself. Because the effect is an independent unit, you can easily activate or deactivate it, allowing you to toggle between the clip's original animation and the animation resulting from the clip effect. This makes it easy to test out changes to your animation.

Levels of Clip Effects

You can apply clip effects to each item (parameter) within a clip, to a whole clip itself (all parameters), or to a compound clip for an overall effect on the multiple clips within the compound.

While you can't apply more than one clip effect on the same clip, you can have the "results" of multiple clip effects by creating a compound clip and applying a clip effect to it. With compound clips, you can have complex effects by nesting them in layers.

For example, you have clips effects on individual clips, then place all these clips into a compound clip and apply a clip effect to the compound clip (such as to add noise, warps, or random values). For a simple example of this, see Example: Creating a Nested Clip Effect.

After you've created a clip effect, the results are calculated in the animation mixer. If multiple effects are applied to a clip, they are calculated in sequence from first applied to last.

Creating a Clip Effect

The basic way of using clip effects is to associate a clip effect expression with each of the items (parameters) within the action clip. In other words, you create a clip effect that has as many entries as the action clip has items.

Each item's clip effect expression references the associated sources within the action clip and then modifies them or overrides them in a variety of ways. For example, if you added this+3 as a clip effect expression for the foot's X position, the action clip supplies a value to the mixer. It first looks at the source of animation to obtain a result and then adds the value 3 to it.

The clip effect expressions can be blank (the default), in which case the animation is taken "as is" from the action. You can also build up arithmetic functions using a number of special effect variables (see Creating Effect Variables).

To create a clip effect

  1. Right-click the clip and choose Clip Properties.

  2. In the Instanced Action property editor, click the Clip Item Information tab.

  3. Enter a formula in the Clip Effect column. You can use the variables and math operators as listed in Variables and Supported Operators and Functions.

    • You can copy and paste formulas in the Clip Effect column using the standard Cut, Copy, and Paste shortcuts: Ctrl+X, Ctrl+C, and Ctrl+V, respectively.

    • Select items by clicking their Item# (Shift+click or Ctrl+click to multi-select items, or click the Clip column to select all items), then click the Clear Fx button to clear the expression written for the selected items' Clip Effect column.

  4. You can also define your own custom variables to be referenced in the expression (see Creating Effect Variables).

    You can refer to that variable in any of the clip effect expressions by referring to it by name. For example, if your effect variable is called "Banana", then you can refer to it with this+Banana in an expression. Any of the variables can be combined in the same clip effect expression; for example: this+45*param+(Banana/weight)+gtime

    TipIf you create a custom variable using a custom parameter on a clip, the custom parameter appears on the Clip Effect page instead of in a custom parameter set, making it easy for you to use. See Creating Effect Variables with Custom Parameters for more information.

    The clip effect is created and represented above the clip as a yellow bar.

    To see where the clip effects live, open an explorer and look deep down in the model's Mixer Tracks Animation Mixer_Anim_Track n Clip list Clip name Instanced Action Clip Effect Items folder.

    To open the clip's path quickly, select the clip in the mixer and then press E in the explorer. This way, only the clip and its nodes appear in the explorer.

    In the explorer, make sure to choose Show Animated or Animatable Parameters to see these parameters.

Example: Creating a Nested Clip Effect

This example shows you how to add an offset to an action clip, then create a compound clip and add a custom variable to it for an overall jitter effect.

  1. Create a simple 2D chain that represents a leg. Duplicate it and translate it so that you have two legs beside each other.

  2. On one leg, select the effector and set a few keyframes of the leg moving up and then down.

  3. Store an action for this animation by choosing Actions Store Transformation - Fcurves.

  4. Open the animation mixer and load the action you just created.

    Offset the leg

  5. Right-click the action clip and choose Clip Properties. In the Instanced Action property editor, click the Clip Item Information tab.

  6. In the Clip Effect column, set a slightly different offset for each parameter.

    In the mixer, a yellow bar appears above the clip, representing the clip effect.

  7. Repeat steps 2 to 6 for the other leg.

    Create a compound clip

  8. Select the action clips and choose Clip Create Compound. This lets you combine a number of clips within a compound so that you can apply an overall effect to both clips.

    Create a custom parameter called "jitter"

  9. Select the compound clip and create a custom parameter called jitter (choose Create Parameter New Custom Parameter). Change the Maximum value to 10 and click OK.

    For information on creating custom parameters, see About Custom and Proxy Parameters [Customization].

  10. Right-click the compound clip and choose Clip Properties. The jitter custom parameter appears as a Variable on the Instanced Action > Clip Effect page.

    Link a randomize expression to the custom parameter

  11. Right-click the jitter custom parameter's animation icon and choose Expression Editor. In the expression editor, add a random function and give it any values you like. The expression could look something like this:

    For information on writing expressions, see Animating with Expressions [Animation].

    Use the jitter as a custom variable

  12. For each of the clips, open their Clip Item Information pages. In the Clip Effect column, reference the custom parameter (variable) you created by entering this+jitter for each clip effect item (use Ctrl+C and Ctrl+V to copy and paste).

    When you play back the animation, you'll see how there's an overall shakiness on the leg. The expression on the jitter slider is controlling the amount of jitter applied to the animation.

Clip Effect Expressions

Clip effect expressions let you define the clip effect on a per-clip item basis.

To add a clip effect expression

  • Enter expressions in the Clip Effect column using the variables, operators, and functions listed in this section.

To clear the expressions for an item

  1. Select items by clicking their Item number (Shift+click or Ctrl+click to multi-select items, or click the Clip column to select all items).

  2. Click the Clear Fx button to clear the expression written for the selected items' Clip Effect column.

    Note
    • You cannot save a preset. However, you can copy and paste clip effect expressions using the standard Copy and Paste shortcuts: Ctrl+C and Ctrl+V, respectively.

    • You can also use scripting commands to read and write clip effect items. Use clipname.actionclip as the value of the MappingTemplate parameter with the GetNumMappingRules(), GetMappingRule(), and SetMappingRule() commands. See the online Command and Object Model Reference for more information.

Variables

When writing clip effect expressions, there are several special variables you can use:

Variable

Meaning

this

The item's original parameter value. This lets you create offsets from the original value rather than use a new value entirely.

cid

The cycle ID number. If you have cycled or bounced an action clip in the animation mixer, the original clip has a cid of 0, the first cycle has a cid of 1, and so on. This lets you continuously increment or decrement a value based on the cycle; for example, so that a car moves forward with every wheel rotation. See Using Cycles in Clip Effects.

time

The current local time of the clip's source, in seconds. If you cycle or bounce the clip, the values in the first cycle are repeated in the second, and so on.

frame

The current local frame of the clip's source. Again, if you cycle or bounce the clip, the values are repeated. Note that this is always an integer, even if the clip has been scaled and offset.

gtime

The current global time of the scene.

gframe

The current global frame of the scene.

weight

The current mix weight value of the clip.

custom parameter name

If you have created a custom parameter on the clip, you can access its value by using its name in the clip effect expression for any item.

See Creating Effect Variables with Custom Parameters.

param

The item's effect variable at evaluation time.

See Creating Effect Variables.

iwarp

The item's effect variable as a warp for using the original value. See Using Warps in Clip Effects.

warp

If you have created a custom parameter on the clip called "warp", using this name in the clip effect expression of any item causes the source item to be taken at a time dictated by the warp parameter.

See Using Warps in Clip Effects.

Examples

Expression

Result

5

The corresponding parameter value is always 5, no matter what animation is contained in the action.

this + 5

5 is added to the parameter value of the action at the current frame.

(cid * 10) + this

The parameter value of the action is used for the duration of the original clip, then 10 is added for the first cycle, 20 is added for the second cycle, and so on.

Supported Operators and Functions

The expressions in clip effects do not use exactly the same syntax as expressions in the expression editor. In clip effect expressions, you can use any operator or function supported by VBScript. The following tables list the most useful operators and functions.

Operator

Description

+

Addition

-

Subtraction

*

Multiplication

/

Division

^

Exponentiation

\

Integer division

Mod

Remainder

And

Logical conjunction

Imp

Logical implication

Not

Logical negation

Or

Logical disjunction

Xor

Logical exclusion

Function

Description

Abs()

Absolute value

Cos()

Cosine

Fix(), Int()

Integer portion of a number

Log()

Natural logarithm

Rnd()

Random number

Sgn()

The sign of a number: –1, 0, or 1

Sin()

Sine

Sqr()

Square root

Tan()

Tangent

The clip effect expressions use VBScript as a basic evaluation engine for non-trivial expressions, and in the simple cases, a private custom parser and evaluation engine is used.

For more information, see the Microsoft VBScript language documentation at http://msdn.microsoft.com/scripting/vbscript/doc/vbstoc.htm

Creating Effect Variables

An effect variable is a parameter that is associated with the clip effect. You can animate it independently in the time space of the clip and it can be referred to in the clip effect expression of a clip's items.

In other words, you can greatly modify the values within the action clip itself by using other parameters to change the value being supplied to the mixer without needing to alter the sources themselves.

There are two types of effect variables:

  • Per effect — These are variables for the entire clip effect. You can create and remove them dynamically at any time, so you can have as many or as few as you need. These variables can be referenced by any of the items within an action.

  • Per item — These are created automatically for each animation item that is present in the original clip. For every item within the clip, a custom variable is created within the associated effect and this variable can be referenced only in the clip effect expression for that item.

When you animate the effect variables (per-item or per-effect variables), you do so in local clip time. When the timing on the animation clip changes, any animation driving the effect variables also moves and updates with the state of the clip itself, so everything stays synchronized.

If you use an expression to drive an effect variable, and if that expression reads from objects in the scene, then those items are used in global scene time. If you tie together variables in the same effect, however, then one will use the other in the correct, clip local time.

Creating Effect Variables with Custom Parameters

You can create effect variables using custom or proxy parameters that can connect to expressions, linked parameters, or scripts (see About Custom and Proxy Parameters).

You can access a custom parameter directly by name inside each item's clip effect expression, allowing you to connect any animation source you please to the item's parameter. For example, you can add per-item noise by creating a noise expression on a custom parameter and then using its parameter name in the clip effect expression for a clip's item.

You can also use custom parameters that you create on the clip itself. If you select a clip and create a custom parameter for it, the custom parameter appears on the Clip Effect page instead of in a custom parameter set, making it easily accessible. See Example: Creating a Nested Clip Effect for an example of this.

You can then reference the values of those variables in each item's clip effect expression by using the word param to mean the parameter associated with that item and the custom parameter name itself to reference it. For example, you can connect a standard expression that generates noise to a custom parameter you create on the clip. You then reference that noise parameter inside an item on the clip by entering this + noise (the name of the custom parameter). Similarly, you could connect a scripted operator to the item's parameter, then reference it using this + param * 10+3/2 (for example). You can even override the channel of animation completely by just using the param variable or the name of the clip's parameter, and in this way, replace the contents of a clip at runtime.

Using Warps in Clip Effects

A special use of the effect variables allows a weight control on a clip with extrapolation using either the warp or iwarp variable. This lets you create a timewarp for any of all items within a clip.

The warp variable allows you to define a custom parameter for the clip (called "warp") and refer to it in the clip effect expression strings for any item in the clip. The advantages are that:

  • You can connect any sort of animation source to the warp parameter (since it's a normal parameter).

  • You can view the source in a standard animation editor.

  • You can write scripts referring to the parameter.

  • You can decide if you want the warp repeated over cycles or not (that is, the warp can occur every cycle or encompass all cycles in an extrapolation).

In the basic use, you enter warp as the string for all the clip effect strings (you can script this too), then attach your own curve to a custom parameter called warp, and you're done.

With the iwarp variable, you can have a distinct per-animation item (such as per fcurve source in the action clip) warp effect by treating the per-item parameter as a warp, attaching a curve (or whatever), and using the string iwarp in the effect.

To do this, rather than using the this variable in the clip effect expression, you use the iwarp variable. What this means is that you use the value source(Parameter(t)); that is, the clip item's effect variable is used as a timewarp lookup to the source itself.

For information on timewarps in general, see Changing Time Relationships (Timewarps).

Using Cycles in Clip Effects

The cid variable in a clip effect expression is the cycle ID number. The cycle ID can be used in an expression to progressively offset a parameter in an action, such as for having a walk cycle with a progressive offset. You can find the Cycle ID of the current frame on the General page in the Time Control property editor (click the clip and press Ctrl+T). This information is read-only and cannot be modified.

If you have cycled or bounced an action clip in the animation mixer, the original clip has a Cycle ID of 0, the first cycle has a Cycle ID of 1, and so on. If the clip is set to extrapolate before with a cycle or bounce, the cycle immediately before the original clip has an ID of -1, etc. This lets you continuously increment or decrement a value based on the cycle; for example, so that a car moves forward with every wheel rotation.

For example, with a clip effect expression like:

(cid * 10) + this

The parameter value of the action is used for the duration of the original clip, then 10 is added for the first cycle, 20 is added for the second cycle, and so on.

For information on cycles in general, see Cycling, Bouncing, and Holding Clips (Extrapolation).

Repeating a Clip Effect When Cycling or Bouncing

When you create a clip effect, you can force it to repeat with each extrapolation (each cycle or bounce) or have it span the entire extrapolation. For example, you can do a walk cycle and then use the offset effect to move the hand. You can then apply the hand movement to each cycle instance or have it span the entire walk cycle.

  1. Select the clip with a clip effect.

  2. Right-click the action clip and choose Clip Properties.

  3. In the Instanced Action property editor, select one of the Time Reference options on the Clip Effect page:

    • If you select the Original Clip option, the clip effect repeats for each instance of the extrapolation (for each cycle or bounce).

    • If you select the Extrapolated Clip option, the clip effect spans the entire extrapolation.

  4. Cycle or bounce the clip by dragging one of its corners. For more information on extrapolation, see Cycling, Bouncing, and Holding Clips (Extrapolation).

Activating or Deactivating Clip Effects

Do one of the following:

  • Right-click the clip and choose Toggle Effect Activeness.

    or

  • Right-click the clip and choose Clip Properties. On the Clip Effect page, toggle the Active option.

    TipTo activate or deactivate clip animation items, see Muting (Deactivating) Parts or All of an Action Clip. When an animation item is off, the clip no longer drives the corresponding parameter.

Deleting a Clip Effect

Do one of the following:

  • Right-click the clip's yellow effect bar or a pose offset's aqua bar and choose Remove Effect.

    or

  • Select the clip and choose Effect Remove Effect on the animation mixer command bar. This removes the animation on all parameter curves and clears the clip effect expression information for all clip, offset, and pose offset effects.