FCurve
 
 
 

FCurve

Object Hierarchy | Related C++ Class: FCurve

Inheritance

SIObject

AnimationSource

FCurve

Introduced

v1.0

Description

The FCurve (function curve) object provides access to a set of functions for getting and setting Softimage fcurve attributes, as well as creating, retrieving, modifying and deleting fcurve keys.

FCurves can be created and connected to parameters using the Parameter.AddFCurve and Parameter.AddFCurve2 methods. To access an existing FCurve on a Parameter, use the Parameter.Source method. FCurves are supported by the following parameter types: siDouble, siFloat, siInt4, siInt2, siByte, siUInt4, siUInt2 and siUByte (see siVariantType for definitions of these types).

When defining FCurveKeys, the key value is coerced to meet the key value's type criteria. For boolean and integer fcurves, the values supplied are rounded. For example, if you provide the value 3.5 to an integer fcurve, it is rounded down to 3. For boolean fcurves, non-zero values are interpreted as true.

SIObject.Parent returns the parent of the fcurve. For fcurves connected to parameters, the Parameter object is considered to be the parent. For fcurves contained by ActionSource objects the parent is the AnimationSourceItem object.

Note: For more information, see "FCurve Interpolation and Extrapolation" in the Softimage user guide.

Methods

AddKey BeginEdit EndEdit Eval
ExtendCycle Fit GetKey GetKeyAtIndex
GetKeyFrame GetKeyIndex GetKeyValue GetKeysBetween
GetMaxKeyFrame GetMaxKeyValue GetMidKeyFrame GetMidKeyValue
GetMinKeyFrame GetMinKeyValue GetNumKeys InsertKeyAtFrame
IsClassOf operator IsEditing IsEqualTo operator KeyExists
MakeRotationsContinuous Offset OffsetKeys RemoveKey
RemoveKeyAtIndex RemoveKeys RemoveKeysAtIndex Resample
Scale ScaleKeys Set SetKey
SetKeyTangents SetKeys Smooth SnapToNearestFrame
UndoEdit      
       

Properties

Application Categories DependsOnFrameRate Extrapolation
FullName operator Help HighClamp Interpolation
Keys Locked LowClamp Mute
Name operator NestedObjects NoKeyValue Origin
OriginPath Parent SI3DStyle Selected
SelectedKeys Type Type operator  
       

Examples

1. JScript Example

/*
        This example demonstrates how to get the parent of an fcurve.
*/ 
// Set up the scene with a custom pset on a null
NewScene( null, false );
var n = ActiveSceneRoot.AddNull();
var pset = n.AddCustomProperty( "CustomPSet" );
var x = pset.AddParameter3( "X", siDouble, 0, 0, 100 );
LogMessage( "x value = " + x.value, siInfo )
LogMessage( "x min/max = " + x.min + ", " + x.max, siInfo )
// Set an fcurve on the custom parameter
var fc = x.AddFCurve2( null, null );
var param = fc.Parent;
LogMessage( "parent of fcurve = " + param.FullName, siInfo );
LogMessage( "param isequal to x = " + param.IsEqualTo(x), siInfo );
// Outputs:
//INFO : "x value = 0"
//INFO : "x min/max = 0, 100"
//INFO : "parent of fcurve = null.CustomPSet.X"
//INFO : "param isequal to x = true"

2. VBScript Example

' ==========================================================================
'   This part of the script just sets up the sphere, curve, and the path
'   constraint between them.
' --------------------------------------------------------------------------
' Set up scene context
Set oRoot = ActiveSceneRoot
' Create sphere that will be animated with path constraint
Set oSphere = oRoot.AddGeometry( "Sphere", "MeshSurface" )
' Create curve for path constraint
Set oCrv = SICreateCurve( "crvlist", 3, 0 )
SIAddPointOnCurveAtEnd oCrv, _
        -7.87711815167134, -1.9399113143663, 0.193991131436629, False
SIAddPointOnCurveAtEnd oCrv, _
        8.74360114835504, -5.93730432578764, 0.593730432578766, False
SIAddPointOnCurveAtEnd oCrv, _
        7.60141901636287, 5.15350177452872, -0.515350177452866, False
