/*
This example shows how to set up a texture shader on a sphere
and then get information about one of its parameters.
*/
// Create an object with a texture shader
NewScene( null, false );
var root = Application.ActiveProject.ActiveScene.Root;
var model = root.AddModel();
model.name = "MyModel";
var object = model.AddGeometry( "Sphere", "MeshSurface" );
BlendInPresets( "Image", object, 1, false );
CreateProjection( object, siTxtSpherical, siTxtDefaultSpherical, "TxtSupport", "TxtProjection" );
var filename = Application.InstallationPath( siFactoryPath ) +
"\\Data\\XSI_SAMPLES\\Pictures\\xsilogo.jpg";
var imageclip = CreateImageClip( filename, "XSILogo" );
// Set up the texture space on texture shader
var mat = object.Material;
var textureshader = object.Material.CurrentTexture;
// GetShaderParameterType returns a SafeArray, so convert it to a JS array
var vbShaderInfo = textureshader.GetShaderParameterType("tex");
var shaderInfo = vbShaderInfo.toArray();
Application.LogMessage( shaderInfo[0] );
Application.LogMessage( ShaderParameterTypeAsText(shaderInfo[1]) );
// Expected results:
// INFO : True
// INFO : siTextureParameterType
// Convenience function to get a human-readable string
function ShaderParameterTypeAsText(type)
{
switch (type)
{
case siUnknownParameterType : return "siUnknownParameterType";
case siBooleanParameterType : return "siBooleanParameterType";
case siColorParameterType : return "siColorParameterType";
case siDataParameterType : return "siDataParameterType";
case siIntegerParameterType : return "siIntegerParameterType";
case siLensParameterType : return "siLensParameterType";
case siLightParameterType : return "siLightParameterType";
case siMaterialParameterType : return "siMaterialParameterType";
case siMatrixParameterType : return "siMatrixParameterType";
case siModelParameterType : return "siModelParameterType";
case siRealTimeParameterType : return "siRealTimeParameterType";
case siReferenceParameterType : return "siReferenceParameterType";
case siScalarParameterType : return "siScalarParameterType";
case siShaderParameterType : return "siShaderParameterType";
case siStringParameterType : return "siStringParameterType";
case siStructParameterType : return "siStructParameterType";
case siTextureParameterType : return "siTextureParameterType";
case siTextureSpaceParameterType : return "siTextureSpaceParameterType";
case siVectorParameterType : return "siVectorParameterType";
default: return type;
}
} |