The Filter object represents an instance of a Softimage filter. Filters are used by Softimage interactive tools and OM objects for validating the use of a set of objects in a given context. Softimage already defines a set of native filters available to users and can be extended with custom filter objects.
Custom filters are defined with a plug-in which can be either compiled or scripted as described in cus_addons Distributing Customized Items for the detailed workflow.
Like native filters, custom filters can also be used with other base filter functions defined in the SDK such as SIFilter, X3DObjectCollection.Filter, etc.
- Since:
- 4.0
- Example:
- Demonstrates how to work with filters in Softimage
#include <xsi_application.h>
#include <xsi_filter.h>
#include <xsi_model.h>
using namespace XSI;
static TestFilter( const CString& in_strFilter, const CRef& in_ref )
{
Application app;
Filter filter = app.GetFilters().GetItem( in_strFilter );
bool bApplicable = filter.IsApplicable(in_ref);
bool bMatch = filter.Match(in_ref);
app.LogMessage( L"*** Filter: " + filter.GetName() );
app.LogMessage( L" Target: " + SIObject(in_ref).GetName() );
app.LogMessage( L" Applicable: " + CValue(bApplicable).GetAsText() );
app.LogMessage( L" Match: " + CValue(bMatch).GetAsText() );
}
static TestFilter( const CString& in_strFilter, const CString& in_strTest, const CRefArray& in_array )
{
Application app;
Filter filter = app.GetFilters().GetItem( in_strFilter );
bool bApplicable = filter.IsApplicable(in_array);
bool bMatch = filter.Match(in_array);
CRefArray subArray = filter.Subset(in_array);
app.LogMessage( L"*** Filter: " + filter.GetName() );
app.LogMessage( L" Target: " + in_strTest + L" count: " + CValue((LONG)in_array.GetCount()).GetAsText() );
app.LogMessage( L" Applicable: " + CValue(bApplicable).GetAsText() );
app.LogMessage( L" Match: " + CValue(bMatch).GetAsText() );
app.LogMessage( L" Subset: " + CValue(subArray.GetCount()).GetAsText() );
}
Application app;
CRefArray filterArray = app.GetFilters();
for (LONG i=0; i<filterArray.GetCount(); i++)
{
Filter filter(filterArray[i]);
app.LogMessage( filter.GetName() );
}
Model root = app.GetActiveSceneRoot();
X3DObject sphere;
root.AddGeometry( L"Sphere", L"MeshSurface", L"", sphere );
TestFilter( L"Object", root );
TestFilter( L"PolygonMesh", sphere );
CRefArray array(root.GetChildren());
CString strTest(root.GetName() + L" children");
TestFilter( L"Object", strTest, array );
TestFilter( L"Light", strTest, array );
TestFilter( L"Camera", strTest, array );
TestFilter( L"PolygonMesh", strTest, array );
array = root.GetProperties();
strTest = root.GetName() + L" properties";
TestFilter( L"Object", strTest, array );
TestFilter( L"Light", strTest, array );