ISimpleMaterial Class Reference


Detailed Description

ISimpleMaterial provides any material or texture plugin the ability to display itself in the new Viewport Display system in 3ds Max 2012.

ISimpleMaterial supports fast efficient handling of a basic phong style shader. It supports all the usual surface elements like Diffuse, Specular with the added ability to support two input textures for diffuse and opacity. If a developer needs finer control over the visual appearance of the material then they should look to use the Advanced mode graphics API

A developer typically would not need to worry about many of the Set methods in the class as the viewport display system will translate the host material calling MtlBase::GetDiffuse() and then using ISimpleMaterial::SetDiffuse to update the display definition. Every material and texture map will have an ISimpleMaterial available as it is added as a property of the MtlBase. To access the property use the following code

        ISimpleMaterial *pISimpleMtl = (ISimpleMaterial *)GetProperty(PROPID_SIMPLE_MATERIAL);

The only aspect of the material setup that is not fully automatic is the allocation of textures. In general materials have a more complicated requirement for texture display. An example would be diffuse and opacity display with different mapping channels. Texture plugins on the other hand tend to be more simplistic. However, there are examples of a more complex setup as can be seen with the mix or composite maps. To support these more complex setups the developer must implement ITextureDisplay and implement SetupTextures. SetupTextures is called when ever a change in the material or texture is detected by the system. It is in this method the developer should assign the texture using SetTexture. This method also provides a chance to override the automatic translation of the material parameters, however, it is not a requirement. If ITextureDisplay is not implemented the translation code will use GetActiveTexHandle() to access the texture resource, this is how texture maps such as Checker work.

ISimpleMaterial also allows the material to define a draw style such as whether it is a solid or wireframe. During translation the materials requirements will be checked. For example the standard material can be forced into wireframe mode. The translating code would look like this

        // assuming geomNode is a pointer to INode, the node currently being translated
        Mtl * mtl = geomNode->GetMtl();
        ULONG mtlReq = mtl->Requirements(0);
        if (mtlReq & MTLREQ_WIRE) {
                pISimpleMtl->SetFillMode(FillWireframe);
        }

ISimpleMaterial is used to provide quick and approximate representations of materials in the viewport. More realistic material representations can be created by writing custom real-time shader using the advanced mode graphics API

Note:
All of the methods of this interface are implemented by the graphics driver layer, it is not designed to be derived by plug-ins.

#include <ISimpleMaterial.h>

Inheritance diagram for ISimpleMaterial:
Inheritance graph
[legend]

List of all members.

Public Types

enum   FillMode { FillPoint, FillWireframe, FillSolid }
 

This is the fill mode used in both SetFillMode and GetFillMode.

More...
enum   MapUsage { UsageDiffuse = 0, UsageOpacity, MaxUsage }
 

This enum type tells the viewport rendering system the usage of each texture.

More...

Public Member Functions

virtual ISimpleMaterial Clone ()=0
  Clones the instance of ISimpleMaterial.
virtual void  SetFillMode (ISimpleMaterial::FillMode mode)=0
  Specifies the fill mode of the material.
virtual ISimpleMaterial::FillMode  GetFillMode () const =0
  Returns the fill mode that the material is using.
virtual void  SetAmbientColor (const AColor &color)=0
  Specifies the ambient color as an RGBA value.
virtual const AColor GetAmbientColor () const =0
  Returns ambient color that the material is using.
virtual void  SetDiffuseColor (const AColor &color)=0
  Specifies diffuse color as an RGBA value.
virtual const AColor GetDiffuseColor () const =0
  Returns diffuse color that the material is using.
virtual void  SetSpecularColor (const AColor &color)=0
  Specifies the specular color as an RGBA value.
virtual const AColor GetSpecularColor () const =0
  Returns specular color that the material is using.
virtual void  SetEmissiveColor (const AColor &color)=0
  Specifies the Emissive color as an RGBA value.
virtual const AColor GetEmissiveColor () const =0
  Returns Emissive color that the material is using.
virtual void  SetSpecularPower (float power)=0
  Specifies the specular exponent of the material to be set.
virtual float  GetSpecularPower ()=0
  Returns specular power that the material is using.
virtual void  SetSpecularLevel (float level)=0
  Specifies the specular level.
virtual float  GetSpecularLevel () const =0
  Returns specular level that the material is using.
virtual void  SetSelfIllumColorOn (bool bOn)=0
  Specifies the self illumination mode.
virtual bool  GetSelfIllumColorOn () const =0
  Returns self illumination mode that the material is using.
virtual bool  SetTextureTransform (MapUsage usage, const Matrix3 &transform)=0
  Set texture transform matrix.
virtual Matrix3 GetTextureTransform (MapUsage usage)=0
  Get texture transform matrix.
virtual bool  SetTexture (TexHandle *pTexture, MapUsage usage)=0
  Set texture with texture handle.
