SIConnectShaderToCnxPoint

導入

v1.0

カテゴリ

shader

詳細

シェーダを指定のシェーダ接続ポイントに接続します。

スクリプト構文

oReturn = SIConnectShaderToCnxPoint( [Source], [InputObjs], [DeleteOnLastDisconnection] );

戻り値

新しく接続されたシェーダを含むXSICollectionを戻します。

パラメータ

パラメータ タイプ 詳細
Source 文字列 接続するシェーダ

デフォルト値: 現在選択されている値

InputObjs 文字列 シェーダの接続ポイントのリスト

デフォルト値: 現在選択されている値

DeleteOnLastDisconnection ブール True を設定すると、このコマンドによって接続解除された既存のシェーダが削除されます。

デフォルト値: True

VBScript の例

'
' This example creates a sphere, applies a lambert shader to it, prints out
' the list of connection points to that shader, connects the toon shader 
' to the surface and shadow connection points and then prints the updated list.
'
' Create the sphere to which the shader will be connected
NewScene , false
set oSphere = CreatePrim( "Sphere", "NurbsSurface" )
' Apply a lambert shader to instantiate the material
sPresetPath = XSIUtils.BuildPath(_
        Application.InstallationPath(siFactoryPath), _
        "Data", "DSPresets", "Shaders", "Material", "Lambert.Preset" _
)
set oShader = SIApplyShader( sPresetPath, oSphere, "Christopher" )
' Convert the shader to a Shader object 
set oShader = oShader(0)
' Print lambert shader info 
printShaderInfo oShader
' Load a toon shader
CreateShaderFromPreset "Shaders\Material\Toon_Paint_Rounded.Preset", "Sources.Materials.DefaultLib.Material"
' For convenience, create a collection to hold the parameters
' to be disconnected (Surface and Shadow connection points).
set oCnxPoints = CreateObject( "XSI.Collection" )
oCnxPoints.Add oSphere & ".material.Surface"
oCnxPoints.Add oSphere & ".material.Shadow"
' Use that collection to connect the toon shader to the sphere 
set oToony = SIConnectShaderToCnxPoint( "Sources.Materials.DefaultLib.Material.Toon_Paint_Rounded", oCnxPoints )
' Convert the shader to a Shader object 
set oToony = oToony(0)
' Print toon shader info 
printShaderInfo oToony
' This is a convenience routine that prints information about the shader
sub printShaderInfo( in_shader )
        ' From the shader object you can get the material it belongs to
        set oMaterial = in_shader.Owners(0)
        ' Use the material to return the parameters that are connected and
        ' print out their names
        for each p in oMaterial.Parameters
                 if TypeName( p.Source ) <> "Nothing" then
                         Application.LogMessage p.ScriptName & " is connected to " & p.Source.Name
                 end if
        next
end sub
' Output of the above script:
' ...before adding the toon shader
' INFO : surface is connected to Christopher
' INFO : shadow is connected to Christopher
' INFO : Photon is connected to Christopher
'
' ...after adding the toon shader
' INFO : surface is connected to Phong
' INFO : shadow is connected to Phong
' INFO : Photon is connected to Lambert

関連項目

AddObjectsToShader RemoveObjectsFromShader ApplyShader RemoveShaderFromCnxPoint RemoveAllShadersFromCnxPoint