SIAddPointOnCurveAtEnd oCrv, _
        -6.30169452133709, 5.03593139183983, -0.50359313918398, False
SIAddPointOnCurveAtEnd oCrv, _
        2.71760576232661, -6.21163521872843, 0.621163521872845, False
' Apply path constraint to sphere 
SelectObj oSphere, , True
ApplyPath oSphere, oCrv, 10.0, 95.5, 2, False, False

' ==========================================================================
'   This part of the script finds the existing fcurve & gets the time in 
'   frames of the first and last key.
' --------------------------------------------------------------------------
' Get all the meshes under the root
Set oMeshes = oRoot.FindChildren(,,siMeshFamily)
LogMessage "Number of meshes found: " & oMeshes.Count
' Iterate over the meshes to find the one with the fcurve
For Each s In oMeshes
        ' Get the path constraint on the object
        Set oCns = s.Kinematics.Constraints("PathCns")
        ' Just to make sure script doesn't crash if not found
        If oCns <> "Nothing" Then
                ' Getting path percentage to check that it's ok
                LogMessage "Path percentage = " & oCns.perc.Value
                ' Get fcurve attached to path percentage
                Set oFCurve = oCns.perc.Source
                ' Getting first & last curves on source
                If oFCurve.Keys.Count > 0 Then
                        dFCKeyA = oFCurve.Keys(0).Time
                        dFCKeyZ = oFCurve.Keys(oFCurve.Keys.Count - 1).Time
                        ' Print values
                        LogMessage "First key in time is at frame " & dFCKeyA
                        LogMessage "Last key in time is at frame " & dFCKeyZ
                End If
        End If
Next
' Output of above script is:
' --------------------------
'INFO : "Number of meshes found: 1"
'INFO : "Path percentage = 100"
'INFO : "First key in time is at frame 4.126"
'INFO : "Last key in time is at frame 90.274"

3. VBScript Example

' 
' This example manipulates the FCurve that drives a Linked Parameter
' 
dim oControlPSet, oControlledPSet
set oControlPSet = ActiveSceneRoot.AddProperty( "CustomProperty", false, "ControlPSet" )
oControlPSet.AddParameter2 "LinkSrc", siInt4, 5, 0, 20, 0, 20, 0, siAnimatable 
set oControlledPSet = ActiveSceneRoot.AddProperty( "CustomProperty", false, "ControlledPSet" )
oControlledPSet.AddParameter2 "LinkDest", siInt4, 5, 0, 20, 0, 20, 0, siAnimatable 
'Create linked parameter
SetExpr "ControlledPSet.LinkDest", "l_fcv( ControlPset.LinkSrc )"
'Important: This is how you get to the FCurve so you can
'create the specific relationship
dim oFCurve, oExpr      
set oExpr = oControlledPSet.Parameters( "LinkDest" ).Source                     
set oFCurve = oExpr.Parameters( "l_fcv" ).Source
oFCurve.BeginEdit
oFCurve.RemoveKeys
oFCurve.Interpolation = siLinearInterpolation
'Important: Linked fcurves are time independant.  So the in_Frame value is
'used directly as input (i.e. no conversion from frames to seconds is done).
'When linksrc is 0 then linkdest is 0
oFCurve.AddKey 0, 1
'when linksrc is 1 then linkdest is 3
oFCurve.AddKey 1, 3
'when linksrc is 2 then listdest is 2
oFCurve.AddKey 2, 2
'When linksrc is 10 the listdest is 20
oFCurve.AddKey 10, 20
oFCurve.EndEdit
'Demonstrate the relationship
oControlPSet.LinkSrc.Value = 1
Logmessage oControlledPSet.LinkDest.Value 
oControlPSet.LinkSrc.Value = 10
Logmessage oControlledPSet.LinkDest.Value 
'Expected results:
'INFO : 3
'INFO : 20

See Also

FCurveKey FCurveKeyCollection Parameter.AddFCurve GetFCurveInfo Parameter AnimationSourceItem Parameter.Max Parameter.Source CustomProperty.AddFCurveParameter PPGLayout.AddFCurve Sequence ScaleAndOffset ActivateFCurve CopyAnimation