Operator.ConnectToGroup

導入

v4.0

詳細

オブジェクトをポートグループに接続します。このメソッドは、オブジェクトが接続された後に任意で複数インスタンスの接続が作成されたダイナミックオペレータで使用すると便利です。

注:ポートグループにあるポートが 1 つの場合、このメソッドは自己インストールカスタムオペレータに対してのみ機能します。この制限は、渡すことができるObject引数のオブジェクトが 1 つだけであるため設けられています。

C#構文

Int32 Operator.ConnectToGroup( Int32 in_group, Object in_obj );

スクリプト構文

oLong = Operator.ConnectToGroup( Group, Object );

戻り値

Long。新しいポートグループインスタンスのインデックス

パラメータ

パラメータ タイプ 説明
Group Long 接続先のポートグループ
Object Object ポートに接続されるオブジェクト。組み込みOperatorの場合、このオブジェクトにX3DObjectを指定できます。この場合、Softimage は、X3DObject の下から正しいデータの検索し、PortGroup内の各ポートと一致させるように試みます。自己インストールカスタムオペレータの場合、ここではPortGroup内のポートの特定のターゲットオブジェクトを指定します。

JScript の例

/*

	This example demonstrates how to connect a runtime custom operator to an object.

*/

NewScene( null, false );

var null1 = GetPrim( "null" );

var null2 = GetPrim( "null" );

// Create a runtime scripted operator and turn on debugging (logs extra information)

var sop = XSIFactory.CreateScriptedOp( "myexpr", myexpr_Update.toString(), "JScript" );

sop.Debug = 1;

// Add a portgroup to read from/write to

var group1 = sop.AddPortGroup( "MainGroup" )

// We use an IO port because we want to blend the existing

// transformation rather than completely replacing it

sop.AddIOPort( null1.Kinematics.Local, "", group1.Index );

// Add a second group with an optional port

var group2 = sop.AddPortGroup( "SecondGroup", 0, 1 )

sop.AddInputPort( null2.Kinematics.Local, "inputs", -1, group2.Index );

// Connect first group.  Operator would start functioning immediately

sop.ConnectToGroup( group1.Index, null1.Kinematics.Local );

// Connect to the optional port

sop.ConnectToGroup( 1, null2.Kinematics.Local);

// This has no effect on null1

Translate( null2, 1, -1, 1 );

// This changes null1 rotation as well

Rotate(null2, 90, -45, 0 ) ;

// This operator constrains the rotation of the connected (target) object to the

// rotation of the object connected through the second portgroup.

function myexpr_Update( ctx, out, inlocal1, inlocal2 )

{

	Application.LogMessage( "myexpr_Update: " + out.Name );

	Application.LogMessage( ""+(inlocal2) );

	var transfo = inlocal1.Value.Transform;

	// Is there an object connected to the 2nd group?

	if ( ctx.Operator.GetNumInstancesInGroup( 1 ) )

	{

		var inlocal2 = ctx.Operator.PortAt( 0, 1, 0 );

		// Is the port connected?

		if ( inlocal2.IsConnected )

		{

			var rot = inlocal2.Value.Transform.Rotation;

			transfo.SetRotation	( rot );

		}

	}

	out.Value.Transform = transfo;

}

関連項目

Operator.DisconnectGroup UpdateConnectOnOp