# IRfMaterialEditor Interface Reference

Inherits IUnknown.

List of all members.

## Public Member Functions
HRESULT | GetMaterialEditorRoot ([out] IRsNode **pMaterialEditorNode)
HRESULT | GetActiveMaterial ([out] IRsNode **pMaterialNode)
HRESULT | GetMaterialEditorHandler ([out] IRsNode **ppMaterialEditorHandler)
HRESULT | SetActiveMaterial ([in] IRsNode *pMaterialNode,[in] IRcUndoRedoGroup *spUndoRedo,[in] RtBool bForceCopy)
HRESULT | ForceMaterialEditorsRefresh ()
HRESULT | AddMaterial (ReMaterialInstancingMode dwMode, IRsNode *pNode, RtDWORD *pdwOutMatIndex, IRsNode **ppNewMaterial)
HRESULT | SetMaterial (ReMaterialInstancingMode dwMode, IRsNode *pNode, RtDWORD dwOutMatIndex, IRsNode **ppNewMaterial)
HRESULT | CreateActiveMaterialCopy (RtUlong dwMaterialIndex, IRsNode **ppNewMaterial)
HRESULT | OpenMaterialEditor ()
HRESULT | GetActiveMaterialEditor ([out, retval] IRsNode **ppActiveMaterialEditor)
HRESULT | GetActiveMasterMaterial ([out] IRsMaterialGeneric **ppGeneric)
HRESULT | GetMaterialEditor ([in] GUID gId,[out] IRsNode **ppEditor)
HRESULT | RemoveAllMaterialFlavors ()
HRESULT | GetActiveMaterialFlavorManager (IRsMaterialFlavorManager **pChunkManager)
HRESULT | SetNewMaterialFlavor (IRsNode *spMaterialNode, CONID gMaterialConId)
HRESULT | OpenMaterialEditorPanels ()
HRESULT | RemoveDependentMaterialFlavors ()
HRESULT | SetMaterialFlavorMaster (GUID clsId)
HRESULT | GetMaterialConversionMode (ReMaterialConversionMode *pdwMode)
HRESULT | OpenContextMaterialEditor (IRcUndoRedoGroup *spUndoRedo)
HRESULT | GetContextMaterialEditor (RtMatClsId clsMatId, IRsMaterialEditor **ppEditor)
HRESULT | CreateRealTimeMaterial (IRsMaterialGeneric *pMaterial, IRsNode **ppD3dmaterial)
HRESULT | GetMaterialNode (RtMatClsId clsMatId, IRsNode **ppMaterial)
HRESULT | AddRealTimeMaterial (IRsNode *spMaterial)
HRESULT | PaintObject (IRsNode *pNode, IRsNode *pMaterial)
HRESULT | GetMaterialLiveStatus (RtBool *pLiveMaterial)
HRESULT | GetMaterialInstancingMode (ReMaterialInstancingMode *pdwInstancingMode)
HRESULT | GetMaterialInstancingStatus (ReMaterialInstancingMode *pdwInstancingMode)
HRESULT | LocateActiveMaterial (IRnEncapsulator *pEnc, IRsNode **ppMaterialNode)
HRESULT | GetMaterialActiveInfo (IRdMaterialActiveInfo **ppActiveInfo)
HRESULT | GetActiveMaterialFlavor (RtMatClsId clsMatId, IRsMaterialGeneric **ppMaterial)

## Detailed Description

Material editor function set provides functions for shared material editor management.

## Member Function Documentation

HRESULT IRfMaterialEditor::GetMaterialEditorRoot | ( | [out] IRsNode ** | pMaterialEditorNode | ) |

Get material editor node.

Parameters:

  | pNode | [out] Pointer to material editor.

Returns:
  S_OK if material editor located successfully.

HRESULT IRfMaterialEditor::GetActiveMaterial | ( | [out] IRsNode ** | pMaterialNode | ) |

Get active material.

Parameters:

  | pNode | [out] Pointer to active material node.

Returns:
  S_OK if material located successfully.

HRESULT IRfMaterialEditor::GetMaterialEditorHandler | ( | [out] IRsNode ** | ppMaterialEditorHandler | ) |

Get material editor handler.

Parameters:

  | ppMaterialEditorHandler | [out] Pointer to material editor handler (if found).

Returns:
  S_OK if material handler found.

HRESULT IRfMaterialEditor::SetActiveMaterial | ( | [in] IRsNode * | pMaterialNode,
|  | [in] IRcUndoRedoGroup * | spUndoRedo,
|  | [in] RtBool | bForceCopy |
| ) |  |  |

Set active material.

