Parameter.IsSupportedInstanceValue

Introduced

v5.0

Description

Returns true if the value is supported by the parameter. For example, many shaders have a parameter of input type of siTextureSpaceParameterType (see Shader.GetShaderInputType) but may only support vertex color Property objects. This method will support passing the name of the property or the actual property itself.

Scripting Syntax

oBoolean = Parameter.IsSupportedInstanceValue( Object, Value );

Return Value

Boolean

Parameters

Parameter Type Description
Object Object such as a X3DObject Object using the shared property
Value Variant New value for instance.

Examples

JScript Example

/*
        This example demonstrates how to set a map lookup shader on a parameter 
        and then test it for supported maps
*/
NewScene( null, false );
// Create a grid with a map lookup shader
var root = Application.ActiveProject.ActiveScene.Root;
var grid = root.AddGeometry( "Grid", "MeshSurface" );
BlendInPresets( "Image", grid, 1, false );
CreateProjection( grid, siTxtSpherical, siTxtDefaultSpherical, "TxtSupport", "TxtProjection" );
var filename = Application.InstallationPath( siFactoryPath ) + "\\Data\\XSI_SAMPLES\\Pictures\\xsilogo.jpg";
var imageclip = CreateImageClip( filename, "XSILogo" );
var mat = grid.Material;
var shaders = mat.FindShaders( siShaderFilter );
var textureshader = shaders("Image");
var txtparam = textureshader.Parameters("tspace_id");
// Don't want to deal with cluster to find UVW prop
txtparam.SetInstanceValue( grid, "TxtProjection" );
var txtuvw = txtparam.GetInstanceValue( grid, true );           // true == bind to object
var cav = grid.ActivePrimitive.Geometry.AddVertexColor();
var weightmap = CreateWeightMap( "WeightMap", grid, "Weight_Map" )(0);
var txtmap = Create2DMap( grid, "Texture_Map", siDefaultPropagation )(0);
txtmap.Parameters("ImageClipName").Value = imageclip.Name;
txtmap.Parameters("UVReference").SetInstanceValue( grid, txtuvw );
var polycls = grid.ActivePrimitive.Geometry.AddCluster( siPolygonCluster,"RenderMapCluster" );
var rendermap = polycls.AddProperty( "RenderMap" );
// Replace image shader with map lookup 
var ambient_blend = shaders("ambient_blend");
var maplookup = ambient_blend.Parameters("color1").ConnectFromProgID( "Softimage.map_lookup_color" );
var mapparam = maplookup.Parameters("map");
// Setup maps array
var maps = Array( weightmap, cav, txtuvw, txtmap, rendermap );
// Test map lookup shader for supported maps
for ( var i = 0; i < maps.length; i++ ) {
        if ( mapparam.IsSupportedInstanceValue( grid, maps[i] ) ) {
                Application.LogMessage( mapparam.FullName + " parameter supports objects of "+ maps[i].Type );
        } else {
                Application.LogMessage( mapparam.FullName + " parameter does not supports objects of "+ maps[i].Type );
        }
}
// Expected results:
//INFO : grid.Scene_Material1.Phong.ambient_blend.Softimage.map parameter supports objects of wtmap
//INFO : grid.Scene_Material1.Phong.ambient_blend.Softimage.map parameter supports objects of vertexcolor
//INFO : grid.Scene_Material1.Phong.ambient_blend.Softimage.map parameter supports objects of uvspace
//INFO : grid.Scene_Material1.Phong.ambient_blend.Softimage.map parameter supports objects of TextureProp
//INFO : grid.Scene_Material1.Phong.ambient_blend.Softimage.map parameter does not supports objects of rendermap

See Also

Parameter.GetInstanceValue Parameter.SetInstanceValue Parameter.HasInstanceValue