PPGLayout.AddFCurve operator

導入

v4.0

詳細

F カーブエディタをレイアウトに追加します。F カーブパラメータに関連付けられている必要があります(CustomProperty.AddFCurveParameterを参照)。このコントロールは完全なF カーブエディタです。Animation Divot と混同しないようにしてください。

その他のパラメータと同様に、レイアウトにカスタムロジックコードを追加して、F カーブが変更されるたびに呼び出されるようにできます。これについては、例の中で説明します

スクリプト 構文

oReturn = PPGLayout.AddFCurve( ScriptName, [Height] );

戻り値

PPGItem

パラメータ

パラメータ タイプ 詳細
ScriptName String Parameterのスクリプト名。FCurveタイプである必要があります。この名前のパラメータが存在しない場合でも呼び出しはエラーになりません。ただし、この場合は、コントロールはレイアウトの一部として表示されません
高さ Long コントロールの高さ。注:コントロールはプロパティページのサイズに応じて自動的にリサイズされるため、幅は設定する必要はありません。

デフォルト値:300

1. JScript の例

/*
        This example shows how an FCurve can be stored on a Custom Property and UI tools can be added 
        via the PPGLayout object
*/
BuildScene()
function BuildScene()
{
        NewScene( null, false ) ;
        var oCustomProperty = ActiveSceneRoot.AddProperty( "CustomProperty", false, "DataTemplate" ) ;
        oCustomProperty.AddFCurveParameter( "Curve" ) ;
        // Create read-only parameters that will be updated by the logic
        oCustomProperty.AddParameter3( "KeyCount", siInt4,null,null,null,false,true ) ;
        oCustomProperty.AddParameter3( "MaxY", siInt4,null,null,null,false,true ) ;
        // Build the Layout
        var oLayout = oCustomProperty.PPGLayout         
        var oLayoutItem = oLayout.AddFCurve( "Curve", 150 );
        oLayout.AddGroup( "Info" ) ;    
        oLayout.AddRow() ;
        oLayout.AddItem( "KeyCount" ) ;
        oLayout.AddItem( "MaxY" ) ;     
        oLayout.EndRow() ;
        oLayout.EndGroup() ;
        oLayout.AddRow() ;
        oLayout.AddButton( "Randomize" ) ;
        oLayout.AddButton( "Reframe" ) ;
        oLayout.EndRow() ;
        oLayout.Language = "JScript" ;
        oLayout.Logic = OnInit.toString() +
                Randomize_OnClicked.toString() +
                Reframe_OnClicked.toString() +
                ReCalcInfo.toString() +
                Curve_OnChanged.toString() ;
        InspectObj( oCustomProperty ) ;
}
//
// The following code is Logic code for the Property Page
//
function Randomize_OnClicked()
{
        // Get access to the curve
        var oFCurve = PPG.Curve.Value;
        oFCurve.BeginEdit();
        oFCurve.RemoveKeys();
        var maxKeys = 10.0 ;
        var maxX = 100.0 ;
        var maxY = 100.0 ;
        var keys = Math.round( maxKeys * Math.random() ) ;
        for ( var i = 0 ; i < keys ; i++ ) {
                var keyFrame = Math.round( maxX * Math.random() )
                oFCurve.AddKey( keyFrame,
                                                        maxY * Math.random() ) ;
        }
        // Always end back at zero
        oFCurve.AddKey( 0, 0 ) ;
        oFCurve.AddKey( maxX, 0 ) ;
        oFCurve.EndEdit() ;     
        ReCalcInfo() ;
}
function Reframe_OnClicked()
{
        //Redraw, which will reframe the new pset
        PPG.Refresh() ;
}
function ReCalcInfo()
{
        // Show the number of keys and maximum
        // Y value for the curves
        var oFCurve = PPG.Curve.Value;
        PPG.KeyCount.Value = oFCurve.Keys.Count
        var maxYFound = 0 ;
        for ( var i = 0 ; i < oFCurve.Keys.Count ; i++ ) {
                var y = oFCurve.GetKeyValue(i) ;        
                if ( y > maxYFound )  {
                        maxYFound = y ;
                }
        }
        PPG.MaxY.Value = maxYFound ;
}
function Curve_OnChanged()
{
        // Called when every the user changes the FCurve from the user interface.
        ReCalcInfo();
}
function OnInit()
{
        // Called when PPG is first draw, use the opportunity to calculate the initial
        // FCurve values
        ReCalcInfo() ;
}

2. VBScript の例

'
' This example shows how the FCurve control can be customized via SetUIAttribute
' All editors show the same curve but the presentation differs
option explicit
dim oCustomProperty, oLayout, oLayoutItem
set oCustomProperty = ActiveSceneRoot.AddProperty( "CustomProperty",false,"FCurves" )
oCustomProperty.AddFCurveParameter "curve1" 
oCustomProperty.AddFCurveParameter "curve2" 
oCustomProperty.AddFCurveParameter "curve3" 
oCustomProperty.AddFCurveParameter "curve4" 
set oLayout = oCustomProperty.PPGLayout
oLayout.AddRow
oLayout.AddFCurve "curve1", 150
oLayout.AddFCurve "curve2"
oLayout.EndRow
oLayout.AddRow
oLayout.AddFCurve "curve3", 150
oLayout.AddFCurve "curve4", 150
oLayout.EndRow
'Now set attributes
set oLayoutItem = oLayout.Item("curve2")
oLayoutItem.SetAttribute "NoGrid", true
oLayoutItem.SetAttribute "NoRulerX", true
oLayoutItem.SetAttribute "NoRulerY", true
'In order to line up nicely with the 
'other curve in the row set a smaller size (because
'the ruler is not showing
oLayoutItem.SetAttribute "CY", 125
set oLayoutItem = oLayout.Item("curve3")
oLayoutItem.SetAttribute "ViewMinX", -100
oLayoutItem.SetAttribute "ViewMaxX", 100
oLayoutItem.SetAttribute "ViewMinY", 0
oLayoutItem.SetAttribute "ViewMaxY", 150
oLayoutItem.SetAttribute "LabelX", "My X-Axis Label"
oLayoutItem.SetAttribute "LabelY", "My Y-Axis Label"
oLayoutItem.SetAttribute "ColorNonBijective", true
oLayoutItem.SetAttribute "Ghosting", true
'Grid spacing is mostly only a hint to the editor.
'It will ignore values that are too small
set oLayoutItem = oLayout.Item("curve4")
oLayoutItem.SetAttribute "GridSpaceX", 25
oLayoutItem.SetAttribute "GridSpaceY", 25
'Snap Grid is independent of the visible grid
oLayoutItem.SetAttribute "SnapX", 10
oLayoutItem.SetAttribute "SnapY", 10
InspectObj oCustomProperty

関連項目

CustomProperty.AddFCurveParameter FCurve PPGLayout.Logic