FCurve.GetNumKeys

FCurve.GetNumKeys

導入

v3.0

詳細

StartFrame と EndFrame で定義された間隔内にあるキーの数を戻します。デフォルトの間隔は f カーブ全体です。

C#構文

Int32 FCurve.GetNumKeys( Object in_StartFrame, Object in_EndFrame );

スクリプト構文

oLong = FCurve.GetNumKeys( [StartFrame], [EndFrame] );

戻り値

Long

パラメータ

パラメータ タイプ 説明
StartFrame Variant 間隔の開始時間(フレーム)

デフォルト値:最初のキーのフレーム

EndFrame Variant 間隔の終了時間(フレーム)

デフォルト値:最後のキーのフレーム

JScript の例

/*

	This JScript example illustrates how to use the FCurve.GetNumKeys method

	to determine the number of keys within a specified interval.

*/

// Create a null

Application.NewScene( null, false );

var nullobj = ActiveSceneRoot.AddNull();

// Create an fcurve on the posx parameter from the null

var fc = nullobj.posx.AddFCurve()

// Define some random keys

var nbkeys = Math.round( Math.random() * 200 );

var arraysize = nbkeys * 2;

var keys = new Array( 2 * nbkeys );

var i = 0;

var offset = -50;

for ( i=0; i<arraysize; i+=2 )

{

	keys[i] = Math.round( offset + Math.random( ) * 100 );

	keys[i+1] = offset + Math.random() * 100;

}

// Set the keys on the fcurve

fc.SetKeys( keys );

LogMessage( "total number of keys = " + fc.GetNumKeys() );

// For each 10 frames determine how many keys are in the interval

var frame, nextframe, endframe, offset;

frame = fc.GetKeyFrame(0);

endframe = fc.GetKeyFrame( fc.GetNumKeys() - 1 );

offset = 10;

while ( frame < endframe )

{

	nextframe = frame + offset;

	var ckeys = fc.GetNumKeys( frame, nextframe );

	if ( ckeys > 1 )

	{

		LogMessage( ckeys + " keys between frames " + frame + " and " + nextframe );

	}

	frame = nextframe;

}

// Output:

//INFO : total number of keys = 78

//INFO : 10 keys between frames -50 and -40

//INFO : 6 keys between frames -40 and -30

//INFO : 9 keys between frames -30 and -20

//INFO : 6 keys between frames -20 and -10

//INFO : 9 keys between frames -10 and 0

//INFO : 10 keys between frames 0 and 10

//INFO : 9 keys between frames 10 and 20

//INFO : 7 keys between frames 20 and 30

//INFO : 11 keys between frames 30 and 40

//INFO : 8 keys between frames 40 and 50

関連項目

FCurve.Keys