Parameters:

  | pNode | [in] Pointer to material node to set.
  | spUndoRedo | [in] Undo/Redo container to collect setting active material events.
  | bForceCopy | [in] Set to true if material editor should create copy.

Returns:
  S_OK if material located successfully

HRESULT IRfMaterialEditor::ForceMaterialEditorsRefresh | ( |  | ) |

Refresh material editors, regenerate all previews.

Returns:
  S_OK if material located successfully.

HRESULT IRfMaterialEditor::AddMaterial | ( | ReMaterialInstancingMode | dwMode,
|  | IRsNode * | pNode,
|  | RtDWORD * | pdwOutMatIndex,
|  | IRsNode ** | ppNewMaterial |
| ) |  |  |

Add active material to node and return it's index.

Parameters:

  | dwMode | [in] Material instancing mode override.
  | pNode | [in] Node to add material to.
  | dwOutMatIndex | [out] Index of added material.
  | ppNewMaterial | [out] Material node with new material.

Returns:
  S_OK if succeeded.

HRESULT IRfMaterialEditor::SetMaterial | ( | ReMaterialInstancingMode | dwMode,
|  | IRsNode * | pNode,
|  | RtDWORD | dwOutMatIndex,
|  | IRsNode ** | ppNewMaterial |
| ) |  |  |

Set active material with specified index to node.

Parameters:

  | dwMode | [in] Material instancing mode override.
  | pNode | [in] Node to add material to.
  | dwMatIndex | [in] Material index.
  | ppNewMaterial | [out] Material node with new material.

Returns:
  S_OK if succeeded.

HRESULT IRfMaterialEditor::CreateActiveMaterialCopy | ( | RtUlong | dwMaterialIndex,
|  | IRsNode ** | ppNewMaterial |
| ) |  |  |

Create node containing active material copy with D3D material and material specified by active material's chunk active class info.

Parameters:

  | dwMaterialIndex | [in] Index for new material.
  | ppNewMaterial | [out] Filled with new material if succeeded.

Returns:
  S_OK if succeeded.

HRESULT IRfMaterialEditor::OpenMaterialEditor | ( |  | ) |

Open active material editor.

Returns:
  S_OK if succeeded.

HRESULT IRfMaterialEditor::GetActiveMaterialEditor | ( | [out, retval] IRsNode ** | ppActiveMaterialEditor | ) |

Returns:
  ppActiveMaterialEditor [out, retval] Get active material editor node.

  S_OK if succeeded.

HRESULT IRfMaterialEditor::GetActiveMasterMaterial | ( | [out] IRsMaterialGeneric ** | ppGeneric | ) |

Get active material master class flavor.

Parameters:

  | ppGeneric | [out] Chunk manager connector.

Returns:
  S_OK if material located successfully.

HRESULT IRfMaterialEditor::GetMaterialEditor | ( | [in] GUID | gId,
|  | [out] IRsNode ** | ppEditor |
| ) |  |  |

Get material editor node defines by GUID.

Parameters:

  | gId | [in] Material editor class ID.
  | ppEditor | [out] Material editor in material editor handler encapsulator.

Returns:
  S_OK if material located successfully.

HRESULT IRfMaterialEditor::RemoveAllMaterialFlavors | ( |  | ) |

Remove all material flavors from active material.

- Use this method in combination with SetNewMaterialFlavor if you created new material and you want to make it master class.

HRESULT IRfMaterialEditor::GetActiveMaterialFlavorManager | ( | IRsMaterialFlavorManager ** | pChunkManager | ) |

Get active material chunk manager.

Returns:
  pChunkManager [out,retval] Filled with active material chunk manager interface.

HRESULT IRfMaterialEditor::SetNewMaterialFlavor | ( | IRsNode * | spMaterialNode,
|  | CONID | gMaterialConId |
| ) |  |  |

Set new material flavor to active material.

Parameters:

  | spMaterialNode | [in] Material node to add to active material.

Remarks:
  Note that node is not copied and is destroyed on error.

Parameters:

  | gMaterialConId | [in] Material output connector ID.

HRESULT IRfMaterialEditor::OpenMaterialEditorPanels | ( |  | ) |

Open panels associated with active material editor. (eg. shaders for LW ME or material node for D3D...)

HRESULT IRfMaterialEditor::RemoveDependentMaterialFlavors | ( |  | ) |

Remove material flavors that are not master.

HRESULT IRfMaterialEditor::SetMaterialFlavorMaster | ( | GUID | clsId | ) |

Set provided material class as master (original).

Parameters:

  | clsId | [in] Material class ID to set as master.
  | S_OK | if material found and is successfully set as master.

