FCurve.Smooth

Introduced

v5.1

Description

Smooths the FCurve in the given time span using the specified filter. 'Smoothing' removes sharp spikes and jags from the FCurve by averaging between keys. The FCurve is smoothed first and re-sampled at a sampling step of in_dSamplingStep.

Note: If the FCurve is locked or if any keys in the interval are locked then the method raises an 'Access Denied' (E_ACCESSDENIED) error.

C# Syntax

FCurve.Smooth( Object in_StartFrame, Object in_EndFrame, Double in_dFilterSize, Double in_dSamplingStep, siFCurveSmoothFilterType in_filterType, Double in_dGaussianVariance );

Scripting Syntax

FCurve.Smooth( [StartFrame], [EndFrame], [FilterSize], [SamplingStep], [FilterType], [GaussianVariance] );

Parameters

Parameter Type Description
StartFrame Variant The start time of the range to smooth. Must be less than the EndFrame value.

Default Value: The first key frame on the fcurve or, if there are no keys, the PlayControl.In frame value.

EndFrame Variant The time in frames at which to end smoothing.

Default Value: The last key frame or, if there are no keys, the PlayControl.Out frame value.

FilterSize Double Defines the number of keys that are averaged to calculate a new key. A high filter size will yield a much straighter curve. The value must be greater than 1.

Default Value: 5

SamplingStep Double The sampling step applied to the FCurve after smoothing. Must be less than FilterSize.

Default Value: 1

FilterType siFCurveSmoothFilterType Specifies the type of filter we want to use for smoothing.

Default Value: siFCurveAverageFilterType

GaussianVariance Double Variance of the Gaussian filter. Controls the degree of smoothing. A higher variance smooths the function curve more. The value must be greater than 0.

Default Value: 1

Examples

JScript Example

/*
	This example illustrates how to use FCurve.Smooth method
*/
// Create a null
NewScene("", false);
var nullobj = Application.ActiveSceneRoot.AddNull();
// Use the Resample method to add keys to empty fcurves
nullobj.posx.AddFCurve().Resample( 1,50, 5 );
nullobj.posy.AddFCurve().Resample( 1,50, 5 );
var posxFC = nullobj.posx.Source;
var posyFC = nullobj.posy.Source;
Application.LogMessage( "posx curve : " + posxFC.GetNumKeys() );
Application.LogMessage( "posy curve : " + posyFC.GetNumKeys() );
// Smooth the posx curve
posxFC.Smooth(1,50);
Application.LogMessage( "smoothed posx curve : " + posxFC.GetNumKeys() );
Application.LogMessage( "posy curve : " + posyFC.GetNumKeys() );
// Outputs:
//INFO : posx curve : 11
//INFO : posy curve : 11
//INFO : smoothed posx curve : 50
//INFO : posy curve : 11

See Also

FCurve.Resample FCurve.Fit