# IRsMaterialEditor Interface Reference

Inherits IUnknown.

List of all members.

## Public Member Functions
HRESULT | SetPrimaryMaterialEditor (IRcUndoRedoGroup *spUndoRedo)
HRESULT | UnSetPrimaryMaterialEditor (IRcUndoRedoGroup *spUndoRedo)
HRESULT | ForceMaterialRefresh ()
HRESULT | EnumMaterialEditorPanels (IRsPanelContainer *pContainer)
HRESULT | UpdateMaterialNodes (IRcUndoRedoGroup *spUndoRedo)
HRESULT | GetMaterialEditorWeight (RtMatClsId gMatClsId, RtFloat *pWeight)
HRESULT | CreateDefaultRealTimeMaterial (IRsMaterialGeneric *pSourceMaterial, IRsNode **ppDefaultD3dMaterial)
HRESULT | CreatePreviewImage (IRsNode *pMaterialNode, RtUlong dwWidth, RtUlong dwHeight, IRdBitmap **ppBitmap)
HRESULT | CreateMaterialFromGeneric (RtMatClsId clsMatId, IRdMaterialGeneric *pGeneric, IRsNode **ppMaterialNode)

## Detailed Description

Implement this interface if you wish to define new material editor. Place your node inside /Material editor/Material editor to install it to system.

## Member Function Documentation

HRESULT IRsMaterialEditor::SetPrimaryMaterialEditor | ( | IRcUndoRedoGroup * | spUndoRedo | ) |

Method is called when user chooses this material editor. Note that only one editor can be active in a time.

Parameters:

  | spUndoRedo | Pointer to container for undo/redo events

HRESULT IRsMaterialEditor::UnSetPrimaryMaterialEditor | ( | IRcUndoRedoGroup * | spUndoRedo | ) |

Method is called when user changes from this material editor to another one.

Parameters:

  | spUndoRedo | Pointer to container for undo/redo events

HRESULT IRsMaterialEditor::ForceMaterialRefresh | ( |  | ) |

Force refresh of material previews. Note, that function is called for all material editors so you can reset your internal caches so you can correctly refresh previews if your material editor becomes active.

HRESULT IRsMaterialEditor::EnumMaterialEditorPanels | ( | IRsPanelContainer * | pContainer | ) |

Called if material editor is being opened. As a response, node should open it's panels and add stack panels to panel contianer.

Parameters:

  | pContainer | Fill with node panels you wish to open together with material editor panel.

Returns:
  S_OK if succeeded.

HRESULT IRsMaterialEditor::UpdateMaterialNodes | ( | IRcUndoRedoGroup * | spUndoRedo | ) |

Called for active material after activation or change of material so that material editor can update shader panels if required.

Parameters:

  | spUndoRedo | Container to store undo/redo commands for this call. This parameter is NULL when undo/redo is not requested.

HRESULT IRsMaterialEditor::GetMaterialEditorWeight | ( | RtMatClsId | gMatClsId,
|  | RtFloat * | pWeight |
| ) |  |  |

Return material editor weight for specified material class. Bigger weight means that editor is more sufficient to open for provided material class. Return negative value if this editor cannot be used for provided material due to serious incompatibility.

Parameters:

  | gMatClsId | Material class id
  | pWeight | Weight of this material editor.

HRESULT IRsMaterialEditor::CreateDefaultRealTimeMaterial | ( | IRsMaterialGeneric * | pSourceMaterial,
|  | IRsNode ** | ppDefaultD3dMaterial |
| ) |  |  |

Create default d3d material from provided material. This method allows custom material editors to provide better real time approximation for their shaders.

Parameters:

  | pSourceMaterial | Material to convert.
  | ppDefaultD3dMaterial | Generated D3D material

Returns:
  S_OK if succeeded. Otherwise default conversion from generic material description will be used.

HRESULT IRsMaterialEditor::CreatePreviewImage | ( | IRsNode * | pMaterialNode,
|  | RtUlong | dwWidth,
|  | RtUlong | dwHeight,
|  | IRdBitmap ** | ppBitmap |
| ) |  |  |

Create material preview bitmap with specified resolution. Must be called from Master thread.

Parameters:

  | pMaterialNode | Material for which you want to generate bitmap.
  | dwWidth | Width of requested image
  | dwHeight | Height of requested image
  | ppBitmap | Filled with default material preview according to current ME settings.

Returns:
  S_OK if succeeded.

HRESULT IRsMaterialEditor::CreateMaterialFromGeneric | ( | RtMatClsId | clsMatId,
|  | IRdMaterialGeneric * | pGeneric,
|  | IRsNode ** | ppMaterialNode |
| ) |  |  |

Create default material from provided generic description.

Parameters:

  | clsMatId | Material class ID
  | pGeneric | Generic material description.
  | ppMaterialNode | Generated material node

Returns:
  S_OK if succeeded. Otherwise default conversion from generic material description will be used.