3ds Max C++ API Reference
IMaterialViewportShading Class Referenceabstract

A new interface for 3ds Max 2008. More...

#include <IMaterialViewportShading.h>

+ Inheritance diagram for IMaterialViewportShading:

Public Types

enum  ShadingModel { Standard , Hardware , OtherTypes }
 This enumeration defines how the material is behaving in viewport. More...
 
- Public Types inherited from BaseInterface
enum  LifetimeType { noRelease , immediateRelease , wantsRelease , serverControlled }
 

Public Member Functions

virtual CoreExport BaseInterfaceGetInterface (Interface_ID id)
 
virtual CoreExport Interface_ID GetID ()
 
- Public Member Functions inherited from BaseInterface
virtual UtilExport ~BaseInterface ()
 Destructor. More...
 
virtual LifetimeType LifetimeControl ()
 
virtual bool RegisterNotifyCallback (InterfaceNotifyCallback *incb)
 
virtual void UnRegisterNotifyCallback (InterfaceNotifyCallback *incb)
 
virtual BaseInterfaceAcquireInterface ()
 
virtual void ReleaseInterface ()
 
virtual void DeleteInterface ()
 
virtual BaseInterfaceCloneInterface (void *remapDir=NULL)
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 
template<class InterfaceType >
InterfaceType * GetTypedInterface ()
 

Static Public Member Functions

static CoreExport bool IsShadingModelSupported (const MtlBase &material, ShadingModel model)
 Does the material support a specific shading model in viewport. More...
 
static CoreExport ShadingModel GetCurrentShadingModel (const MtlBase &material)
 Used to query the material for its current level of viewport rendering. More...
 
static CoreExport bool SetCurrentShadingModel (MtlBase &material, ShadingModel model)
 Set the shading model of the material in viewport and update the UI of material editor. More...
 
static CoreExport int GetSupportedMapLevels (const MtlBase &material)
 The map levels needs to be defined by the material, it will tell the various shader compilers how far to go in the search of materials/maps. More...
 
- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Protected Member Functions

virtual bool IsShadingModelSupported (ShadingModel model) const =0
 Does the material support a specific shading model in viewport. More...
 
virtual ShadingModel GetCurrentShadingModel () const =0
 Used to query the material for its current level of viewport rendering. More...
 
virtual bool SetCurrentShadingModel (ShadingModel model)=0
 Set the shading model of the material in viewport. More...
 
virtual int GetSupportedMapLevels () const =0
 The map levels needs to be defined by the material, it will tell the various shader compilers how far to go in the search of materials/maps. More...
 

Detailed Description

A new interface for 3ds Max 2008.

This interface is used for manipulating material shading model in the viewport. A material would implement this interface so as to control the "Show map in viewport" (SMIV) button. In 3dsmax 2008 the SMIV button can now show as a flyoff, for regular shading (Blue) and Hardware shading (Pink). If a material supports a Hardware representation then it can implement this interface and return the correct level support in IsShadingModelSupported. This will mean the UI is reflective of the support available. This interface DOES NOT provide any support for the actual Hardware implementation - purely the UI synchronisation.
An implementation for this interface can be found at \maxsdk\samples\materials\StdMaterialViewportShading.cpp where it support the case where the material deals with plugin hardware shaders as well. Currently in 3ds max 2008, only two materials implement a Hardware version, and they are the Standard Material and Mental Images's Architectural and Design Material.

Member Enumeration Documentation

◆ ShadingModel

This enumeration defines how the material is behaving in viewport.

Enumerator
Standard 

the material is rendered in standard way - original Viewport rendering.

Hardware 

the material is rendered by using hardware shaders.

OtherTypes 

other render types, such as plugin effect shading.

