SetInstanceDataValue

導入

v1.0

カテゴリ

shader

詳細

パラメータにインスタンス固有のデータを設定します。 マテリアルなど一部のプロパティはいくつかのオブジェクトで共有できます。 状況によっては、オブジェクトのプロパティの 1 つに異なるパラメータ値を割り当てる必要があります。

パラメータの値はコンテキスト固有で、オブジェクトにより異なる点に注意してください。 現在、SetInstanceDataValue コマンドは、シェーダにどの Texture Projection を使用すべきかを指定する場合にのみ使用されます。 オブジェクトの空リストを使用してコマンドを呼び出した場合は、すべてのオブジェクトにこの値が指定され、今後このパラメータを使用して作成されるすべてのオブジェクトにもこの値が指定されます。 パラメータ値を空文字列に設定してコマンドを呼び出すと、インスタンス データ値がリセットされます。

スクリプト構文

SetInstanceDataValue( [InputObjs], InputObj, Value );

パラメータ

パラメータ タイプ 詳細
InputObjs 文字列 オブジェクトのリスト

デフォルト値:空、すべてのオブジェクト

InputObj 文字列 設定するパラメータリスト
文字列 新しいデータ

VBScript の例

'
' This example demonstrates setting a parameter on a shader so that it uses 
' two different projections depending on which item it applies to. In this
' case, we will create one projection for the cube and another for the sphere
' and then tell the shader to use the CubeProjection on the cube and the
' SphereProjection on the sphere.
'
NewScene , false
' Get the default pass
Set oDefPass = GetValue( "Passes.Default_Pass" )
' Create a cube and a sphere
CreatePrim "Cube", "MeshSurface"
CreatePrim "Sphere", "MeshSurface"
Translate "sphere", 5.987, 0.039, -0.004, siRelative, siView, siObj, siXYZ
' Create an XZ texture projection on the object
CreateProjection "cube,sphere", "siTxtPlanarXZ", _
        "siTxtDefaultPlanarXY", , "WrongProjection"
' Create XY texture projections on the objects, named "CubeProjection" 
' and "SphereProjection"
CreateProjection "cube", "siTxtPlanarXY", _
        "siTxtDefaultPlanarXY", , "CubeProjection"
CreateProjection "sphere", "siTxtPlanarXY", _
        "siTxtDefaultPlanarXZ", , "SphereProjection"
' Put the cube and sphere in a group, put a material on it, with 
' an image attached to diffuse.
ToggleSelection "cube"
CreateGroup
ApplyShader
SIApplyShaderToCnxPoint "Image", "sphere.Material.Phong.diffuse"
' Now render one frame of the scene to see the effect  
' (the default image was plunked directly on the top of the 
' cube and sphere)
RenderPasses oDefPass, 1, 1
' At this point, the image shader will, by default, choose the 
' texture projection named "WrongProjection".  We want to tell 
' the image shader that on the cube, it should use "CubeProjection", 
' and on the sphere, it should use "SphereProjection".  This 
' means that the parameter is instance-specific, so we use 
' the SetInstanceDataValue command
' This line sets the parameter "tspace_id" to be "SphereProjection" 
' for the object "sphere"
SetInstanceDataValue "sphere", _
        "Group.Material.Phong.Image.tspace_id", "SphereProjection"
' This line sets the parameter "tspace_id" to be "CubeProjection" 
' for the object "cube"
SetInstanceDataValue "cube", _
        "Group.Material.Phong.Image.tspace_id", "CubeProjection"
' Now render one frame of the scene to see the effect 
' (the default image was applied to the visible area of the 
' cube and sphere)
RenderPasses oDefPass, 1, 1