Parameter.Disconnect

導入

v2.0

詳細

任意の Shader またはパラメータに接続されたアニメーションを接続解除します。このメソッドで削除できるアニメーションは、FCurveExpression、および Operator です。

C#構文

DataSource Parameter.Disconnect();

スクリプト構文

oDataSource = Parameter.Disconnect();

戻り値

以前接続されていたDataSource。注:戻されたオブジェクトは、Shader の場合は有効ですが、FCurve の場合は無効です。

1. VBScript の例

'

' This example illustrates how to disconnect a shader from the photon parameter of a material.

'

NewScene , false

set grid = Application.ActiveSceneRoot.AddGeometry( "Cube","MeshSurface" )

set mat = grid.AddMaterial( "Phong" )

set photon = mat.Parameters("Photon")

set shader = photon.Disconnect()

2. VBScript の例

' 

' Demonstration of using Disconnect to remove an FCurve from a Parameter

' 

NewScene , false

set oCube = Application.ActiveSceneRoot.AddGeometry( "Cube", "MeshSurface" )

set oPosXParam = oCube.PosX

dim aValues

aValues = Array( 0.00, 5.00, 1.00, 6.00, 2.00, 7.00, 3.00, 8.00 )

oPosXParam.AddFCurve2( aValues )

set oFCurve = oPosXParam.Source

Application.LogMessage "Expected value at frame 10: " & oFCurve.Eval( 10 )  

' Disconnect the FCurve

set oFCurve = oPosXParam.Disconnect

' You can still evalute the fcurve but it doesn't belong to the parameter

Application.LogMessage "FCurve value at Frame 10:" & oFCurve.Eval( 10 )  

' Prove that the FCurve is gone.

Application.LogMessage "Source driving Parameter value: " & TypeName( oPosXParam.Source ) 

SetValue "PlayControl.Current", 10

Application.LogMessage( "Parameter value with no FCurve: " & oPosXParam.Value ) 

' Expected output

'INFO : Expected value at frame 10: 8

'INFO : FCurve value at Frame 10:8

'INFO : Source driving Parameter value: Nothing

'INFO : Parameter value with no FCurve: 5

3. JScript の例

/*

	Demonstrates deleting an FCurve with Parameter.Disconnect

*/

NewScene( null, false ) ;

var oCube = Application.ActiveSceneRoot.AddGeometry( "Cube", "MeshSurface" ) ;

var oPosXParam = oCube.PosX

aValues = new Array( 0.00, 5.00, 1.00, 6.00, 2.00, 7.00, 3.00, 8.00 ) ;

oPosXParam.AddFCurve2( aValues ) ;

Application.LogMessage( oPosXParam.Source == null ) ;

oPosXParam.Disconnect();

Application.LogMessage( oPosXParam.Source == null ) ;

// Expected results:

//INFO: false

//INFO: true

4. JScript の例

/*

	Demonstration of removing an expression with Parameter.Disconnect

*/

NewScene( null, false ) ;

var oCube = Application.ActiveSceneRoot.AddGeometry( "Cube","MeshSurface" ) ;

var oLocalKine = oCube.Kinematics.Local

var oPosXParam = oLocalKine.PosX

var oPosYParam = oLocalKine.PosY

oPosXParam.AddExpression( oPosYParam.FullName + " * 2.0" ) ;

Application.LogMessage( "Before disconnecting:" ) ;

Application.LogMessage( "Source: " + oPosXParam.Source.Type  ) ;

Application.LogMessage( "Number of Animated parameters: " + oCube.AnimatedParameters().Count ) ;

oPosXParam.Disconnect();

Application.LogMessage( "After disconnecting:" ) ;

Application.LogMessage( "Source is null? " + ( oPosXParam.Source == null ) ) ;

Application.LogMessage( "Number of Animated parameters: " + oCube.AnimatedParameters().Count ) ;

//INFO : Before disconnecting:

//INFO : Source: Expression

//INFO : Number of Animated parameters: 1

//INFO : After disconnecting:

//INFO : Source is null? true

//INFO : Number of Animated parameters: 0

5. JScript の例

/*

	Example of removing an Operator using Parameter.Disconnect

*/

NewScene( null, false );

var obj = Application.ActiveSceneRoot.AddNull();

obj.posx.AddScriptedOp( myexpr_Update.toString(), obj.posy, "myexpr", "JScript" );

// Invoke the custom operator

obj.posy = 26 ;

// posx will have been changed to 20 by the operator

Application.LogMessage( "Value of posx:" + obj.posx.Value ) ;

obj.posx.Disconnect() ;

// Change the value of posy again

// However because there is no operator 

// now it will have no effect on posx

obj.posy = 18 ;

Application.LogMessage( "No source anymore? " + (obj.posx.Source == null) ) ;

Application.LogMessage( "Value of posx " + obj.posx.Value ) ;

//Expected output:

//INFO : Value of posx:20

//INFO : No source anymore? true

//INFO : Value of posx 20

function myexpr_Update( ctx, out, inposy )

{

	var posYVal = inposy.Value ;

	if ( posYVal < 20 )	

		out.Value = inposy;

	else

		out.Value = 20 ;	

}

関連項目

RemoveAnimation Parameter.Source Parameter.Connect Parameter.ConnectFromFile Parameter.ConnectFromPreset Parameter.ConnectFromProgID