/*
This JScript example illustrates how to use the GetKeyValue() method
to quickly look up a key's 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()
// Create a custom property set on the null
var cpset = nullobj.AddCustomProperty( "CustomPSet" );
var empty;
var x = cpset.AddParameter( "X", siDouble, empty, siAnimatable, "X", "X", empty, 5, 0, 5 );
var y = cpset.AddParameter( "Y", siInt4, empty, siAnimatable, "Y", "Y", empty, 5, 0, 5 );
var z = cpset.AddParameter( "Z", siBool, empty, siAnimatable, "Z", "Z", empty, true );
var fc1 = x.AddFCurve();
var fc2 = y.AddFCurve();
var fc3 = z.AddFCurve();
// Use the Resample method to add keys to the fcurve on every second frame
fc1.NoKeyValue = Math.random() * 100;
fc2.NoKeyValue = Math.random() * 100;
fc3.NoKeyValue = true;
fc1.Resample( empty, empty, 2 );
fc2.Resample( empty, empty, 2 );
fc3.Resample( empty, empty, 2 );
printfc( fc1 );
printfc( fc2 );
printfc( fc3 );
// Print out all key frame/value pairs
function printfc(fc)
{
var index;
for ( index=0; index<fc.GetNumKeys(); index++ )
{
LogMessage( "key" + index + " frame = "
+ Math.round(fc.getkeyframe(index))
+ " value = " + fc.getkeyvalue(index)
);
}
}
// Outputs:
//INFO : key0 frame = 1 value = 24.42401859658091
//INFO : key1 frame = 3 value = 24.42401859658091
//INFO : key2 frame = 5 value = 24.42401859658091
// etc...
//INFO : key48 frame = 97 value = 1
//INFO : key49 frame = 99 value = 1
//INFO : key50 frame = 100 value = 1 |