/*
This JScript example illustrates how to use the GetKeyFrame() method
to quickly look up an key's frame value.
*/
// 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()
// Use the Resample method to add keys to the fcurve on every second frame
var empty;
fc.NoKeyValue = Math.random() * 100;
fc.Resample( empty, empty, 2 );
var index, frame, value;
// Print out all key frame/value pairs
for ( index=0; index<fc.GetNumKeys(); index++ )
{
frame = Math.round( fc.GetKeyFrame( index ) );
value = fc.GetKeyValue( index );
LogMessage( "key" + index + " frame = " + frame + " value = " + value );
}
// Outputs:
//INFO : key0 frame = 1 value = 66.7755833336558
//INFO : key1 frame = 3 value = 66.7755833336558
//INFO : key2 frame = 5 value = 66.7755833336558
// ...etc.
//INFO : key48 frame = 97 value = 66.7755833336558
//INFO : key49 frame = 99 value = 66.7755833336558
//INFO : key50 frame = 100 value = 66.7755833336558
|