ShaderArrayParamDef

Object Hierarchy | Related C++ Class: ShaderArrayParamDef

Inheritance

SIObject

ShaderParamDef

ShaderArrayParamDef

Introduced

v9.0 (2011)

Categories

ICE Shaders

Description

This object represents a definition for a ShaderArrayParameter instance. It allows you to set and get the array elements contained by this shader parameter (ShaderArrayParamDef.ItemInitialValues, which returns a ValueMap object that you can populate or query).

To create a ShaderArrayParamDef object, use the ShaderParamDefContainer.AddArrayParamDef method when adding a new parameter definition to the shader parameter definition container.

Methods

IsClassOf operator IsEqualTo operator    
       

Properties

Application Attributes operator Capabilities operator Categories
DataType operator DefaultValue operator DisplayName operator FullName operator
HasDefaultValue operator Help IsArray operator IsInput operator
IsOutput operator IsStructure operator ItemDef operator ItemInitialCount operator
ItemInitialValues operator ItemName operator MainPort operator MaxValue operator
MinValue operator Name operator NestedObjects Origin
OriginPath Parent StaticArray operator SuggestedMaxValue operator
SuggestedMinValue operator Texturable operator Type operator  
       

Examples

JScript Example

/* 
        This example demonstrates how to create a dynamic shader definition 
        with an input array parameter and then populate the array using the
        ValueMap object created via the ItemInitialValues property.
*/
app = Application;
app.NewScene("", false);
var oShaderDef = XSIFactory.CreateShaderDef("MyParser", "MyArrayDemo", 1, 0);
oShaderDef.AddShaderFamily(siShaderFamilyTexture);
app.LogMessage("Shader definition name: " + oShaderDef.Name);
// Set up shader parameter definition options to use with new input parameter
oShaderInParamDefOptions = XSIFactory.CreateShaderParamDefOptions();
oShaderInParamDefOptions.SetAnimatable(false);
oShaderInParamDefOptions.SetTexturable(true);
oShaderInParamDefOptions.SetInspectable(true);
oShaderInParamDefOptions.SetShortName("Fluffy Bunnies");
// Add input parameter to definition
oInputParams = oShaderDef.InputParamDefs;
var oArrayParamDef = oInputParams.AddArrayParamDef("flurry", siScalarParameterType, oShaderInParamDefOptions);
// Make it an array of 6 items and populate the array via the ValueMap interface
oArrayParamDef.ItemInitialCount = 6;
var oValueMap = oArrayParamDef.ItemInitialValues;
oValueMap.Set("a", 0);
oValueMap.Set("b", 8);
oValueMap.Set("c", 16);
oValueMap.Set("d", 32);
oValueMap.Set("e", 64);
oValueMap.Set("f", 128);
// Now print info to see what we have
for (var i=0; i<oShaderDef.InputParamDefs.Definitions.Count; i++) {
        LogParamInfo("\t", oShaderDef.InputParamDefs.Definitions.Item(i));
}       
// INFO : Shader definition name: MyParser.MyArrayDemo.1.0
// INFO :       Parameter name: Fluffy Bunnies
// INFO :       ClassName: ShaderArrayParamDef
// INFO :       Family: 65
// INFO :       Yes, I'm an array!
// INFO :       I'm an INPUT parameter
// INFO :               Parameter name: Item
// INFO :               ClassName: ShaderStructParamDef
// INFO :               Family: 3
// INFO :               I'm an INPUT parameter
// INFO :               ItemName: Item
// INFO :               ItemInitialCount: 6
// INFO :               ItemInitialValues: 
// INFO :                       Names: a, b, c, d, e, f
// INFO :                       Values: 0, 8, 16, 32, 64, 128
// Convenience function to log info iteratively
function LogParamInfo( in_indent, in_paramdef )
{
        app.LogMessage(in_indent + "Parameter name: " + in_paramdef.DisplayName);
        app.LogMessage(in_indent + "ClassName: " + app.ClassName(in_paramdef));
        app.LogMessage(in_indent + "Family: " + in_paramdef.DataType);
        if (in_paramdef.IsArray) {
                app.LogMessage(in_indent + "Yes, I'm an array!");
        }
        if (in_paramdef.IsInput) {
                app.LogMessage(in_indent + "I'm an INPUT parameter");
        }
        if (in_paramdef.IsOutput) {
                app.LogMessage(in_indent + "I'm an OUTPUT parameter");
        }
        if (in_paramdef.DataType == siShaderDataTypeArray) {
                LogParamInfo(in_indent + "\t", in_paramdef.ItemDef);
                in_indent += "\t";
                app.LogMessage(in_indent + "ItemName: " + in_paramdef.ItemName);
                if (in_paramdef.StaticArray) {
                        app.LogMessage(in_indent + "Is a Static Array");
                }
                app.LogMessage(in_indent + "ItemInitialCount: " + in_paramdef.ItemInitialCount);
                if (in_paramdef.ItemInitialCount) {
                        app.LogMessage(in_indent + "ItemInitialValues: ");
                        var vbaInitNames = new VBArray(in_paramdef.ItemInitialValues.Names);
                        var aInitNames = vbaInitNames.toArray();
                        var vbaInitValues = new VBArray(in_paramdef.ItemInitialValues.Values);
                        var aInitValues = vbaInitValues.toArray();
                        app.LogMessage(in_indent + "\tNames: " + aInitNames.join(", "));
                        app.LogMessage(in_indent + "\tValues: " + aInitValues.join(", "));
                }
        }
}

See Also

ShaderParamDefContainer.AddParamDef ShaderParamDefContainer.AddArrayParamDef ShaderParameter.Definition ShaderParamDefContainer ShaderStructParamDef Shader Definition examples installed with Softimage Shader Parser examples installed with Softimage