エクスプレッションはパラメータ値を制御するデータ断片(DataSource)です。つまり、以下のいずれの方法を使ってアクセスできます。
スクリプト コマンド: GetSource は、1 つまたは複数のパラメータ名を取って、そのソースの XSICollection を返します。
オブジェクト モデル: Parameter.Source
C++ API: Parameter::GetSource
また、エクスプレッションに基づくクリップとソースからアニメーション情報を取得することも可能です。 詳細については「エクスプレッションとミキサ」を参照してください。
この例では、Python で GetSource コマンドを使用して、エクスプレッションへのポイントを取得する方法を示します。 この例は 「Python の例: SetExpr コマンドを使ってのエクスプレッションの設定」から続くもので、null の位置にエクスプレッションを適用します。
# Find the expressions on Null4Expr rtn = Application.GetSource( params, c.siExpressionSource ) for expr in rtn : # From the expression we can access its output port for oport in expr.OutputPorts : target = oport.Target2 Application.LogMessage( "Expression is writing " + str(target.Value) + " to " + target.FullName ); # Expected result: #INFO : Expression is writing 2.0 to Null4Expr.kine.local.posx #INFO : Expression is writing 2.0 to Null4Expr.kine.local.posy #INFO : Expression is writing 2.0 to Null4Expr.kine.local.posz
この例では、JScript で Source プロパティを使用して、エクスプレッションへのポイントを取得する方法を示します。 この例は、「JScript の例: Parameter.AddExpression メソッドを使ってのエクスプレッションの設定」から続くもので、null の位置にエクスプレッションを適用します。
// Find the expressions on Null4Expr
var params2search = n.AnimatedParameters();
for ( var i=0; i<params2search.Count; i++ ) {
var expr = params2search(i).Source;
// From the expression we can access its output port
var oports = new Enumerator( expr.OutputPorts );
for ( ; !oports.atEnd(); oports.moveNext() ) {
var target = oports.item().Target2;
Application.LogMessage( "Expression is writing " + target.Value + " to " + target.FullName );
}
}
// Expected result:
//INFO : Expression is writing 2 to Null4Expr.kine.local.posx
//INFO : Expression is writing 2 to Null4Expr.kine.local.posy
//INFO : Expression is writing 2 to Null4Expr.kine.local.posz
この例では、C++ で GetSource メンバを使用して、エクスプレッションへのポイントを取得する方法を示します。 この例は、「C++ API の例: Parameter::AddExpression メンバ関数を使ってのエクスプレッションの設定」から続くもので、null の位置にエクスプレッションを適用します。
// Find the expressions on Null4Expr
CRefArray params2search = n.GetAnimatedParameters( siExpressionSource );
for ( LONG i=0; i<params2search.GetCount(); ++i )
{
Parameter posparam( params2search[i] );
Expression expr( posparam.GetSource() );
// From the expression we can access its output port
CRefArray oports( expr.GetOutputPorts() );
for ( LONG j=0; j<oports.GetCount(); ++j )
{
OutputPort currport( oports[j] );
Parameter target( currport.GetTarget() );
app.LogMessage( L"Expression is writing " + CString(target.GetValue()) + L" to " + target.GetFullName() );
}
}
// Expected results:
//INFO : Expression is writing 2 to Null4Expr.kine.local.posx
//INFO : Expression is writing 2 to Null4Expr.kine.local.posy
//INFO : Expression is writing 2 to Null4Expr.kine.local.posz
スクリプティングまたは C++ API を介してアクションを保存する唯一の方法は、StoreAction(または SIStoreAction)コマンドを使用することです。 StoreAction コマンドは、いくつかの異なる種類のローレベル アニメーションを ActionSource または ActionSource として、F カーブ、コンストレイント、静的値のエクスプレッションのほかにも保存します。
JScriptの例: エクスプレッションベースのソースおよびクリップの作成
この例は、2 つの null の間にリンクパラメータのエクスプレッションを設定してから、そのエクスプレッションをアクションとして格納する方法を示します。 この例は、ミキサのトラックからのモデルおよびクリップからのソースをアクセスして、「JScript の例: エクスプレッションベースのアクションソースおよびクリップへのアクセス」に引き継がれます。
var root = Application.ActiveSceneRoot;
var jack = root.AddNull("jack");
var diane = root.AddNull("diane");
// Get list of parameters to mark
var params = jack+".kine.local.posx,";
params += jack+".kine.local.posy,";
params += jack+".kine.local.posz";
// Create an Expression (linked parameter)
AddExpr( jack+".kine.local.posx", "l_fcv("+diane+".kine.local.posx)-0.25", true );
AddExpr( jack+".kine.local.posy", "l_fcv("+diane+".kine.local.posy)", true );
AddExpr( jack+".kine.local.posz", "l_fcv("+diane+".kine.local.posz)+0.25", false );
// Make the Expressions into an Action
StoreAction( root, params, 3, "StoredExprAction", true, 0, 0, false, false, true, 0);
C++ の例: エクスプレッションベースのソースおよびクリップの作成
この例は、エクスプレッション ソースを作成する方法と、C++ API を使ってミキサにクリップとしてエクスプレッション ソースのインスタンスを作成する方法を示します。 この例は、ミキサのトラックからのモデルおよびクリップからのソースをアクセスして、「C++ の例: エクスプレッションベースのアクションソースおよびクリップへのアクセス」に引き継がれます。
Application app = Application();
Model root = app.GetActiveSceneRoot();
Null jack; root.AddNull( L"jack", jack );
Null diane; root.AddNull( L"diane", diane );
// Get list of parameters to mark
CString jname = jack.GetFullName();
CString dname = diane.GetFullName();
CString params = jname + L".kine.local.posx," + jname + L".kine.local.posy," + jname + L".kine.local.posz";
// Create an Expression (linked parameter) on posx
CValueArray addExprArgs; CValue outArg;
addExprArgs.Add( jname + L".kine.local.posx" );
addExprArgs.Add( L"l_fcv(" + dname + L".kine.local.posx)-0.25" );
addExprArgs.Add( true );
app.ExecuteCommand( L"AddExpr", addExprArgs, outArg );
// For the second call, just change the first two arguments
addExprArgs[0] = jname + L".kine.local.posy";
addExprArgs[1] = L"l_fcv(" + dname + L".kine.local.posy)";
app.ExecuteCommand( L"AddExpr", addExprArgs, outArg );
// For the third call, change all arguments
addExprArgs[0] = jname + L".kine.local.posz";
addExprArgs[1] = L"l_fcv(" + dname + L".kine.local.posz)+0.25";
addExprArgs[2] = false;
app.ExecuteCommand( L"AddExpr", addExprArgs, outArg );
// Make the Expressions into an Action
CValueArray storeActionArgs;
storeActionArgs.Add( root.GetFullName() );
storeActionArgs.Add( params );
storeActionArgs.Add( CValue(3.0) );
storeActionArgs.Add( L"StoredExprAction" );
storeActionArgs.Add( true );
storeActionArgs.Add( CValue(0.0) );
storeActionArgs.Add( CValue(0.0) );
storeActionArgs.Add( false );
storeActionArgs.Add( false );
storeActionArgs.Add( true );
storeActionArgs.Add( CValue(0.0) );
app.ExecuteCommand( L"StoreAction", storeActionArgs, outArg );
ActionSource または ActionSource はモデルから使用でき、そのモデルの下に Model.Sources プロパティ(OM)または Model::GetSources メンバ(C++ API)を介して保存またはインスタンス化されます。
Clip は、クリップのインスタンスが作成されるミキサまたはコンパウンド クリップのいずれかから使用できます。 また、その Track 所有者から直接使用することもできます。 オブジェクト モデルでは、使用するプロパティは ClipContainer.Clips および Track.Clips です。 C++ API の場合は、ClipContainer::GetClips および Track::GetClips を使用できます。
JScript の例: エクスプレッションベースのアクションソースおよびクリップへのアクセス
この例では、Model.Sources プロパティを使って ActionSource を取得する方法と、Track.Clips プロパティを使って Clip を取得する方法を示します。 この例は、「JScript の例: エクスプレッションベースのソースおよびクリップの作成」から続くもので、null の位置にエクスプレッションを適用され、その後保存され、インスタンス化されます。
// Get the new source from the model
var sourcelist = new Enumerator( root.Sources );
for ( ; !sourcelist.atEnd(); sourcelist.moveNext() ) {
var src = sourcelist.item();
// Make sure we are getting the right source by testing the underlying
// AnimationSourceItem to verify that it is an Expression
if ( src.SourceItems(0).Type == siExpressionAnimItem ) {
Application.LogMessage( "Found " + src.FullName );
}
}
// Get the clip from the mixer via the Track object
if ( root.HasMixer() ) {
var alltracks = new Enumerator( root.Mixer.Tracks );
for ( ; !alltracks.atEnd(); alltracks.moveNext() ) {
// Make sure to skip audio and shape tracks
if ( alltracks.item().Type == siTrackAnimationType ) {
var currtrack = alltracks.item();
var cliplist = new Enumerator( currtrack.Clips );
for ( ; !cliplist.atEnd(); cliplist.moveNext() ) {
var clp = cliplist.item();
Application.LogMessage( "Found " + clp.FullName );
}
}
}
}
//INFO : Found Sources.Scene_Root.StoredExprAction
//INFO : Found Mixer.Mixer_Anim_Track.StoredExprAction_Clip
C++ の例: エクスプレッションベースのアクションソースおよびクリップへのアクセス
この例では、Model::GetSources を使って ActionSource を取得する方法と、Track::GetClips を使って Clip を取得する方法を示します。 この例は、「C++ の例: エクスプレッションベースのソースおよびクリップの作成」から続くもので、null の位置にエクスプレッションを適用され、その後保存され、インスタンス化されます。
// Get the new source from the model
CRefArray sourcelist = root.GetSources();
for ( LONG i=0; i<sourcelist.GetCount(); ++i )
{
ActionSource src( sourcelist[i] );
// Make sure we are getting the right source by testing the underlying
// AnimationSourceItem to verify that it is an Expression
CRefArray underlying = src.GetItems();
AnimationSourceItem animsrcitm( underlying[0] );
if ( animsrcitm.GetType() == siExpressionAnimItem )
{
app.LogMessage( L"Found " + src.GetFullName() );
}
}
// Get the clip from the mixer via the Track object
if ( root.HasMixer() ) {
CRefArray alltracks = root.GetMixer().GetTracks();
for ( LONG j=0; j<alltracks.GetCount(); ++j )
{
// Make sure to skip audio and shape tracks
Track currtrack( alltracks[j] );
if ( currtrack.GetType() == siTrackAnimationType ) {
CRefArray cliplist = currtrack.GetClips();
for ( LONG k=0; k<cliplist.GetCount(); ++k )
{
Clip clp( cliplist[k] );
app.LogMessage( L"Found " + clp.GetFullName() );
}
}
}
}
// Expected results:
//INFO : Found Sources.Scene_Root.StoredExprAction
//INFO : Found Mixer.Mixer_Anim_Track.StoredExprAction_Clip