38  {
40  Standard,
42  Hardware,
44  OtherTypes,
45  };
@ Standard
the material is rendered in standard way - original Viewport rendering.
Definition: IMaterialViewportShading.h:40
@ OtherTypes
other render types, such as plugin effect shading.
Definition: IMaterialViewportShading.h:44
@ Hardware
the material is rendered by using hardware shaders.
Definition: IMaterialViewportShading.h:42

Member Function Documentation

◆ GetInterface()

virtual CoreExport 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 BaseInterface.

◆ GetID()

virtual CoreExport Interface_ID GetID ( )
virtual
Remarks
This method returns the unique interface ID.

Reimplemented from BaseInterface.

◆ IsShadingModelSupported() [1/2]

virtual bool IsShadingModelSupported ( ShadingModel  model) const
protectedpure virtual

Does the material support a specific shading model in viewport.

This will be used to enable\disable the SMIV options.

Parameters
modelThe shading model, for now it must be Standard or Hardware.
Returns
if the shading model is supported, return true; otherwise return false

◆ GetCurrentShadingModel() [1/2]

virtual ShadingModel GetCurrentShadingModel ( ) const
protectedpure virtual

Used to query the material for its current level of viewport rendering.

Returns
current shading model.

◆ SetCurrentShadingModel() [1/2]

virtual bool SetCurrentShadingModel ( ShadingModel  model)
protectedpure virtual

Set the shading model of the material in viewport.

Parameters
modelThe shading model, must be Standard or Hardware.
Returns
If the shading model is set successfully, return true; otherwise return false.

◆ GetSupportedMapLevels() [1/2]

virtual int GetSupportedMapLevels ( ) const
protectedpure virtual

The map levels needs to be defined by the material, it will tell the various shader compilers how far to go in the search of materials/maps.

Most materials will stop searching after one level, as the shader becomes too complex. For example specifiying 1 will mean the first map found will be used e.g a BitmapTex in a diffuse slot. The compiler will not search any further for maps to support. In this case it will probably bake the submaps to textures and will not try to generate
shader code for these submaps.

Returns
How deep the shader compilers will go in the search of material/Maps in the tree.

◆ IsShadingModelSupported() [2/2]

static CoreExport bool IsShadingModelSupported ( const MtlBase material,
ShadingModel  model 
)
static

Does the material support a specific shading model in viewport.

This will be used to enable\disable the SMIV options.

Parameters
materialThe material you want to test. If the material does not support IMaterialViewportShading interface, then only standard shading model is supported.
modelThe shading model, for now it must be Standard or Hardware.
Returns
if the shading model is supported, return true; otherwise return false

◆ GetCurrentShadingModel() [2/2]

static CoreExport ShadingModel GetCurrentShadingModel ( const MtlBase material)
static

Used to query the material for its current level of viewport rendering.

Parameters
materialThe material you want to get shading model from. If the material does not support IMaterialViewportShading interface, then the function will return Standard shading model.
Returns
current shading model.

◆ SetCurrentShadingModel() [2/2]

static CoreExport bool SetCurrentShadingModel ( MtlBase material,
ShadingModel  model 
)
static

Set the shading model of the material in viewport and update the UI of material editor.

Parameters
materialThe material you want to set its shading model. If the material does not support the shading model, the function will fail.
modelThe shading model, must be Standard or Hardware.
Returns
If the shading model is set successfully, return true; otherwise return false.

◆ GetSupportedMapLevels() [2/2]

static CoreExport int GetSupportedMapLevels ( const MtlBase material)
static

The map levels needs to be defined by the material, it will tell the various shader compilers how far to go in the search of materials/maps.

Most materials will stop searching after one level, as the shader becomes too complex. For example specifiying 1 will mean the first map found will be used e.g a BitmapTex in a diffuse slot. The compiler will not search any further for maps to support. In this case it will probably bake the submaps to textures and will not try to generate
shader code for these submaps.

Parameters
materialThe material you want to get map levels from. If the material does not support IMaterialViewportShading interface, the function returns 1.
Returns
How deep the shader compilers will go in the search of material/Maps in the tree.