XSIFactory.RemoveShaderDef operator

導入

v9.0 (2011)

詳細

指定されたシェーダ定義を Softimage から削除します。

C#構文

XSIFactory.RemoveShaderDef( ShaderDef in_ShaderDef );

スクリプト構文

XSIFactory.RemoveShaderDef( in_ShaderDef );

パラメータ

パラメータ タイプ 説明
in_ShaderDef ShaderDef 削除するシェーダ定義

JScript の例

/*

	This example demonstrates how to create a completely bogus shader 

	definition on the fly (ie., not to be persisted), instantiate it 

	on a scene object, and then remove it.

*/

NewScene("", false);

// First check to make sure the parser name isn't already registered

// Create the shader definition on the fly and get its ProgID

var sProgID = CreateDefOnTheFly();

// Now create a cube and instantiate this shader on it

var oCube = CreatePrim("Cube", "MeshSurface");

CreateShaderFromProgID(sProgID, "Sources.Materials.DefaultLib.Scene_Material");

SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.Chauncey.splish", 

	"Sources.Materials.DefaultLib.Scene_Material.Phong.ambient", false);

// List all the on-the-fly shader definitions found

FindOnTheFlyDefs();

// Now remove it

var oRemoveMe = Application.ShaderDefinitions(sProgID);

if (oRemoveMe) {

	XSIFactory.RemoveShaderDef(oRemoveMe);

	// List any remaining on-the-fly shader definitions 

	FindOnTheFlyDefs();

} else {

	Application.LogMessage("Couldn't find "+sProgID+" shader definition");

}

// Expected output:

// INFO : Found 2 on-the-fly definition(s): RendererUserPorts.mental ray.1.0, Gardiner.Chauncey.1.0

// INFO : Found 1 on-the-fly definition(s): RendererUserPorts.mental ray.1.0

// This function demonstrates how to find a a list of on-the-fly shader definitions 

function FindOnTheFlyDefs ()

{

	var aOTFDefs = new Array();

	var e = new Enumerator(Application.ShaderDefinitions);

	for (; !e.atEnd(); e.moveNext()) {

		var oMaybe = e.item();

		if (oMaybe.ParserBased && !oMaybe.DefinitionPath) {

			aOTFDefs.push(oMaybe);

		}

	}

	// Write out results

	if (aOTFDefs.length) {

		Application.LogMessage("Found "+aOTFDefs.length+" on-the-fly definition(s): "+aOTFDefs.join(", "));

	} else {

		Application.LogMessage("No on-the-fly definitions found");

	}

}

// This function creates a bogus shader definition on the fly and returns its ProgID

function CreateDefOnTheFly () 

{

	var otmpShaderDef = XSIFactory.CreateShaderDef("Gardiner", "Chauncey", 1, 0);

	otmpShaderDef.Category = "Test Shaders";

	// family

	otmpShaderDef.AddShaderFamily("mrTexture");

	// paramdef options (in)

	var otmpShadPDefOpts = XSIFactory.CreateShaderParamDefOptions();

	otmpShadPDefOpts.SetTexturable(true);

	otmpShadPDefOpts.SetShortName("squelch");

	// paramdef (in)

	var otmpInParams = otmpShaderDef.InputParamDefs;

	otmpInParams.AddParamDef("squerch", siColorParameterType, otmpShadPDefOpts);

	// paramdef options (out)

	otmpShadPDefOpts = XSIFactory.CreateShaderParamDefOptions();

	otmpShadPDefOpts.SetTexturable(true);

	otmpShadPDefOpts.SetShortName("splosh");

	// paramdef (out)

	var otmpOutParams = otmpShaderDef.OutputParamDefs;

	otmpOutParams.AddParamDef("splish", siColorParameterType, otmpShadPDefOpts);

	// renderer

	var otmpRendDef = otmpShaderDef.AddRendererDef("whoops");

	otmpRendOpts = otmpRendDef.RendererOptions;

	otmpRendOpts.Set("plain", false);

	// attributes

	var otmpAttrs = otmpShaderDef.Attributes;

	otmpAttrs.Set("chuckle", "on");

	otmpAttrs.Set("nbr", 456123);

	// return the ProgID of the new shader

	return otmpShaderDef.ProgID;

}

関連項目

XSIFactory.CreateShaderDef XSIFactory.CreateShaderParamDefOptions XSIApplication.ShaderDefinitions XSIApplication.GetShaderDef