FCurveKey.Set

導入

v3.0

詳細

F カーブキー時間(FCurveKey.Timeを参照)および値(FCurveKey.Value)を設定します。

注:該当の新しいフレーム値に別のキーがすでに存在する場合は、'Cannot set key'(E_FAIL)エラーが発生します。

ヒント:F カーブがロックされている場合は、'Access Denied'(E_ACCESSDENIED)エラーが発生します。エラートラッピングを使用してこのエラーを取得する例については、FCurveKey.Constraintプロパティを参照してください。

スクリプト 構文

FCurveKey.Set( Frame, Value, [OverrideKeyLock] );

パラメータ

パラメータ タイプ 詳細
Frame Variant 新しいキーの時間(フレーム)
Value Variant 新しいキーの値。

標準およびロー F カーブには、Double 値(VT_R8)を使用します

整数 F カーブには、LONG (VT_I4)を使用します

ブール F カーブには、Variant Bool 値(VT_BOOL,VARIANT_TRUE,VARIANT_FALSE)を使用します。
OverrideKeyLock Boolean True の場合は、FCurveKey.Locked値を上書きして、強制的にキーを削除します。

デフォルト値: false

JScript の例

/*
        This example illustrates how to use the FCurveKey.Set method to translate keys.
*/
// Create new scene
Application.NewScene( "", false );
var empty;
var nullobj = Application.ActiveSceneRoot.AddNull();
var cpset = nullobj.AddProperty( "Custom_parameter_list", empty, "CustomPSet" );
var x = cpset.AddParameter( "X", siDouble, empty, siAnimatable, "X", "X", empty, 0.25, -100, 100 );
var y = cpset.AddParameter( "Y", siDouble, empty, siAnimatable, "Y", "Y", empty, 0.25, -100, 100 );
// Create some fcurves
var fc1 = x.AddFCurve();
var fc2 = y.AddFCurve();
// Start editing fcurve
fc1.BeginEdit();
fc2.BeginEdit();
// Add keys to the fcurves
fc1.Resample();
fc2.Resample();
// Assign some values to keys
for ( i=0; i<fc1.GetNumKeys(); i++ ) {
        var calcX = ((i+1)-10)/10;
        fc1.GetKeyAtIndex(i).Value = Math.atan(calcX / Sqr(-calcX * calcX + 1));
        // Copy the value to fc2 for comparison
        fc2.GetKeyAtIndex(i).Value = fc1.GetKeyValue(i);
}
var ckeys = fc1.GetNumKeys();
var tangents = new Array(ckeys*4);
var itan=0;
// Save tangents
for ( var i=0; i<ckeys; i++ ) {
        var fckey = fc1.GetKeyAtIndex(i);
        // Save the tangents
        tangents[itan++] = fckey.LeftTanX;
        tangents[itan++] = fckey.LeftTanY;
        tangents[itan++] = fckey.RightTanX;
        tangents[itan++] = fckey.RightTanY;
}
// Translate the keys
for ( var i=0; i<ckeys; i++ ) {
        var frame = fc1.GetKeyFrame(i);
        var val = fc1.GetKeyValue(i);
        var fckey = fc1.GetKey(frame);
        fckey .set( frame-100, val * 1.25 );
}
// Reset the tangents
fc1.SetKeyTangents(tangents);
// End editing fcurve
fc2.EndEdit();
fc1.EndEdit();
// Convenience function
function Sqr( x ) 
{
        return x * x;
}