//
// This example illustrates how to snap fcurve keys to their nearest frames
// Create a new scene
NewScene(null, false);
// Create a null
oNull = Application.GetPrim("Null");
// Get the posx parameter of the null
oPosX = oNull.posx
// Create array of time-value pairs
aKeys = new Array( 0.2, 5.00,
1.4, 6.00,
2.1, 7.00,
3.3, 8.00,
3.8, 9.00,
4.6, 10.00 );
// Create an empty FCurve
oFCurve = oPosX.AddFCurve2( null, siStandardFCurve );
// Set the fcurve keys
oFCurve.SetKeys( aKeys );
Application.LogMessage( 'Before SnapToNearestFrame:', siInfo );
for (var i = 0; i < oFCurve.Keys.Count; i++)
{
Application.LogMessage( 'Time: ' + oFCurve.Keys(i).Time + ', Value: ' + oFCurve.Keys(i).Value, siInfo );
}
oFCurve.SnapToNearestFrame();
Application.LogMessage( 'After SnapToNearestFrame:', siInfo );
for (var i = 0; i < oFCurve.Keys.Count; i++)
{
Application.LogMessage( 'Time: ' + oFCurve.Keys(i).Time + ', Value: ' + oFCurve.Keys(i).Value, siInfo );
}
// Produces the following output:
//
//INFO : Before SnapToNearestFrame:
//INFO : Time: 0.2, Value: 5
//INFO : Time: 1.4, Value: 6
//INFO : Time: 2.1, Value: 7
//INFO : Time: 3.3, Value: 8
//INFO : Time: 3.8, Value: 9
//INFO : Time: 4.6, Value: 10
//INFO : After SnapToNearestFrame:
//INFO : Time: 0, Value: 5
//INFO : Time: 1, Value: 6
//INFO : Time: 2, Value: 7
//INFO : Time: 3, Value: 8
//INFO : Time: 4, Value: 9
//INFO : Time: 5, Value: 10 |