added everything
This commit is contained in:
72
lib/maxsdk70/include/mentalray/imrAdvancedTranslation.h
Executable file
72
lib/maxsdk70/include/mentalray/imrAdvancedTranslation.h
Executable file
@ -0,0 +1,72 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: imrAdvancedTranslation.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 28 April 2004
|
||||
|
||||
description:
|
||||
|
||||
Defition of the mental ray advanced shader translation interface.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2003 Autodesk
|
||||
==============================================================================*/
|
||||
#ifndef _IMRADVANCEDTRANSLATION_H_
|
||||
#define _IMRADVANCEDTRANSLATION_H_
|
||||
|
||||
//==============================================================================
|
||||
// class imrAdvancedTranslation
|
||||
//
|
||||
// A reference to this class is passed to imrShaderTranslation::TranslateParameters_Advanced().
|
||||
//
|
||||
// All methods in the class are an _exact_ match with a function in the mental ray API.
|
||||
// They need to be used in _exactly_ the same way as the mental ray API equivalent.
|
||||
// (For example: all the strings passed to the mental ray API need to be allocated using mi_mem_strdup()).
|
||||
//
|
||||
// For documentation on each method, see the MENTAL RAY MANUAL.
|
||||
//==============================================================================
|
||||
class imrAdvancedTranslation {
|
||||
|
||||
public:
|
||||
|
||||
typedef enum {
|
||||
miTYPE_BOOLEAN = 0, /* simple types: used for */
|
||||
miTYPE_INTEGER, /* returns and parameters */
|
||||
miTYPE_SCALAR,
|
||||
miTYPE_STRING,
|
||||
miTYPE_COLOR,
|
||||
miTYPE_VECTOR,
|
||||
miTYPE_TRANSFORM,
|
||||
miTYPE_SHADER, /* complex types: used for */
|
||||
miTYPE_SCALAR_TEX, /* parameters only */
|
||||
miTYPE_COLOR_TEX,
|
||||
miTYPE_VECTOR_TEX,
|
||||
miTYPE_LIGHT,
|
||||
miTYPE_STRUCT,
|
||||
miTYPE_ARRAY,
|
||||
miTYPE_TEX,
|
||||
miTYPE_MATERIAL, /* phenomenon types */
|
||||
miTYPE_GEOMETRY,
|
||||
miTYPE_LIGHTPROFILE, /* light profiles as args */
|
||||
miTYPE_DATA, /* free-form user data */
|
||||
miNTYPES
|
||||
} miParam_type;
|
||||
|
||||
typedef enum {miFALSE=0, miTRUE=1} miBoolean;
|
||||
|
||||
virtual miBoolean mi_api_parameter_name (char *) = 0;
|
||||
virtual miBoolean mi_api_parameter_value (miParam_type, void *, int *, int *) = 0;
|
||||
virtual miBoolean mi_api_parameter_push (miBoolean) = 0;
|
||||
virtual miBoolean mi_api_parameter_pop (void) = 0;
|
||||
virtual miBoolean mi_api_new_array_element (void) = 0;
|
||||
|
||||
virtual char* _mi_mem_strdup(const char*) = 0;
|
||||
virtual void _mi_mem_release(void*) = 0;
|
||||
virtual void* _mi_mem_allocate(int) = 0;
|
||||
};
|
||||
|
||||
#endif
|
97
lib/maxsdk70/include/mentalray/imrMaterialCustAttrib.h
Executable file
97
lib/maxsdk70/include/mentalray/imrMaterialCustAttrib.h
Executable file
@ -0,0 +1,97 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: imrMaterialCustAttrib.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 26sept2002
|
||||
|
||||
description:
|
||||
|
||||
Interface definition for the mental ray custom attributes. This custom
|
||||
attributes is used to override the default translation of a MAX materal
|
||||
by assigning custom shaders.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2002 Autodesk
|
||||
==============================================================================*/
|
||||
#ifndef _IMRMATERIALCUSTATTRIB_H_
|
||||
#define _IMRMATERIALCUSTATTRIB_H_
|
||||
|
||||
#include <CustAttrib.h>
|
||||
|
||||
#define MRMATERIALCUSTATTRIB_CLASS_ID Class_ID(0x218ab459, 0x25dc8980)
|
||||
|
||||
class Texmap;
|
||||
|
||||
//==============================================================================
|
||||
// class imrMaterialCustAttrib
|
||||
//
|
||||
// The mental ray material custom attributes. Used to assign custom shaders
|
||||
// to MAX materals, overriding the default translation.
|
||||
//
|
||||
//==============================================================================
|
||||
class imrMaterialCustAttrib : public CustAttrib {
|
||||
|
||||
public:
|
||||
|
||||
enum ShaderSlot {
|
||||
kShaderSlot_Surface,
|
||||
kShaderSlot_Displacement,
|
||||
kShaderSlot_Shadow,
|
||||
kShaderSlot_Volume,
|
||||
kShaderSlot_Environment,
|
||||
kShaderSlot_Contour,
|
||||
kShaderSlot_Photon,
|
||||
kShaderSlot_PhotonVolume,
|
||||
kShaderSlot_LightMap,
|
||||
|
||||
kShaderSlot_Count
|
||||
};
|
||||
|
||||
// Gets/Sets the "Opaque" flag at the given time
|
||||
virtual bool GetOpaque(TimeValue t = 0) const = 0;
|
||||
virtual void SetOpaque(bool val, TimeValue t = 0) = 0;
|
||||
|
||||
// Gets/Sets the different shaders.
|
||||
virtual Texmap* GetShader(ShaderSlot slot) const = 0;
|
||||
virtual void SetShader(ShaderSlot slot, Texmap* shader) = 0;
|
||||
|
||||
// Enables/Disables the locks for each slot
|
||||
virtual bool GetLockEnabled(ShaderSlot slot) const = 0;
|
||||
virtual void SetLockEnabled(ShaderSlot slot, bool enable) = 0;
|
||||
|
||||
// Turns the locks for each slot ON/OFF.
|
||||
virtual bool GetShaderLocked(ShaderSlot slot) const = 0;
|
||||
virtual void SetShaderLocked(ShaderSlot slot, bool lock) = 0;
|
||||
|
||||
// Returns whether the given shader slot is locked. Shader locks that are
|
||||
// disabled are never ON, regardless of the value returned by GetShaderLock()
|
||||
virtual bool IsShaderLocked(ShaderSlot slot) const = 0;
|
||||
};
|
||||
|
||||
// Returns the mental ray custom attribute associate with the given material,
|
||||
// if it one exists.
|
||||
// Cut and paste in your source file to use it.
|
||||
/*
|
||||
imrMaterialCustAttrib* Get_mrMaterialCustAttrib(MtlBase* rt) {
|
||||
|
||||
ICustAttribContainer* cc = rt->GetCustAttribContainer();
|
||||
if(cc != NULL) {
|
||||
int nbCustAttribs = cc->GetNumCustAttribs();
|
||||
for(int i = 0; i < nbCustAttribs; ++i) {
|
||||
|
||||
CustAttrib* ca = cc->GetCustAttrib(i);
|
||||
if((ca != NULL) && (ca->ClassID() == MRMATERIALCUSTATTRIB_CLASS_ID)) {
|
||||
return static_cast<imrMaterialCustAttrib*>(ca);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
116
lib/maxsdk70/include/mentalray/imrPreferences.h
Executable file
116
lib/maxsdk70/include/mentalray/imrPreferences.h
Executable file
@ -0,0 +1,116 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: imrPreferences.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 26aug2002
|
||||
|
||||
description:
|
||||
|
||||
Interface for accessing the mental ray preferences.
|
||||
|
||||
PERFORMANCE NOTICE:
|
||||
Most the the methods of the preferences interface directly access a .ini
|
||||
file to get/set the preference values. It is therefore important to
|
||||
minimize calls to this interface in performance critical code.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2002 Autodesk
|
||||
==============================================================================*/
|
||||
#ifndef _IMRPREFERENCES_H_
|
||||
#define _IMRPREFERENCES_H_
|
||||
|
||||
#include <Windows.h>
|
||||
#include <max.h>
|
||||
#include <ifnpub.h>
|
||||
|
||||
#define IMRPREFERENCES_INTERFACEID Interface_ID(0x594511cc, 0x15505bac)
|
||||
|
||||
//==============================================================================
|
||||
// class imrPreferences
|
||||
//
|
||||
// This interface provides access to the mental ray preferences.
|
||||
//==============================================================================
|
||||
class imrPreferences : public FPStaticInterface {
|
||||
|
||||
public:
|
||||
|
||||
// Mode used for clearing the VFB before rendering
|
||||
enum VFBClearMode {
|
||||
kVFBClear_None, // Do not clear the VFB
|
||||
kVFBClear_OneLineOnTwo, // Clear every other line (1 line on 2)
|
||||
kVFBClear_All, // Clear the entire VFB
|
||||
};
|
||||
|
||||
// Register/unregister preference change callbacks
|
||||
typedef void(*mrPreferencesCallback)(void* param);
|
||||
virtual void RegisterChangeCallback(mrPreferencesCallback callback, void* param) = 0;
|
||||
virtual void UnRegisterChangeCallback(mrPreferencesCallback callback, void* param) = 0;
|
||||
|
||||
// Are the mental ray extensions ON/OFF?
|
||||
virtual bool GetMRExtensionsActive() const = 0;
|
||||
virtual void SetMRExtensionsActive(bool active) = 0;
|
||||
|
||||
// Is mental ray the default production renderer?
|
||||
virtual bool GetMRDefaultProductionRenderer() const = 0;
|
||||
virtual void SetMRDefaultProductionRenderer(bool val) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Message dialog verbosity & options, log file
|
||||
//
|
||||
|
||||
virtual bool GetMsgDlgOpenOnError() const = 0;
|
||||
virtual void SetMsgDlgOpenOnError(bool val) = 0;
|
||||
|
||||
virtual bool GetMsgVerbosity_Info() const = 0;
|
||||
virtual void SetMsgVerbosity_Info(bool val) = 0;
|
||||
virtual bool GetMsgVerbosity_Progress() const = 0;
|
||||
virtual void SetMsgVerbosity_Progress(bool val) = 0;
|
||||
virtual bool GetMsgVerbosity_Debug() const = 0;
|
||||
virtual void SetMsgVerbosity_Debug(bool val) = 0;
|
||||
|
||||
// Opens the message dialog
|
||||
virtual void OpenMessageDialog() const = 0;
|
||||
|
||||
// log file name
|
||||
virtual const TCHAR* GetLogFileName() const = 0;
|
||||
virtual void SetLogFileName(const TCHAR* filename) = 0;
|
||||
// log file ON
|
||||
virtual bool GetLogFileON() const = 0;
|
||||
virtual void SetLogFileON(bool on) = 0;
|
||||
// log file Append
|
||||
virtual bool GetLogFileAppend() const = 0;
|
||||
virtual void SetLogFileAppend(bool on) = 0;
|
||||
|
||||
//
|
||||
// Message dialog verbosity & options
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Rendering Options
|
||||
//
|
||||
|
||||
// Show brackets around the bucket(s) currently being rendered
|
||||
virtual bool GetShowRenderBrackets() const = 0;
|
||||
virtual void SetShowRenderBrackets(bool on) = 0;
|
||||
|
||||
// Get the mode used for clearing the VFB (virtual frame buffer) before render
|
||||
virtual VFBClearMode GetVFBClearMode() const = 0;
|
||||
virtual void SetVFBClearMode(VFBClearMode mode) = 0;
|
||||
|
||||
//
|
||||
// Rendering Options
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
|
||||
// Retrieve a pointer to the preferences interface
|
||||
inline imrPreferences* GetMRPreferences() {
|
||||
|
||||
return static_cast<imrPreferences*>(GetCOREInterface(IMRPREFERENCES_INTERFACEID));
|
||||
}
|
||||
|
||||
#endif
|
124
lib/maxsdk70/include/mentalray/imrShader.h
Executable file
124
lib/maxsdk70/include/mentalray/imrShader.h
Executable file
@ -0,0 +1,124 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: imrShader.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 10feb2003
|
||||
|
||||
description:
|
||||
|
||||
Interface definition for mental ray shaders.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2003 Autodesk
|
||||
==============================================================================*/
|
||||
#ifndef __IMRSHADER__H
|
||||
#define __IMRSHADER__H
|
||||
|
||||
#include <windows.h>
|
||||
#include <tab.h>
|
||||
#include <maxtypes.h>
|
||||
#include <BaseInterface.h>
|
||||
#include <strclass.h>
|
||||
|
||||
class imrShaderClassDesc;
|
||||
class IParamBlock2;
|
||||
class ReferenceTarget;
|
||||
|
||||
// Interface ID for imrShader interface
|
||||
#define IMRSHADER_INTERFACE_ID Interface_ID(0x3b2f7b97, 0x5766e45)
|
||||
|
||||
//==============================================================================
|
||||
// class imrShader
|
||||
//
|
||||
// Abstract class from which the mental ray shaders are derived.
|
||||
//
|
||||
// 3rd parties must not derive from this interface.
|
||||
//
|
||||
// This interface is implemented by both material plugins (class Mtl) and texture
|
||||
// map plugins (class Texmap). To query this interface from a material or texture
|
||||
// map plugin, use the GetIMRShader() and IsIMRShader() functions below.
|
||||
//
|
||||
//==============================================================================
|
||||
class imrShader : public BaseInterface {
|
||||
|
||||
public:
|
||||
|
||||
// Naming methods
|
||||
virtual void SetName(const TCHAR* name) = 0;
|
||||
virtual const TCHAR* GetName() = 0;
|
||||
virtual TSTR GetFullName() = 0;
|
||||
|
||||
// Returns the class descriptor of this shader.
|
||||
virtual imrShaderClassDesc& GetClassDesc() = 0;
|
||||
|
||||
// Access to the four main parameter blocks
|
||||
virtual IParamBlock2* GetResultsParamBlock() = 0;
|
||||
virtual IParamBlock2* GetParametersParamBlock() = 0;
|
||||
virtual IParamBlock2* GetConnectionsParamBlock() = 0;
|
||||
|
||||
// Called when WM_HELP is received by the shader editor. Show shader help
|
||||
// and return true, or return false for default handling.
|
||||
virtual bool HandleHelp() = 0;
|
||||
|
||||
// Returns the ReferenceTarget associated with the given shader. Class imrShader
|
||||
// does not derive from ReferenceTarget, but its implementation does.
|
||||
// This method is necessary if the client wishes to create a reference to the
|
||||
// shader.
|
||||
virtual ReferenceTarget& GetReferenceTarget() = 0;
|
||||
|
||||
// Controls whether this shader was created for custom translation.
|
||||
// USED INTERNALLY.
|
||||
virtual bool IsCustomTranslationShader() = 0;
|
||||
virtual void SetCustomTranslationShader(bool val) = 0;
|
||||
|
||||
// -- from BaseInterface
|
||||
virtual Interface_ID GetID();
|
||||
};
|
||||
|
||||
inline Interface_ID imrShader::GetID() {
|
||||
|
||||
return IMRSHADER_INTERFACE_ID;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// GetIMRShader()
|
||||
//
|
||||
// Queries and returns the imrShader interface on an object. Returns NULL if
|
||||
// the given object is _not_ a mental ray shader.
|
||||
//==============================================================================
|
||||
inline imrShader* GetIMRShader(InterfaceServer* iserver) {
|
||||
|
||||
if(iserver == NULL)
|
||||
return NULL;
|
||||
else
|
||||
return static_cast<imrShader*>(iserver->GetInterface(IMRSHADER_INTERFACE_ID));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// IsIMRShader()
|
||||
//
|
||||
// Returns whether an object implements the imrShader interface (i.e. returns
|
||||
// whether an object _is_ a mental ray shader).
|
||||
//==============================================================================
|
||||
inline bool IsIMRShader(InterfaceServer* iserver) {
|
||||
|
||||
return (GetIMRShader(iserver) != NULL);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// GetReferenceTarget()
|
||||
//
|
||||
// Converts a mental ray shader back to a reference target.
|
||||
//==============================================================================
|
||||
inline ReferenceTarget* GetReferenceTarget(imrShader* shader) {
|
||||
|
||||
return ((shader != NULL) ? &shader->GetReferenceTarget() : NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
157
lib/maxsdk70/include/mentalray/imrShaderClassDesc.h
Executable file
157
lib/maxsdk70/include/mentalray/imrShaderClassDesc.h
Executable file
@ -0,0 +1,157 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: imrShaderClassDesc.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 10feb2003
|
||||
|
||||
description:
|
||||
|
||||
Class descriptor for mental ray shaders.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2003 Autodesk
|
||||
==============================================================================*/
|
||||
#ifndef _IMRSHADERCLASSDESC_H_
|
||||
#define _IMRSHADERCLASSDESC_H_
|
||||
|
||||
#include <max.h>
|
||||
#include <iparamb2.h>
|
||||
|
||||
class imrShader;
|
||||
class mrShaderDesc;
|
||||
|
||||
//==============================================================================
|
||||
// class imrShaderClassDesc
|
||||
//
|
||||
// Class descriptor for a mental ray shader. Dynamically created for each shader
|
||||
// encountered in the .mi files during startup.
|
||||
//
|
||||
// This class derives from InterfaceServer to allow for future extensions.
|
||||
//==============================================================================
|
||||
class imrShaderClassDesc : public ClassDesc2, public InterfaceServer {
|
||||
|
||||
private:
|
||||
|
||||
// Apply types for this shader
|
||||
enum {
|
||||
// Types defined by the mental ray API
|
||||
kApply_Lens,
|
||||
kApply_Material,
|
||||
kApply_Light,
|
||||
kApply_Shadow,
|
||||
kApply_Environment,
|
||||
kApply_Volume,
|
||||
kApply_Texture,
|
||||
kApply_Photon,
|
||||
kApply_Geometry,
|
||||
kApply_Displace,
|
||||
kApply_PhotonEmitter,
|
||||
kApply_Output,
|
||||
kApply_LightMap,
|
||||
kApply_PhotonVol,
|
||||
kApply_Other,
|
||||
|
||||
// Additional types defined by the GUI attributes
|
||||
kApply_Bump,
|
||||
kApply_ContourShader,
|
||||
kApply_ContoutStore,
|
||||
kApply_ContourContrast,
|
||||
kApply_ContourOutput,
|
||||
kApply_Illum,
|
||||
kApply_PassMerge,
|
||||
|
||||
kApply_MtlPhen, // Shader is a material phenomenon
|
||||
|
||||
kApply_Count
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
// Apply type bits when compined in a single value
|
||||
enum ApplyFlags {
|
||||
// Types defined by the mental ray API
|
||||
kApplyFlag_Lens = (1 << kApply_Lens),
|
||||
kApplyFlag_Material = (1 << kApply_Material),
|
||||
kApplyFlag_Light = (1 << kApply_Light),
|
||||
kApplyFlag_Shadow = (1 << kApply_Shadow),
|
||||
kApplyFlag_Environment = (1 << kApply_Environment),
|
||||
kApplyFlag_Volume = (1 << kApply_Volume),
|
||||
kApplyFlag_Texture = (1 << kApply_Texture),
|
||||
kApplyFlag_Photon = (1 << kApply_Photon),
|
||||
kApplyFlag_Geometry = (1 << kApply_Geometry),
|
||||
kApplyFlag_Displace = (1 << kApply_Displace),
|
||||
kApplyFlag_PhotonEmitter = (1 << kApply_PhotonEmitter),
|
||||
kApplyFlag_Output = (1 << kApply_Output),
|
||||
kApplyFlag_LightMap = (1 << kApply_LightMap),
|
||||
kApplyFlag_PhotonVol = (1 << kApply_PhotonVol),
|
||||
kApplyFlag_Other = (1 << kApply_Other),
|
||||
|
||||
// Additional types defined by the GUI attributes
|
||||
//kApply_None, // Probably better remove this...
|
||||
kApplyFlag_Bump = (1 << kApply_Bump),
|
||||
kApplyFlag_ContourShader = (1 << kApply_ContourShader),
|
||||
kApplyFlag_ContourStore = (1 << kApply_ContoutStore),
|
||||
kApplyFlag_ContourContrast = (1 << kApply_ContourContrast),
|
||||
kApplyFlag_ContourOutput = (1 << kApply_ContourOutput),
|
||||
kApplyFlag_Illum = (1 << kApply_Illum),
|
||||
kApplyFlag_PassMerge = (1 << kApply_PassMerge),
|
||||
|
||||
kApplyFlag_MtlPhen = (1 << kApply_MtlPhen),
|
||||
|
||||
// All except mtl phenomenon
|
||||
kApplyFlag_All = (~0 & ~kApplyFlag_MtlPhen),
|
||||
|
||||
// Default type accepts texure, material, illum, bump
|
||||
kApplyFlag_Default = (kApplyFlag_Material | kApplyFlag_Texture | kApplyFlag_Illum | kApplyFlag_Bump),
|
||||
};
|
||||
|
||||
// Create a shader for the given apply type. The shader's default name will
|
||||
// match the apply type. Returns NULL if a bad apply type is given
|
||||
// virtual imrShader* CreateShader(ApplyType applyType) = 0;
|
||||
|
||||
// Same as ClassDesc::Create(), but returns a pointer to a shader instead of a void*
|
||||
virtual imrShader* CreateShader(bool loading = false) = 0;
|
||||
|
||||
// Get the types to which this shader may be applied (combination of
|
||||
// ApplyFlags values).
|
||||
virtual unsigned int GetApplyTypes() = 0;
|
||||
|
||||
// Get the shader descriptor for this class
|
||||
virtual mrShaderDesc& GetShaderDesc() = 0;
|
||||
|
||||
// Access to the Parameters PBDesc & sub-PBDescs
|
||||
virtual ParamBlockDesc2* GetParamPBDesc() = 0;
|
||||
virtual Tab<ParamBlockDesc2*>& GetParamSubPBDescs() = 0;
|
||||
|
||||
// Access to the Results PBDesc & sub-PBDescs
|
||||
virtual ParamBlockDesc2* GetResultPBDesc() = 0;
|
||||
virtual Tab<ParamBlockDesc2*>& GetResultPBDescs() = 0;
|
||||
|
||||
// Access to the Connestions PBDesc & sub-PBDescs
|
||||
virtual ParamBlockDesc2* GetConnectionPBDesc() = 0;
|
||||
virtual Tab<ParamBlockDesc2*>& GetConnectionSubPBDescs() = 0;
|
||||
|
||||
// Creates the auto param dialog for this shader
|
||||
virtual IAutoMParamDlg* CreateShaderParamDlgs(HWND hwMtlEdit, IMtlParams *imp, ReferenceTarget* obj) = 0;
|
||||
};
|
||||
|
||||
// Pass this command ID to ClassDesc::Execute(). The function will return
|
||||
// (GETIMRSHADERCLASSDESC_CMD+1) if the ClassDesc* can safely be cast to a imrShaderClassDesc*
|
||||
#define GETIMRSHADERCLASSDESC_CMD 0x984a860f
|
||||
|
||||
// Converts, if possible, a ClassDesc* to a imrShaderClassDesc*
|
||||
inline imrShaderClassDesc* Get_mrShaderClassDesc(ClassDesc* cd) {
|
||||
|
||||
if((cd != NULL) && (cd->Execute(GETIMRSHADERCLASSDESC_CMD) == (GETIMRSHADERCLASSDESC_CMD + 1))) {
|
||||
return static_cast<imrShaderClassDesc*>(cd);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
346
lib/maxsdk70/include/mentalray/imrShaderTranslation.h
Executable file
346
lib/maxsdk70/include/mentalray/imrShaderTranslation.h
Executable file
@ -0,0 +1,346 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: imrShaderTranslation.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 10feb2003
|
||||
|
||||
description:
|
||||
|
||||
Defition of the mental ray shader translation interface.
|
||||
|
||||
modified:
|
||||
|
||||
[dl] 28 April 2004. Added advanced translation of parameters, incremented
|
||||
interface IDs to distinguish between the old (MAX 6) interface and the new (MAX 7)
|
||||
interface.
|
||||
|
||||
<EFBFBD> 2004 Autodesk
|
||||
==============================================================================*/
|
||||
#ifndef _IMRSHADERTRANSLATION_H_
|
||||
#define _IMRSHADERTRANSLATION_H_
|
||||
|
||||
#include <mentalray\imrAdvancedTranslation.h>
|
||||
|
||||
#include <max.h>
|
||||
#include <BaseInterface.h>
|
||||
|
||||
class imrShader;
|
||||
class imrShaderCreation;
|
||||
class Texmap;
|
||||
class imrMaterialCustAttrib;
|
||||
|
||||
#define IMRSHADERTRANSLATION_INTERFACE_ID Interface_ID(0x1c396abd, 0x5f964e0c)
|
||||
#define IMRMTLPHENTRANSLATION_INTERFACE_ID Interface_ID(0x5f970a9c, 0x65e75de4)
|
||||
#define IMRGEOMSHADERTRANSLATION_INTERFACE_ID Interface_ID(0x31882a12, 0x2102a73)
|
||||
#define IMRSHADERTRANSLATION_CLASSINFO_INTERFACE_ID Interface_ID(0x17a76fd6, 0x5ab32bcd)
|
||||
|
||||
//==============================================================================
|
||||
// class imrShaderTranslation
|
||||
//
|
||||
// Interface to be implemented by the MAX plugin which translates to a mental
|
||||
// ray shader. Materials do not use this interface. Instead, they use the
|
||||
// imrMaterialTranslation interface.
|
||||
//
|
||||
// For example:
|
||||
// A 3rd party implements a MAX texmap pluggin for a brick effect. By default,
|
||||
// the mental ray translator does not support this texture and will be unable to
|
||||
// render it. If the 3rd party has also implemented a mental ray shader for this
|
||||
// effect, then this interface may be used to tell the mental ray translator
|
||||
// which shader is to be used.
|
||||
//==============================================================================
|
||||
class imrShaderTranslation : public BaseInterface {
|
||||
|
||||
public:
|
||||
|
||||
// List of requirements that may be queried on this translation interface
|
||||
enum Requirement {
|
||||
// This shader requires tangent basis vectors.
|
||||
// The tangent basis vectors will be translated for the object on which
|
||||
// this shader is used.
|
||||
// Return true if the vectors are needed, false otherwise.
|
||||
// The 't', and 'valid' parameters are not used.
|
||||
// The 'arg' variable is a pointer to an 'int', to which to map channel
|
||||
// to be used should be assigned.
|
||||
kReq_TangentBasisVectors = 0,
|
||||
};
|
||||
|
||||
struct AdditionalDependency {
|
||||
|
||||
AdditionalDependency(ReferenceTarget* rt, bool assign = true) : refTarg(rt), assignAsChild(assign) {}
|
||||
|
||||
// The reference target that is to be translated as a dependency
|
||||
ReferenceTarget* refTarg;
|
||||
// This should be true in all but exceptional cases where the translator
|
||||
// could run into potential problems with reference looping.
|
||||
bool assignAsChild;
|
||||
};
|
||||
|
||||
typedef Tab<AdditionalDependency> AdditionalDependencyTable;
|
||||
|
||||
// Called by the mental ray translator to get the mental ray shader which
|
||||
// is to be used. The method may return a shader which was already created,
|
||||
// or create a new one via the imrShaderCreation interface.
|
||||
// This method will never be called more than once per render.
|
||||
virtual imrShader* GetMRShader(imrShaderCreation& shaderCreation) = 0;
|
||||
|
||||
// This may be called when rendering is finished to discard the mental ray shaders.
|
||||
// If the derived class holds a reference to the shader created by the call to GetMRShader(),
|
||||
// then it may release that reference in this call. This is not an obligation,
|
||||
// but it can free memory and/or resolve issues such as the "Make Unique"
|
||||
// button always being enabled in the material editor.
|
||||
virtual void ReleaseMRShader() = 0;
|
||||
|
||||
// Should the translator automatically copy the parameters based on the param
|
||||
// block 2 system?
|
||||
// NOTE: The metnal ray translator will correctly handle automatic translation
|
||||
// of the parameters IF the 3rd party plugin's parameters all use the ParamBlock2
|
||||
// system AND if the names & types of the parameters match the shader definition
|
||||
// (names are not case sensitive).
|
||||
// If this returns 'true', then the automatic translation will take place
|
||||
// after the call to TranslateParameters().
|
||||
virtual bool NeedsAutomaticParamBlock2Translation() = 0;
|
||||
|
||||
// Translates the parameters of this plugin to the mental ray shader. Called
|
||||
// for the first frame, and for each subsequent frame that is not in the
|
||||
// validity interval. The method must store the validity interval of the
|
||||
// translated parameters in 'valid'.
|
||||
// **The parameters must be stored in the shader at time 0.
|
||||
virtual void TranslateParameters(imrShader* shader, TimeValue t, Interval& valid) = 0;
|
||||
|
||||
// If this class needs any ReferenceTarget to be translated, but which are not
|
||||
// sub-references or within a parameter block of the plugin class, then these
|
||||
// ReferenceTarget's may be given here. The mental ray translator will automatically
|
||||
// create a dependency between the plugin and the given ReferenceTarget's.
|
||||
virtual void GetAdditionalReferenceDependencies(AdditionalDependencyTable& refTargets) = 0;
|
||||
|
||||
// This method is meant for advanced users for whom TranslateParameters() either is not
|
||||
// sufficient or causes performance issues.
|
||||
// Whereas TranslateParameters() translates parameters using the ParamBlock2 system,
|
||||
// this method is used to send parameters directly to mental ray, bypassing the ParamBlock2 system.
|
||||
// If TranslateParameters() is enough for you, or if you do not understand why you would need
|
||||
// this advanced translation method, then do not implement this method.
|
||||
// See the documentation of class imrAdvancedTranslation for more details.
|
||||
virtual void TranslateParameters_Advanced(imrAdvancedTranslation& advancedTranslation, TimeValue t, Interval& valid);
|
||||
|
||||
// This method is meant to query specific requirements from the translation interface.
|
||||
// Look at the documentation for each requirement flag for more information.
|
||||
// Note that 'arg' may or may not be used, depending on the requirement.
|
||||
virtual bool HasRequirement(Requirement requirement, TimeValue t, Interval& valid, void* arg = NULL);
|
||||
|
||||
// -- from BaseInterface
|
||||
virtual Interface_ID GetID();
|
||||
};
|
||||
|
||||
inline imrShaderTranslation* GetIMRShaderTranslation(InterfaceServer* iserver) {
|
||||
|
||||
return static_cast<imrShaderTranslation*>(iserver->GetInterface(IMRSHADERTRANSLATION_INTERFACE_ID));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// class imrMaterialPhenomenonTranslation
|
||||
//
|
||||
// A material plugin that wishes to have a custom translation to a material
|
||||
// phenomenon must derive from this interface. The interface is identical to
|
||||
// imrShaderTranslation, except that:
|
||||
// - the interface ID is different
|
||||
// - only material phenomenon may be created via the imrShaderCreation interface.
|
||||
//
|
||||
// SPECIAL CASE: Using the mental ray material directly.
|
||||
// To translate a material to a mental ray material directly, without actually
|
||||
// using a phenomenon of your own, create an instance of the phenomenon called
|
||||
// "max_default_mtl_phen". Even though this is a phenomenon, it is not translated
|
||||
// as one, but instead it is translated as a material. NOTE, however, that this
|
||||
// particular phenomenon does NOT support the automatic ParamBlock2 translation,
|
||||
// so NeedsAutomaticParamBlock2Translation() should return false.
|
||||
//==============================================================================
|
||||
class imrMaterialPhenomenonTranslation : public imrShaderTranslation {
|
||||
|
||||
public:
|
||||
|
||||
// Returns whether this material supports the 'mental ray connection' custom
|
||||
// attributes rollup. This rollup allows users to override any of the 10 shaders
|
||||
// on the material. Note that only materials that translate to the default
|
||||
// material phenomenon ("max_default_mtl_phen") may return true here, since
|
||||
// the translator needs that phenomenon to translate the shader overrides.
|
||||
// If the material does not return the default material phenomenon but still
|
||||
// wishes to support the overrides, then it will have to do so itself.
|
||||
virtual bool SupportsMtlOverrides() = 0;
|
||||
|
||||
// Initializes the mtl overrides custom attribute, if necessary. Only called
|
||||
// if SupportsMtlOverrides() returned true.
|
||||
// All that this function should do is enable/disable the shader locks of the custom
|
||||
// attribute.
|
||||
// A material may simply do nothing here, or it may disable some of the shader locks
|
||||
// that don't apply.
|
||||
virtual void InitializeMtlOverrides(imrMaterialCustAttrib* mtlCustAttrib) = 0;
|
||||
|
||||
// -- from BaseInterface
|
||||
virtual Interface_ID GetID();
|
||||
};
|
||||
|
||||
inline imrMaterialPhenomenonTranslation* GetIMRMaterialPhenomenonTranslation(InterfaceServer* iserver) {
|
||||
|
||||
return static_cast<imrMaterialPhenomenonTranslation*>(iserver->GetInterface(IMRMTLPHENTRANSLATION_INTERFACE_ID));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// class imrGeomShaderTranslation
|
||||
//
|
||||
// A geometry object plugin that wishes to have a custom translation to a mental
|
||||
// ray shader must derive from this interface. The interface is used to retrieve
|
||||
// an instance of the geometry shader to be used.
|
||||
// Derive your GeomObject or ShapeObject from this class to have it translated
|
||||
// to a geometry shader.
|
||||
//==============================================================================
|
||||
class imrGeomShaderTranslation : public BaseInterface {
|
||||
|
||||
public:
|
||||
|
||||
// Returns the geometry shader to be used with this object. The ReferenceTarget
|
||||
// returned by this method should be a Texmap plugin that translates to a mental
|
||||
// ray geometry shader. You may need to implement your own Texmap plugin that
|
||||
// uses the imrShaderTranslation interface to translate itself to a mental ray
|
||||
// shader.
|
||||
virtual ReferenceTarget* GetGeomShader() = 0;
|
||||
|
||||
// Returns a scale for the geometry shader, to be applied on the instance transform.
|
||||
// This is useful in the case that a geometry shader produces objects of a fixed
|
||||
// size (e.g. the mib_geo_* shaders), but you still want to be able to expose
|
||||
// a size parameter in the UI.
|
||||
// If you don't care about scaling, just return a scale of (1,1,1).
|
||||
virtual void GetScale(Point3& scale) = 0;
|
||||
|
||||
// -- from BaseInterface
|
||||
virtual Interface_ID GetID();
|
||||
};
|
||||
|
||||
inline imrGeomShaderTranslation* GetIMRGeomShaderTranslation(InterfaceServer* iserver) {
|
||||
|
||||
return static_cast<imrGeomShaderTranslation*>(iserver->GetInterface(IMRGEOMSHADERTRANSLATION_INTERFACE_ID));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// class imrShaderCreation
|
||||
//
|
||||
// Interface used to create new shader instances.
|
||||
//
|
||||
// A reference to this interface is passed to the "GetMRShader()" method of the
|
||||
// imrShaderTranslation interface. If one tries to create a shader which does
|
||||
// nto exist, CreateShader() outputs an error in the mental ray message window
|
||||
// and returns NULL.
|
||||
//
|
||||
// IMPORTANT: If the implementation of this interface holds a pointer to
|
||||
// a shader, to avoid re-creating it every time, then it MUST make a reference
|
||||
// to that shader. Otherwise, the shader will be deleted when the render ends.
|
||||
//==============================================================================
|
||||
class imrShaderCreation {
|
||||
|
||||
public:
|
||||
|
||||
// Creates an instance of a shader with the given name. The name must be as it
|
||||
// appears in the .mi declaration.
|
||||
// This method may return NULL if the shader is not found, and the caller
|
||||
// should check for NULL values.
|
||||
virtual imrShader* CreateShader(
|
||||
const TCHAR* declarationName,
|
||||
const TCHAR* mtlName // The material's name is used when reporting errors.
|
||||
// (Tip: Pass the result of MtlBase::GetFullName())
|
||||
// Passing NULL suppresses error messages.
|
||||
) = 0;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// class imrShaderTranslation_ClassInfo
|
||||
//
|
||||
// IMPLEMENTATION INSTRUCTIONS:
|
||||
//
|
||||
// To be subclassed by a ClassDesc or ClassDesc2 of a Texmap plugin.
|
||||
// The subclass HAS TO call Init(*this) from its constructor.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
//
|
||||
// This class is used to provide additional 'ApplyType' information for texmaps
|
||||
// that translate to a custom shaders.
|
||||
//
|
||||
// All mental ray shaders have an 'apply' type. This type classifies shaders into
|
||||
// different categories (e.g. texture shader, light shader, environment shader, etc.).
|
||||
// The apply type restricts where and how a shader may be used. By default, if
|
||||
// this interface is not implemented, a Texmap plugin will have the
|
||||
// imrShaderClassDesc::kApplyFlag_Default apply type. If this is incorrect, then
|
||||
// this interface should be implemented - otherwise it may be impossible to use
|
||||
// the shader and crashes could occur if the shader is not used correctly.
|
||||
//==============================================================================
|
||||
class imrShaderTranslation_ClassInfo : public FPStaticInterface {
|
||||
|
||||
public:
|
||||
|
||||
// Initialization method. MUST be called from the constructor of the subclass. i.e. "Init(*this);".
|
||||
void Init(
|
||||
ClassDesc& classDesc
|
||||
);
|
||||
|
||||
// Get the types to which this shader may be applied (combination of
|
||||
// imrShaderClassDesc::ApplyFlags values).
|
||||
virtual unsigned int GetApplyTypes() = 0;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// class imrShaderTranslation_ClassInfo inlined methods
|
||||
//==============================================================================
|
||||
|
||||
// Given the class descriptor of a Mtl/Texmap plugin, this returns its compatibility interface (if it exists).
|
||||
inline imrShaderTranslation_ClassInfo* Get_imrShaderTranslation_ClassInfo(ClassDesc& mtlBaseClassDesc) {
|
||||
|
||||
return static_cast<imrShaderTranslation_ClassInfo*>(mtlBaseClassDesc.GetInterface(IMRSHADERTRANSLATION_CLASSINFO_INTERFACE_ID));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// class imrShaderTranslation inlined methods
|
||||
//==============================================================================
|
||||
|
||||
inline Interface_ID imrShaderTranslation::GetID() {
|
||||
|
||||
return IMRSHADERTRANSLATION_INTERFACE_ID;
|
||||
}
|
||||
|
||||
inline void imrShaderTranslation::TranslateParameters_Advanced(imrAdvancedTranslation& advancedTranslation, TimeValue t, Interval& valid) {
|
||||
|
||||
// Default implementation does nothing
|
||||
}
|
||||
|
||||
inline bool imrShaderTranslation::HasRequirement(Requirement, TimeValue t, Interval& valid, void* arg) {
|
||||
|
||||
// Default implementation has no requirements
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// class imrMaterialPhenomenonTranslation inlined methods
|
||||
//==============================================================================
|
||||
|
||||
inline Interface_ID imrMaterialPhenomenonTranslation::GetID() {
|
||||
|
||||
return IMRMTLPHENTRANSLATION_INTERFACE_ID;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// class imrGeomShaderTranslation inlined methods
|
||||
//==============================================================================
|
||||
|
||||
inline Interface_ID imrGeomShaderTranslation::GetID() {
|
||||
|
||||
return IMRGEOMSHADERTRANSLATION_INTERFACE_ID;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// class imrShaderTranslation_ClassInfo inlined methods
|
||||
//==============================================================================
|
||||
|
||||
inline void imrShaderTranslation_ClassInfo::Init(ClassDesc& classDesc) {
|
||||
|
||||
LoadDescriptor(IMRSHADERTRANSLATION_CLASSINFO_INTERFACE_ID, _T("imrShaderTranslation_ClassInfo"), 0, &classDesc, 0, end);
|
||||
}
|
||||
|
||||
#endif
|
27
lib/maxsdk70/include/mentalray/mentalrayInMax.h
Executable file
27
lib/maxsdk70/include/mentalray/mentalrayInMax.h
Executable file
@ -0,0 +1,27 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: mentalrayInMax.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 05May2004
|
||||
|
||||
description:
|
||||
|
||||
General include file for anyone who uses mental ray in Max.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2004 Autodesk
|
||||
==============================================================================*/
|
||||
#ifndef _MENTALRAYINMAX_H_
|
||||
#define _MENTALRAYINMAX_H_
|
||||
|
||||
#define MRRENDERER_CLASSID_PARTA 0x58f67d6c
|
||||
#define MRRENDERER_CLASSID_PARTB 0x4fcf3bc3
|
||||
|
||||
// The class ID of the metnal ray renderer
|
||||
#define MRRENDERER_CLASSID Class_ID(MRRENDERER_CLASSID_PARTA, MRRENDERER_CLASSID_PARTB)
|
||||
|
||||
#endif
|
183
lib/maxsdk70/include/mentalray/shared_src/mrShaderButtonHandler.cpp
Executable file
183
lib/maxsdk70/include/mentalray/shared_src/mrShaderButtonHandler.cpp
Executable file
@ -0,0 +1,183 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: mrShaderButtonHandler.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 23 April 2003
|
||||
|
||||
description:
|
||||
|
||||
Implementation of a DADMgr which handles shader buttons outside of the
|
||||
material editor.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2003 Autodesk
|
||||
==============================================================================*/
|
||||
|
||||
#include "mrShaderButtonHandler.h"
|
||||
|
||||
#include <mentalray\imrShader.h>
|
||||
|
||||
//==============================================================================
|
||||
// class ShaderButtonDADMgr
|
||||
//==============================================================================
|
||||
|
||||
mrShaderButtonHandler::mrShaderButtonHandler(unsigned int applyTypes, int ctrlID)
|
||||
: m_shaderFilter(applyTypes, TYPE_MAX_TYPE, true),
|
||||
m_ctrlID(ctrlID),
|
||||
m_dialogHWnd(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
mrShaderButtonHandler::~mrShaderButtonHandler() {
|
||||
|
||||
}
|
||||
|
||||
void mrShaderButtonHandler::Enable(bool enable) {
|
||||
|
||||
DbgAssert(m_dialogHWnd != NULL);
|
||||
|
||||
HWND ctrlHWnd = GetDlgItem(m_dialogHWnd, m_ctrlID);
|
||||
ICustButton* custButton = GetICustButton(ctrlHWnd);
|
||||
if(custButton != NULL) {
|
||||
custButton->Enable(enable);
|
||||
ReleaseICustButton(custButton);
|
||||
}
|
||||
else {
|
||||
DbgAssert(false);
|
||||
}
|
||||
}
|
||||
|
||||
void mrShaderButtonHandler::OnInitDialog(HWND hDialog) {
|
||||
|
||||
m_dialogHWnd = hDialog;
|
||||
|
||||
DbgAssert(m_dialogHWnd != NULL);
|
||||
|
||||
HWND ctrlHWnd = GetDlgItem(m_dialogHWnd, m_ctrlID);
|
||||
ICustButton* custButton = GetICustButton(ctrlHWnd);
|
||||
if(custButton != NULL) {
|
||||
custButton->SetDADMgr(this);
|
||||
ReleaseICustButton(custButton);
|
||||
}
|
||||
else {
|
||||
DbgAssert(false);
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
void mrShaderButtonHandler::OnCommand() {
|
||||
|
||||
DbgAssert(m_dialogHWnd != NULL);
|
||||
|
||||
// Add the filter
|
||||
IMtlBrowserFilter_Manager* filterManager = Get_IMtlBrowserFilter_Manager();
|
||||
if(filterManager != NULL) {
|
||||
filterManager->AddFilter(m_shaderFilter);
|
||||
}
|
||||
|
||||
// Browse for a texmap
|
||||
BOOL newMat;
|
||||
BOOL cancel;
|
||||
MtlBase* mtlBase = GetCOREInterface()->DoMaterialBrowseDlg(m_dialogHWnd, (BROWSE_MAPSONLY | BROWSE_INCNONE), newMat, cancel);
|
||||
if(!cancel) {
|
||||
DbgAssert((mtlBase == NULL) || ((mtlBase->SuperClassID() == TEXMAP_CLASS_ID)));
|
||||
|
||||
Texmap* texmap = static_cast<Texmap*>(mtlBase);
|
||||
SetShader(texmap);
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
if(filterManager != NULL) {
|
||||
filterManager->RemoveFilter(m_shaderFilter);
|
||||
}
|
||||
}
|
||||
|
||||
void mrShaderButtonHandler::OnClose() {
|
||||
|
||||
DbgAssert(m_dialogHWnd != NULL);
|
||||
m_dialogHWnd = NULL;
|
||||
}
|
||||
|
||||
void mrShaderButtonHandler::Update() {
|
||||
|
||||
DbgAssert(m_dialogHWnd != NULL);
|
||||
|
||||
HWND ctrlHWnd = GetDlgItem(m_dialogHWnd, m_ctrlID);
|
||||
ICustButton* custButton = GetICustButton(ctrlHWnd);
|
||||
if(custButton != NULL) {
|
||||
|
||||
TSTR text;
|
||||
Texmap* shader = GetShader();
|
||||
if(shader != NULL)
|
||||
text = shader->GetFullName();
|
||||
else
|
||||
text = GetNoneString();
|
||||
|
||||
custButton->SetText(text.data());
|
||||
|
||||
ReleaseICustButton(custButton);
|
||||
}
|
||||
else {
|
||||
DbgAssert(false);
|
||||
}
|
||||
}
|
||||
|
||||
SClass_ID mrShaderButtonHandler::GetDragType(HWND hwnd, POINT p) {
|
||||
|
||||
return TEXMAP_CLASS_ID;
|
||||
}
|
||||
|
||||
ReferenceTarget* mrShaderButtonHandler::GetInstance(HWND hwnd, POINT p, SClass_ID type) {
|
||||
|
||||
if(type == TEXMAP_CLASS_ID) {
|
||||
Texmap* shader = GetShader();
|
||||
return shader;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL mrShaderButtonHandler::OkToDrop(ReferenceTarget *dropThis, HWND hfrom, HWND hto, POINT p, SClass_ID type, BOOL isNew) {
|
||||
|
||||
if(type == TEXMAP_CLASS_ID) {
|
||||
|
||||
Texmap* texmap = static_cast<Texmap*>(dropThis);
|
||||
if(texmap == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
return m_shaderFilter.Include(*texmap, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int mrShaderButtonHandler::SlotOwner() {
|
||||
|
||||
return OWNER_SCENE;
|
||||
}
|
||||
|
||||
void mrShaderButtonHandler::Drop(ReferenceTarget *dropThis, HWND hwnd, POINT p, SClass_ID type) {
|
||||
|
||||
DbgAssert(OkToDrop(dropThis, NULL, hwnd, p, type, FALSE));
|
||||
if((dropThis == NULL) || (dropThis->SuperClassID() == TEXMAP_CLASS_ID)) {
|
||||
Texmap* texmap = static_cast<Texmap*>(dropThis);
|
||||
SetShader(texmap);
|
||||
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
BOOL mrShaderButtonHandler::AutoTooltip() {
|
||||
|
||||
return TRUE;
|
||||
}
|
89
lib/maxsdk70/include/mentalray/shared_src/mrShaderButtonHandler.h
Executable file
89
lib/maxsdk70/include/mentalray/shared_src/mrShaderButtonHandler.h
Executable file
@ -0,0 +1,89 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: mrShaderButtonHandler.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 23 April 2003
|
||||
|
||||
description:
|
||||
|
||||
Implementation of a DADMgr which handles shader buttons outside of the
|
||||
material editor.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2003 Autodesk
|
||||
==============================================================================*/
|
||||
#ifndef _MRSHADERBUTTONHANDLER_H_
|
||||
#define _MRSHADERBUTTONHANDLER_H_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <max.h>
|
||||
#include <mentalray\shared_src\mrShaderFilter.h>
|
||||
|
||||
class imrShader;
|
||||
|
||||
//==============================================================================
|
||||
// class mrShaderButtonHandler
|
||||
//
|
||||
// Base class for shader DAD managers.
|
||||
//
|
||||
// Users need only derive from this class and implement the pure virtual
|
||||
// methods. The DialogProc should call the OnInitDialog(), OnCommand(), and OnClose()
|
||||
// methods.
|
||||
//==============================================================================
|
||||
class mrShaderButtonHandler : public DADMgr {
|
||||
|
||||
public:
|
||||
|
||||
// Initialize with accepted apply types
|
||||
mrShaderButtonHandler(
|
||||
unsigned int applyTypes, // Accepted apply types, a combination of imrShaderClassDesc::ApplyFlags
|
||||
int ctrlID // ID of the button control. Must be an ICustButton control.
|
||||
);
|
||||
virtual ~mrShaderButtonHandler();
|
||||
|
||||
void OnInitDialog(HWND hDialog); // To be called on WM_INITDIALOG
|
||||
void OnCommand(); // To be called on WM_COMMAND for this button.
|
||||
void OnClose(); // To be called on WM_CLOSE
|
||||
|
||||
// Updates the text on the button
|
||||
void Update();
|
||||
|
||||
void Enable(bool enable);
|
||||
|
||||
// -- from DADMgr
|
||||
virtual SClass_ID GetDragType(HWND hwnd, POINT p);
|
||||
virtual ReferenceTarget *GetInstance(HWND hwnd, POINT p, SClass_ID type);
|
||||
virtual BOOL OkToDrop(ReferenceTarget *dropThis, HWND hfrom, HWND hto, POINT p, SClass_ID type, BOOL isNew = FALSE);
|
||||
virtual int SlotOwner();
|
||||
virtual void Drop(ReferenceTarget *dropThis, HWND hwnd, POINT p, SClass_ID type);
|
||||
virtual BOOL AutoTooltip();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void SetShader(Texmap* shader) = 0;
|
||||
virtual Texmap* GetShader() = 0;
|
||||
|
||||
// Loads a localized string for "None" (Shows up on the button when no shader is assigned)
|
||||
virtual const TCHAR* GetNoneString() = 0;
|
||||
|
||||
private:
|
||||
|
||||
// The shader filter used to validate the shaders
|
||||
mrShaderFilter m_shaderFilter;
|
||||
|
||||
int m_ctrlID;
|
||||
|
||||
HWND m_dialogHWnd;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
284
lib/maxsdk70/include/mentalray/shared_src/mrShaderFilter.cpp
Executable file
284
lib/maxsdk70/include/mentalray/shared_src/mrShaderFilter.cpp
Executable file
@ -0,0 +1,284 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: mrShaderFilter.cpp
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 21feb2003
|
||||
|
||||
description:
|
||||
|
||||
The filter for the material/map browser, which also doubles as a PBValidator.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2003 Autodesk
|
||||
==============================================================================*/
|
||||
|
||||
#include "mrShaderFilter.h"
|
||||
|
||||
#include <mentalray\imrShaderClassDesc.h>
|
||||
#include <mentalray\imrPreferences.h>
|
||||
#include <mentalray\imrShaderTranslation.h>
|
||||
|
||||
//==============================================================================
|
||||
// class mrShaderFilter
|
||||
//==============================================================================
|
||||
|
||||
mrShaderFilter::mrShaderFilter(
|
||||
unsigned int applyTypes, // Accepted apply types, a combination of imrShaderClassDesc::ApplyFlags
|
||||
ParamType2 paramType, // Accepted return types. Pass TYPE_MAX_TYPE to accept all types.
|
||||
bool acceptStructs // Should shaders returning structures be accepted? (the structure has to contain a member with a valid type)
|
||||
)
|
||||
: m_enabled(true),
|
||||
m_applyTypes(applyTypes),
|
||||
m_paramType(paramType),
|
||||
m_acceptStructs(acceptStructs)
|
||||
{
|
||||
}
|
||||
|
||||
mrShaderFilter::~mrShaderFilter() {
|
||||
|
||||
}
|
||||
|
||||
const TCHAR* mrShaderFilter::FilterName() {
|
||||
|
||||
return _T("mental ray: Shader Filter");
|
||||
}
|
||||
|
||||
bool mrShaderFilter::Enabled() {
|
||||
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
void mrShaderFilter::Enable(bool enable) {
|
||||
|
||||
m_enabled = enable;
|
||||
}
|
||||
|
||||
void mrShaderFilter::Registered() {
|
||||
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void mrShaderFilter::Unregistered() {
|
||||
|
||||
// do nothing
|
||||
}
|
||||
|
||||
bool mrShaderFilter::Include(MtlBase& mtlBase, DWORD flags) {
|
||||
|
||||
// Validate using the class ID
|
||||
ClassDesc* classDesc = GetCOREInterface()->GetDllDir().ClassDir().FindClass(mtlBase.SuperClassID(), mtlBase.ClassID());
|
||||
DbgAssert(classDesc != NULL);
|
||||
if(classDesc != NULL) {
|
||||
return Include(*classDesc, flags);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool mrShaderFilter::Include(ClassDesc& classDesc, DWORD flags) {
|
||||
|
||||
// [dl | 20may2003] Disregard the 'mr extensions active' flag.
|
||||
/*
|
||||
// If this is a mental ray shader, then never include it if the mental ray
|
||||
// custom attributes are not active.
|
||||
imrShaderClassDesc* shaderClassDesc = Get_mrShaderClassDesc(&classDesc);
|
||||
imrShaderTranslation_ClassInfo* customClassInfo = Get_imrShaderTranslation_ClassInfo(classDesc);
|
||||
if((shaderClassDesc != NULL) || (customClassInfo != NULL)) {
|
||||
imrPreferences* prefs = GetMRPreferences();
|
||||
if((prefs != NULL) && !prefs->GetMRExtensionsActive()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return (ValidateApplyType(classDesc) && ValidateReturnType(classDesc));
|
||||
}
|
||||
|
||||
BOOL mrShaderFilter::Validate(PB2Value& v) {
|
||||
|
||||
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 mrShaderFilter::Validate(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex) {
|
||||
|
||||
return Validate(v);
|
||||
}
|
||||
|
||||
BaseInterface* mrShaderFilter::GetInterface(Interface_ID id) {
|
||||
|
||||
if(id == MRSHADERFILTER_INTERFACEID) {
|
||||
return this;
|
||||
}
|
||||
else if(id == IMTLBROWSERFILTER_INTERFACEID) {
|
||||
return static_cast<IMtlBrowserFilter*>(this);
|
||||
}
|
||||
else {
|
||||
return PBValidator::GetInterface(id);
|
||||
}
|
||||
}
|
||||
|
||||
bool mrShaderFilter::ValidateApplyType(ClassDesc& classDesc) {
|
||||
|
||||
SClass_ID superClassID = classDesc.SuperClassID();
|
||||
|
||||
if(superClassID == MATERIAL_CLASS_ID) {
|
||||
|
||||
// Validate if materials are accepted
|
||||
return ((m_applyTypes & imrShaderClassDesc::kApplyFlag_MtlPhen) != 0);
|
||||
}
|
||||
else if(superClassID == TEXMAP_CLASS_ID) {
|
||||
|
||||
// First, query for a possible custom apply type
|
||||
imrShaderTranslation_ClassInfo* customClassInfo = Get_imrShaderTranslation_ClassInfo(classDesc);
|
||||
if(customClassInfo != NULL) {
|
||||
|
||||
unsigned int customApplyType = customClassInfo->GetApplyTypes();
|
||||
return ((customApplyType & m_applyTypes) != 0);
|
||||
}
|
||||
else {
|
||||
imrShaderClassDesc* shaderClassDesc = Get_mrShaderClassDesc(&classDesc);
|
||||
|
||||
if(shaderClassDesc == NULL) {
|
||||
// Not a mr shader. Validate if texture shaders are accepted.
|
||||
return ((m_applyTypes & imrShaderClassDesc::kApplyFlag_Texture) != 0);
|
||||
}
|
||||
else {
|
||||
|
||||
// Depends on the apply type of the shader
|
||||
unsigned int shaderApplyTypes = shaderClassDesc->GetApplyTypes();
|
||||
return ((shaderApplyTypes & m_applyTypes) != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Shouldn't occur
|
||||
DbgAssert(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool mrShaderFilter::ValidateReturnType(ClassDesc& classDesc) {
|
||||
|
||||
|
||||
SClass_ID superClassID = classDesc.SuperClassID();
|
||||
|
||||
if(superClassID == MATERIAL_CLASS_ID) {
|
||||
|
||||
// Validate if we want a TYPE_MTL return type
|
||||
//return ValidType(TYPE_MTL);
|
||||
|
||||
// Do not validate types for materials. Only use the apply type for validatoin.
|
||||
return true;
|
||||
}
|
||||
else if(superClassID == TEXMAP_CLASS_ID) {
|
||||
|
||||
imrShaderClassDesc* shaderClassDesc = Get_mrShaderClassDesc(&classDesc);
|
||||
|
||||
if(shaderClassDesc == NULL) {
|
||||
// Assume that the texture returns a color
|
||||
return ValidType(static_cast<ParamType2>(TYPE_RGBA));
|
||||
}
|
||||
else {
|
||||
|
||||
// Go through the results structure
|
||||
ParamBlockDesc2* pbDesc = shaderClassDesc->GetResultPBDesc();
|
||||
if((pbDesc != NULL) && ValidateReturnType(*pbDesc)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Go through the sub-structures, is allowed
|
||||
if(m_acceptStructs) {
|
||||
Tab<ParamBlockDesc2*>& resultDescs = shaderClassDesc->GetResultPBDescs();
|
||||
int count = resultDescs.Count();
|
||||
for(int i = 0; i < count; ++i) {
|
||||
ParamBlockDesc2* pbDesc = resultDescs[i];
|
||||
if((pbDesc != NULL) && ValidateReturnType(*pbDesc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Shouldn't occur
|
||||
DbgAssert(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool mrShaderFilter::ValidType(ParamType2 type) {
|
||||
|
||||
switch(m_paramType) {
|
||||
case TYPE_MAX_TYPE:
|
||||
return true;
|
||||
|
||||
// Casts to more complex types are acceptable
|
||||
#ifndef MAX51_MENTALRAY // TYPE_FRGBA and TYPE_POINT4 don't exist in 5.1
|
||||
case TYPE_RGBA:
|
||||
case TYPE_FRGBA:
|
||||
return ((type == TYPE_RGBA) || (type == TYPE_FRGBA));
|
||||
#else
|
||||
case TYPE_RGBA:
|
||||
return (type == TYPE_RGBA);
|
||||
#endif
|
||||
|
||||
#ifndef MAX51_MENTALRAY // TYPE_FRGBA and TYPE_POINT4 don't exist in 5.1
|
||||
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));
|
||||
#else
|
||||
case TYPE_POINT3:
|
||||
return ((type == TYPE_RGBA)
|
||||
|| (type == TYPE_POINT3));
|
||||
case TYPE_FLOAT:
|
||||
return ((type == TYPE_RGBA)
|
||||
|| (type == TYPE_POINT3)
|
||||
|| (type == TYPE_FLOAT));
|
||||
#endif
|
||||
|
||||
default:
|
||||
return (type == m_paramType);
|
||||
}
|
||||
}
|
||||
|
||||
bool mrShaderFilter::ValidateReturnType(ParamBlockDesc2& pbDesc) {
|
||||
|
||||
// Go through all the parameters of the block
|
||||
int count = pbDesc.Count();
|
||||
for(int i = 0; i < count; ++i) {
|
||||
ParamDef& paramDef = pbDesc.GetParamDef(pbDesc.IndextoID(i));
|
||||
|
||||
if(ValidType(paramDef.type))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void mrShaderFilter::DeleteThis() {
|
||||
|
||||
delete this;
|
||||
}
|
98
lib/maxsdk70/include/mentalray/shared_src/mrShaderFilter.h
Executable file
98
lib/maxsdk70/include/mentalray/shared_src/mrShaderFilter.h
Executable file
@ -0,0 +1,98 @@
|
||||
/*==============================================================================
|
||||
|
||||
file: mrShaderFilter.h
|
||||
|
||||
author: Daniel Levesque
|
||||
|
||||
created: 21feb2003
|
||||
|
||||
description:
|
||||
|
||||
The filter for the material/map browser, which also doubles as a PBValidator.
|
||||
|
||||
modified:
|
||||
|
||||
|
||||
<EFBFBD> 2003 Autodesk
|
||||
==============================================================================*/
|
||||
#ifndef _MRSHADERFILTER_H_
|
||||
#define _MRSHADERFILTER_H_
|
||||
|
||||
#include <max.h>
|
||||
#include <iparamb2.h>
|
||||
#include <IMtlBrowserFilter.h>
|
||||
|
||||
#define MRSHADERFILTER_INTERFACEID Interface_ID(0x36ad69a6, 0x17db66d1)
|
||||
|
||||
//==============================================================================
|
||||
// class mrShaderFilter
|
||||
//
|
||||
// Used to filter out unwanted shaders from the mtl/map browser. Also used as
|
||||
// a PBValidtor.
|
||||
//==============================================================================
|
||||
class mrShaderFilter : public IMtlBrowserFilter, public PBValidator {
|
||||
|
||||
public:
|
||||
|
||||
mrShaderFilter(
|
||||
unsigned int applyTypes, // Accepted apply types, a combination of imrShaderClassDesc::ApplyFlags
|
||||
ParamType2 paramType, // Accepted return types. Pass TYPE_MAX_TYPE to accept all types.
|
||||
bool acceptStructs // Should shaders returning structures be accepted? (the structure has to contain a member with a valid type)
|
||||
);
|
||||
|
||||
virtual ~mrShaderFilter();
|
||||
|
||||
// Returns whether the given parameter type is accepted
|
||||
bool ValidType(ParamType2 type);
|
||||
|
||||
// -- from IMtlBrowserFilter
|
||||
virtual const TCHAR* FilterName();
|
||||
virtual bool Enabled();
|
||||
virtual void Enable(bool enable);
|
||||
virtual void Registered();
|
||||
virtual void Unregistered();
|
||||
virtual bool Include(MtlBase& mtlBase, DWORD flags);
|
||||
virtual bool Include(ClassDesc& classDesc, DWORD flags);
|
||||
|
||||
// -- from PBValidator
|
||||
virtual BOOL Validate(PB2Value& v);
|
||||
virtual BOOL Validate(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex);
|
||||
virtual void DeleteThis();
|
||||
|
||||
// -- from InterfaceServer
|
||||
virtual BaseInterface* GetInterface(Interface_ID id);
|
||||
|
||||
private:
|
||||
|
||||
// Returns whether the apply type of the given class is valid
|
||||
bool ValidateApplyType(ClassDesc& classDesc);
|
||||
// Returns whether the return type of the given class is valid
|
||||
bool ValidateReturnType(ClassDesc& classDesc);
|
||||
// Validates the return type based on a parameter block
|
||||
bool ValidateReturnType(ParamBlockDesc2& pbDesc);
|
||||
|
||||
// -- Data Members --
|
||||
|
||||
// Is this filter enabled?
|
||||
bool m_enabled;
|
||||
// Accept shaders returning structs?
|
||||
bool m_acceptStructs;
|
||||
|
||||
// The accepted apply types
|
||||
unsigned int m_applyTypes;
|
||||
|
||||
// The accepted return param types
|
||||
ParamType2 m_paramType;
|
||||
|
||||
};
|
||||
|
||||
inline mrShaderFilter* Get_mrShaderFilter(InterfaceServer* iserver) {
|
||||
|
||||
if(iserver == NULL)
|
||||
return NULL;
|
||||
else
|
||||
return static_cast<mrShaderFilter*>(iserver->GetInterface(MRSHADERFILTER_INTERFACEID));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user