imrShader.h

Go to the documentation of this file.
00001 /*==============================================================================
00002 
00003   file:     imrShader.h
00004 
00005   author:   Daniel Levesque
00006 
00007   created:  10feb2003
00008 
00009   description:
00010 
00011     Interface definition for mental ray shaders.
00012 
00013   modified: 
00014 
00015 
00016 (c) 2003 Autodesk
00017 ==============================================================================*/
00018 #pragma once
00019 
00020 #include "..\tab.h"
00021 #include "..\maxtypes.h"
00022 #include "..\BaseInterface.h"
00023 #include "..\strclass.h"
00024 
00025 // forward declarations
00026 class imrShaderClassDesc;
00027 class IParamBlock2;
00028 class ReferenceTarget;
00029 
00030 // Interface ID for imrShader interface
00031 #define IMRSHADER_INTERFACE_ID Interface_ID(0x3b2f7b97, 0x5766e45)
00032 
00033 //==============================================================================
00034 // class imrShader
00035 //
00036 // Abstract class from which the mental ray shaders are derived.
00037 //
00038 // 3rd parties must not derive from this interface.
00039 //
00040 // This interface is implemented by both material plugins (class Mtl) and texture
00041 // map plugins (class Texmap). To query this interface from a material or texture
00042 // map plugin, use the GetIMRShader() and IsIMRShader() functions below.
00043 //
00044 //==============================================================================
00045 class imrShader : public BaseInterface {
00046 
00047 public:
00048 
00049     // Naming methods
00050     virtual void SetName(const MCHAR* name) = 0;
00051     virtual const MCHAR* GetName() = 0;
00052     virtual MSTR GetFullName() = 0;
00053 
00054     // Returns the class descriptor of this shader.
00055     virtual imrShaderClassDesc& GetClassDesc() = 0;
00056 
00057     // Access to the four main parameter blocks
00058     virtual IParamBlock2* GetResultsParamBlock() = 0;
00059     virtual IParamBlock2* GetParametersParamBlock() = 0;
00060     virtual IParamBlock2* GetConnectionsParamBlock() = 0;
00061 
00062     // Called when WM_HELP is received by the shader editor. Show shader help
00063     // and return true, or return false for default handling.
00064     virtual bool HandleHelp() = 0;
00065 
00066     // Returns the ReferenceTarget associated with the given shader. Class imrShader
00067     // does not derive from ReferenceTarget, but its implementation does.
00068     // This method is necessary if the client wishes to create a reference to the
00069     // shader.
00070     virtual ReferenceTarget& GetReferenceTarget() = 0;
00071 
00072     // Controls whether this shader was created for custom translation.
00073     // USED INTERNALLY.
00074     virtual bool IsCustomTranslationShader() = 0;
00075     virtual void SetCustomTranslationShader(bool val) = 0;
00076 
00077     // -- from BaseInterface
00078     virtual Interface_ID GetID();
00079 };
00080 
00081 inline Interface_ID imrShader::GetID() {
00082 
00083     return IMRSHADER_INTERFACE_ID;
00084 }
00085 
00086 
00087 //==============================================================================
00088 // GetIMRShader()
00089 //
00090 // Queries and returns the imrShader interface on an object. Returns NULL if
00091 // the given object is _not_ a mental ray shader.
00092 //==============================================================================
00093 inline imrShader* GetIMRShader(InterfaceServer* iserver) {
00094 
00095     if(iserver == NULL)
00096         return NULL;
00097     else
00098         return static_cast<imrShader*>(iserver->GetInterface(IMRSHADER_INTERFACE_ID));
00099 }
00100 
00101 //==============================================================================
00102 // IsIMRShader()
00103 //
00104 // Returns whether an object implements the imrShader interface (i.e. returns
00105 // whether an object _is_ a mental ray shader).
00106 //==============================================================================
00107 inline bool IsIMRShader(InterfaceServer* iserver) {
00108 
00109     return (GetIMRShader(iserver) != NULL);
00110 }
00111 
00112 //==============================================================================
00113 // GetReferenceTarget()
00114 //
00115 // Converts a mental ray shader back to a reference target.
00116 //==============================================================================
00117 inline ReferenceTarget* GetReferenceTarget(imrShader* shader) {
00118 
00119     return ((shader != NULL) ? &shader->GetReferenceTarget() : NULL);
00120 }
00121 
00122