virtual TexHandle GetTexture (MapUsage usage)=0
  Get texture handle.
virtual void  ClearTextures ()=0
  Clears all texture used by this material.

Member Enumeration Documentation

enum FillMode

This is the fill mode used in both SetFillMode and GetFillMode.

Enumerator:
FillPoint 

Point rendering style used for vertex ticks.

FillWireframe 

Wireframe rendering style.

FillSolid 

Solid rendering style.

enum MapUsage

This enum type tells the viewport rendering system the usage of each texture.

Enumerator:
UsageDiffuse 

Diffuse channel.

UsageOpacity 

Opacity channel.

MaxUsage 
            {
                UsageDiffuse = 0,   
                UsageOpacity,       
                // to add more
                MaxUsage,
            };

Member Function Documentation

virtual ISimpleMaterial* Clone ( ) [pure virtual]

Clones the instance of ISimpleMaterial.

Returns:
a pointer of new cloned ISimpleMaterial.
virtual void SetFillMode ( ISimpleMaterial::FillMode  mode ) [pure virtual]

Specifies the fill mode of the material.

Parameters:
[in] mode A member of ISimpleMaterial::FillMode.
virtual ISimpleMaterial::FillMode GetFillMode ( ) const [pure virtual]

Returns the fill mode that the material is using.

Returns:
the fill mode.
virtual void SetAmbientColor ( const AColor color ) [pure virtual]

Specifies the ambient color as an RGBA value.

Parameters:
[in] color The ambient color.
virtual const AColor& GetAmbientColor ( ) const [pure virtual]

Returns ambient color that the material is using.

Returns:
the ambient color.
virtual void SetDiffuseColor ( const AColor color ) [pure virtual]

Specifies diffuse color as an RGBA value.

If diffuse texture map exists, this value will be ignored.

Parameters:
[in] color The diffuse color.
virtual const AColor& GetDiffuseColor ( ) const [pure virtual]

Returns diffuse color that the material is using.

Returns:
the diffuse color.
virtual void SetSpecularColor ( const AColor color ) [pure virtual]

Specifies the specular color as an RGBA value.

Parameters:
[in] color The specular color.
virtual const AColor& GetSpecularColor ( ) const [pure virtual]

Returns specular color that the material is using.

Returns:
the specular color.
virtual void SetEmissiveColor ( const AColor color ) [pure virtual]

Specifies the Emissive color as an RGBA value.

Parameters:
[in] color The Emissive color.
virtual const AColor& GetEmissiveColor ( ) const [pure virtual]

Returns Emissive color that the material is using.

Returns:
the Emissive color.
virtual void SetSpecularPower ( float  power ) [pure virtual]

Specifies the specular exponent of the material to be set.

Parameters:
[in] power The specular amount.
virtual float GetSpecularPower ( ) [pure virtual]

Returns specular power that the material is using.

THe power value can be in the range of 0.0f and 1.0f

Returns:
the specular power.
virtual void SetSpecularLevel ( float  level ) [pure virtual]

Specifies the specular level.

The specular level information is used to adjust the specular color. THe level value can be in the range of 0.0f and 10.0f

Parameters:
[in] level The specular level value.
virtual float GetSpecularLevel ( ) const [pure virtual]

Returns specular level that the material is using.

Returns:
the specular level.
virtual void SetSelfIllumColorOn ( bool  bOn ) [pure virtual]

Specifies the self illumination mode.

Parameters:
[in] bOn Sets whether Self Illumination Color is on or off.
virtual bool GetSelfIllumColorOn ( ) const [pure virtual]

Returns self illumination mode that the material is using.

Returns:
the self illumination mode. If TRUE, the SelfIllumColor is on.
virtual bool SetTextureTransform ( MapUsage  usage,
const Matrix3 transform 
) [pure virtual]

Set texture transform matrix.

Parameters:
[in] usage The texture usage
[in] transform The transform matrix
Returns:
true if successful
virtual Matrix3& GetTextureTransform ( MapUsage  usage ) [pure virtual]

Get texture transform matrix.

Parameters:
[in] usage The texture usage
Returns:
the texture transform matrix
virtual bool SetTexture ( TexHandle pTexture,
MapUsage  usage 
) [pure virtual]

Set texture with texture handle.

See also:
ITextureDisplay::SetupTextures()
Parameters:
[in] pTexture A texture handle. If pTexture is NULL it will clear the texture. This can give finer control than using ClearTextures()
[in] usage The texture usage
Returns:
True if successful
virtual TexHandle* GetTexture ( MapUsage  usage ) [pure virtual]

Get texture handle.

Parameters:
[in] usage The texture usage
Returns:
A pointer to texture handle
virtual void ClearTextures ( ) [pure virtual]

Clears all texture used by this material.


ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial
ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial ISimpleMaterial