HRESULT IRfMaterialEditor::GetMaterialConversionMode | ( | ReMaterialConversionMode * | pdwMode | ) |

Get material conversion mode defined by Material editor settings.

Parameters:

  | pdwMode | [out, retval] Filled with current material editor material conversion mode.
  | S_OK | if succeeded.

HRESULT IRfMaterialEditor::OpenContextMaterialEditor | ( | IRcUndoRedoGroup * | spUndoRedo | ) |

Open material editor depending on material editor context settings and set material to use with it.

Parameters:

  | spUndoRedo | [in] Undo/Redo container for collecting undo/redo commands.
  | S_OK | if succeeded.

HRESULT IRfMaterialEditor::GetContextMaterialEditor | ( | RtMatClsId | clsMatId,
|  | IRsMaterialEditor ** | ppEditor |
| ) |  |  |

Get best material editor for provided material class.

Parameters:

  | clsMatId | [in] Material class.

Returns:
  ppEditor [out,retval] Material editor interface for best editor for provided class, NULL if none available.

  S_OK if succeeded.

HRESULT IRfMaterialEditor::CreateRealTimeMaterial | ( | IRsMaterialGeneric * | pMaterial,
|  | IRsNode ** | ppD3dmaterial |
| ) |  |  |

Create real time (d3d) material using material editor conversion routines or internal conversion if there is no available material editor to convert provided material.

Parameters:

  | pMaterial | ]in] Input material.

Returns:
  ppD3dmaterial [out,retval] Created d3d material.

  S_OK if succeeded.

HRESULT IRfMaterialEditor::GetMaterialNode | ( | RtMatClsId | clsMatId,
|  | IRsNode ** | ppMaterial |
| ) |  |  |

Return specified material node inside active material.

Parameters:

  | clsMatId | [in] Material cls ID.

Returns:
  ppMaterial [out,retval] Material with specified class ID.

  S_OK if succeeded.

HRESULT IRfMaterialEditor::AddRealTimeMaterial | ( | IRsNode * | spMaterial | ) |

Add real time material to material node if it is missing.

Parameters:

  | pMaterial | [in] Material to update.

Returns:
  S_OK if succeeded.

HRESULT IRfMaterialEditor::PaintObject | ( | IRsNode * | pNode,
|  | IRsNode * | pMaterial |
| ) |  |  |

Paint object by provided material. If material is NULL, default material is used.

Parameters:

  | pNode | [in] Node to paint.
  | pMaterial | [in] Material to paint, NULL if default material is desired.

Returns:
  S_OK if succeeded.

HRESULT IRfMaterialEditor::GetMaterialLiveStatus | ( | RtBool * | pLiveMaterial | ) |

Check if current active material is directly edited or material editor is using local material copy.

Returns:
  pLiveMaterial [out,retval] True, if live material is edited.

  S_OK if succeeded.

HRESULT IRfMaterialEditor::GetMaterialInstancingMode | ( | ReMaterialInstancingMode * | pdwInstancingMode | ) |

Get material default instancing mode.

Returns:
  pdwInstancingMode [out,retval] Material editor instancing mode.

  S_OK if succeeded.

HRESULT IRfMaterialEditor::GetMaterialInstancingStatus | ( | ReMaterialInstancingMode * | pdwInstancingMode | ) |

Get current material instancing mode.

Returns:
  pdwInstancingMode [out,retval] Current material instancing mode.

Parameters:

  | S_OK | if succeeded.

HRESULT IRfMaterialEditor::LocateActiveMaterial | ( | IRnEncapsulator * | pEnc,
|  | IRsNode ** | ppMaterialNode |
| ) |  |  |

Locate material equivalent to currently edited material within provided encapsulator.

- Function does not search recursively, only first level is checked.

Parameters:

  | pEnc | [in] Encapsulator to search.

Returns:
  ppMaterialNode [out,retval] Material node equaivalent with active material.

  S_OK if material found.

HRESULT IRfMaterialEditor::GetMaterialActiveInfo | ( | IRdMaterialActiveInfo ** | ppActiveInfo | ) |

Get current material active info.

Returns:
  ppActiveInfo [out,retval] Material active info.

  S_OK if succeeded.

HRESULT IRfMaterialEditor::GetActiveMaterialFlavor | ( | RtMatClsId | clsMatId,
|  | IRsMaterialGeneric ** | ppMaterial |
| ) |  |  |

Return specified material flavor from active material.

Parameters:

  | clsMatId | [in] Material cls ID.

Returns:
  ppMaterial [out,retval] Material flavor if it exists.

  S_OK if succeeded.