Parameter.HasInstanceValue

導入

v5.0

詳細

パラメータがインスタンス値であるか(true)かないか(false)を示す Boolean 値を戻します。インスタンスパラメータは、共有できるオブジェクトに属するパラメータで、共有される場所では一意の値を取ります。

インスタンス値には、ImageShader.tspace_id、Material.ImageClipName、Material.UV、Material.CAV などが含まれます。たとえば、マテリアルは MaterialLibrary に所有されていますが、多くのオブジェクトによって使用されます。ImageShader.tspace_id パラメータでは、各オブジェクトは特有の値を取ります。

C#構文

// get accessor

Boolean rtn = Parameter.HasInstanceValue;

JScript の例

/*

	This example illustrates how to detect all parameters that support instance values 

	and determine which parameters are currently in use based on the usage of the material.

	Parameters with instances values include: ImageShader.tspace_id, Material.ImageClipName, 

	Material.UV, Material.CAV.

*/

NewScene( null, false );

// Create an object with its own material

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

var mat = cube.AddMaterial( "Blinn", false, "MyMaterial" );

// Create an object with a material on a polygon cluster

var torus = Application.ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface", "MyTorus" );

var cluster = torus.ActivePrimitive.Geometry.AddCluster( siPolygonCluster, "MyPolygonCluster" );

var clsmat = cluster.AddMaterial( "Phong", false, "MyMaterialOnCluster" );

// This object will get the material from the scene root.

var sphere = Application.ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface", "MySphere" );

// Create an unused material

SICreateMaterial( "Lambert", "UnusedMaterial"  );

var matlib = Application.ActiveProject.ActiveScene.ActiveMaterialLibrary;

for ( var i = 0; i < matlib.Items.Count; i++ )

{

	var mat = matlib.Items(i);

	if ( mat.UsedBy.Count == 0 )

	{

		Application.LogMessage( mat.fullname + " is unused" );

		continue;

	}

	for ( var j = 0; j < mat.Parameters.Count; j++ )

	{

		var param = mat.Parameters(j);

		if ( param.HasInstanceValue )

		{

			var colUsedBy = XSIFactory.CreateObject( "XSI.Collection" );

			colUsedBy.AddItems( mat.UsedBy );

			colUsedBy.RemoveItems( Application.ActiveSceneRoot );

			// Don't consider scene material in use - if there are no renderable objects.

			if ( colUsedBy.Count == 0 )

				Application.LogMessage( param.FullName + " belongs to the scene material and is currently unused" );

			else

				Application.LogMessage( param.FullName + " is an instance value and is being used by " 

								+ colUsedBy.GetAsText() );

		}	

	}

}

// Expected results:

//INFO : Sources.Materials.DefaultLib.Scene_Material.CAV is an instance value and is being used by MyTorus,MySphere

//INFO : Sources.Materials.DefaultLib.Scene_Material.UV is an instance value and is being used by MyTorus,MySphere

//INFO : Sources.Materials.DefaultLib.Material.CAV is an instance value and is being used by MyCube

//INFO : Sources.Materials.DefaultLib.Material.UV is an instance value and is being used by MyCube

//INFO : Sources.Materials.DefaultLib.Material1.CAV is an instance value and is being used by MyTorus.polymsh.cls.MyPolygonCluster

//INFO : Sources.Materials.DefaultLib.Material1.UV is an instance value and is being used by MyTorus.polymsh.cls.MyPolygonCluster

//INFO : Sources.Materials.DefaultLib.UnusedMaterial is unused