mrShaderFilter Class Reference
 
 
 
mrShaderFilter Class Reference

This reference page is linked to from the following overview topics: Mental Ray Classes.


#include <mrShaderFilter.h>

Inheritance diagram for mrShaderFilter:
IMtlBrowserFilter PBValidator BaseInterface InterfaceServer InterfaceServer MaxHeapOperators MaxHeapOperators

Public Member Functions

  mrShaderFilter (unsigned int applyTypes, ParamType2 paramType, bool acceptStructs)
virtual  ~mrShaderFilter ()
bool  ValidType (ParamType2 type)
virtual const MCHAR *  FilterName ()
  Returns the name of the filter.
virtual bool  Enabled ()
  Returns if this filter is enabled.
virtual void  Enable (bool enable)
  Used to enable/disable this filter.
virtual void  Registered ()
  Called when this filter is added to the manager.
virtual void  Unregistered ()
  Called when a filter is removed from the manager.
virtual bool  Include (MtlBase &mtlBase, DWORD flags)
  Returns whether the given material/map should be included in the browser, when browsing for existing materials/maps.
virtual bool  Include (ClassDesc &classDesc, DWORD flags)
  Returns whether the given material/map should be included in the browser, when browsing for 'new'.
virtual BOOL  Validate (PB2Value &v)
virtual BOOL  Validate (PB2Value &v, ReferenceMaker *owner, ParamID id, int tabIndex)
virtual void  DeleteThis ()
virtual BaseInterface GetInterface (Interface_ID id)

Constructor & Destructor Documentation

mrShaderFilter ( unsigned int  applyTypes,
ParamType2  paramType,
bool  acceptStructs 
)
: m_enabled(true),
  m_applyTypes(applyTypes),
  m_paramType(paramType),
  m_acceptStructs(acceptStructs)
{
}
~mrShaderFilter ( ) [virtual]
                                {

}

Member Function Documentation

bool ValidType ( ParamType2  type )
{
        int choice = (int)m_paramType;
        switch(choice)
        {
        case TYPE_MAX_TYPE:
                return true;

        // Casts to more complex types are acceptable
        case TYPE_RGBA:
        case TYPE_FRGBA:
                return ((type == TYPE_RGBA) || (type == TYPE_FRGBA));

        case TYPE_POINT3:
        case TYPE_POINT4:
                return ((type == TYPE_RGBA)
                        || (type == TYPE_FRGBA)
                        || (type == TYPE_POINT3)
                        || (type == TYPE_POINT4));

        case TYPE_FLOAT:
                return ((type == TYPE_RGBA)
                        || (type == TYPE_FRGBA)
                        || (type == TYPE_POINT3)
                        || (type == TYPE_FLOAT));

        default:
                return (type == m_paramType);
        }
}
const MCHAR * FilterName ( ) [virtual]

Returns the name of the filter.

Implements IMtlBrowserFilter.

                                        {

        return _M("mental ray: Shader Filter");
}
bool Enabled ( ) [virtual]

Returns if this filter is enabled.

The filter manager will not call disabled filters.

Returns:
true if this filter should be applied

Implements IMtlBrowserFilter.

                             {

        return m_enabled;
}
void Enable ( bool  enable ) [virtual]

Used to enable/disable this filter.

Parameters:
enable - if false, disable this filter by returning false from Enabled

Implements IMtlBrowserFilter.

                                       {

        m_enabled = enable;
}
void Registered ( ) [virtual]

Called when this filter is added to the manager.

Implements IMtlBrowserFilter.

                                {

        // do nothing
}
void Unregistered ( ) [virtual]

Called when a filter is removed from the manager.

Implements IMtlBrowserFilter.

                                  {

        // do nothing
}
bool Include ( MtlBase mtlBase,
DWORD  flags 
) [virtual]

Returns whether the given material/map should be included in the browser, when browsing for existing materials/maps.

Parameters:
mtlBase - The material/texmap to be filtered
flags - See the List of Material Browser Flags.
Returns:
true if this material should be included in the browser

Implements IMtlBrowserFilter.

{
        Interface* ip = GetCOREInterface();
        if (!ip) {
                return false;
        }
        // Validate using the class ID
        ClassDesc* classDesc = ip->GetDllDir().ClassDir().FindClass( mtlBase.SuperClassID(), mtlBase.ClassID() );
        DbgAssert(classDesc != NULL);
        if(classDesc != NULL) {
                return Include(*classDesc, flags);
        }
        else {
                return true;
        }
}
bool Include ( ClassDesc classDesc,
DWORD  flags 
) [virtual]

Returns whether the given material/map should be included in the browser, when browsing for 'new'.

Parameters:
classDesc - The material/map class descriptor to be filtered
flags - See the List of Material Browser Flags.
Returns:
true if this material should be included in the browser

Implements IMtlBrowserFilter.

{
        return (ValidateApplyType(classDesc) && ValidateReturnType(classDesc));
}
BOOL Validate ( PB2Value v ) [virtual]
Remarks:
Returns TRUE if the given PB2Value if valid; otherwise FALSE.
Parameters:
PB2Value& v

The value to check.

Implements PBValidator.

                                         {

        ReferenceTarget* refTarg = v.r;
        if((refTarg != NULL) && IsMtlBase(refTarg)) {
                MtlBase* mtlBase = static_cast<MtlBase*>(refTarg);
                return Include(*mtlBase, 0);
        }
        else {
                // Null values are acceptable
                return TRUE;
        }
}
BOOL Validate ( PB2Value v,
ReferenceMaker owner,
ParamID  id,
int  tabIndex 
) [virtual]
Remarks:
A variant of Validate() method to PBValidate which supplies more context than the original Validate(), effectively giving the same context information as the Set() & Get() methods in a PBAccessor.
Parameters:
PB2Value& v

The value to check.

ReferenceMaker* owner

Points to the owner of the parameter.

ParamID id

The permanent ID of the parameter.

int tabIndex

If the parameter is a Tab<> this is the zero based index of the parameter in the table.

Reimplemented from PBValidator.

{
        return Validate(v);
}
void DeleteThis ( ) [virtual]
Remarks:
This method that can be used to destroy dynamically allocated instances of this class.
Default Implementation:
{ }

Reimplemented from PBValidator.

                                {

        delete this;
}
BaseInterface * GetInterface ( Interface_ID  id ) [virtual]
Remarks:
Returns a pointer to the interface whose ID is specified.
Parameters:
Interface_ID id

The ID of the interface to return.
Default Implementation:
{ return NULL; }

Reimplemented from InterfaceServer.

                                                           {

        if(id == MRSHADERFILTER_INTERFACEID) {
                return this;
        }
        else if(id == IMTLBROWSERFILTER_INTERFACEID) {
                return static_cast<IMtlBrowserFilter*>(this);
        }
        else {
                return PBValidator::GetInterface(id);
        }
}