Object Hierarchy | 関連する C++クラス:Expression
エクスプレッション
v2.0
Expression オブジェクトは、Parameter.AddExpression によって作成できるパラメータ上のアニメーションソースを表す Operator の一種です。Softimage の Expression により、算術式でアニメーションのパラメータを制御できます。これにより、その他のパラメータの値への参照を含めることができます。この式は、"Definition"パラメータの値として格納され、次の例で示すようにオブジェクトモデルを介して変更することができます。
パラメータの値を Expression により取得する場合、Expression は Parameter.Source プロパティを使用して呼び込むことができます。
式オブジェクトはオペレータの一種なので、Operator.InputPorts プロパティを使用して読み込まれる式からパラメータにアクセスできます。また、ポートグループへのアクセスも提供されます(オペレータの一種であるため)。ただし、式はポートグループを定義しませんが、SDK によって簡単なアクセスが可能です(詳細については Operator.GetNumPortGroups を参照)。
詳細については、Softimage ユーザ ガイドの「エクスプレッション リファレンス」を参照してください。
// This example illustrates how to apply an expression and access it.
NewScene( null, false );
var oNull = ActiveSceneRoot.AddNull();
var oAnotherNull = ActiveSceneRoot.AddNull("AnotherNull");
strExpr = oAnotherNull.posy.FullName + " + 2";
var oExpr = oNull.posx.AddExpression(strExpr);
//You can access the parameter to which an expression is connected by using the output port.
Application.LogMessage("Parameter owner of the expression " + oExpr.OutputPorts(0).Target2.FullName);
//You can access the parameter which are used inside an expression by using the input ports of
//the expression operator.
var oInputPorts = oExpr.InputPorts
for(i = 0; i < oInputPorts.Count; i++)
{
Application.LogMessage("Parameter client of the expression " + oInputPorts(i).Target2.FullName);
}
// Formula that defines the expression is available as a Parameter value
oDefinitionParam = oExpr.Parameters( "Definition" )
Application.LogMessage( "Expression definition :" + oDefinitionParam.Value) ;
// Expression can be changed
strNewExpr = oAnotherNull .posy.FullName + " - " + oAnotherNull .posx.FullName ;
oDefinitionParam.Value = strNewExpr ;
Application.LogMessage( "New expression definition : " + oDefinitionParam.Value ) ;
// Show the new expression formula in action
oAnotherNull.posy = 10 ;
oAnotherNull.posx = 4 ;
// Value should be 10 - 4 = 6
Application.LogMessage( "With new expression posx is " + oNull.posx.value ) ;
// Remove the expression
oNull.posx.Disconnect() ;
//INFO : Parameter owner of the expression null.kine.local.posx
//INFO : Parameter client of the expression AnotherNull.kine.local.posy
//INFO : Expression definition :AnotherNull.kine.local.posy + 2
//INFO : New expression definition : AnotherNull.kine.local.posy - AnotherNull.kine.local.posx
//INFO : With new expression posx is 6 |