#include <MSwatchRenderBase.h>
Swatch Render Base class.
A class providing an interface through which a plugin can implement a class to provide custom rendered images for swatches which are displayed in hypershade and the Attribute Editor.
By deriving from this class and implementing the doIteration function, swatches for nodes (having the required classification) can be custom rendered by the plugin.
The derived class needs to be registered with Maya using the interface provided by MSwatchRenderRegister. Please refer to documentation of MSwatchRenderRegister for more details.
To indicate that swatch for a certain node type will be generated by the plugin the classfication string of the node needs to contain the following string : "swatch/<swatch generator name>" The swatch generator name string should match the name used to register the swatch generator class.
Public Member Functions | |
MSwatchRenderBase (MObject obj, MObject renderObj, int res) | |
Class constructor. More... | |
virtual | ~MSwatchRenderBase () |
Class destructor. | |
virtual bool | doIteration () |
Method called from the MSwatchRenderRegister for generation of swatch image. More... | |
virtual bool | renderParallel () |
Method indicates if the swatch is rendered parallel. More... | |
virtual void | cancelParallelRendering () |
Method to cancel the parallel rendering. More... | |
MObject | swatchNode () const |
This method returns the node for which the swatch is required to be generated. | |
MObject | node () const |
This method returns the node that is used to compute the swatch. | |
int | resolution () const |
This method returns the expected resolution of the swatch. | |
MImage & | image () |
This method returns the the render swatch as an image. | |
void | setRenderQuality (int) |
Method to set the render quality in which the swatch will be rendered. More... | |
int | renderQuality () const |
Returns the quality in which the swatch will be rendered. More... | |
Static Public Member Functions | |
static void | cancelCurrentSwatchRender () |
The method cancels the swatch which is being rendered in parallel, and push the swatch render item back to the render queue after. More... | |
static void | enableSwatchRender (bool enable) |
Enable/disable swatch rendering. More... | |
Protected Member Functions | |
void | finishParallelRender () |
Method to update the swatch image when the parallel rendering is finished. More... | |
MSwatchRenderBase | ( | MObject | obj, |
MObject | renderObj, | ||
int | res | ||
) |
Class constructor.
Saves the Node object and image resolution in members for future use.
[in] | obj | The node object for which the swatch needs to be generated. |
[in] | renderObj | The node which will generate the swatch. |
[in] | res | The expected resolution of the swatch image. |
|
virtual |
Method called from the MSwatchRenderRegister for generation of swatch image.
The doIteration function is called repeatedly (during idle events) until it returns true. Using this swatch image can be generated in stages.
This method should be overridden in derived classes which can compute the swatches in several steps.
Reimplemented in MHWShaderSwatchGenerator.
|
virtual |
Method indicates if the swatch is rendered parallel.
|
virtual |
Method to cancel the parallel rendering.
The derived classes should provide the implementation accordingly if required.
void setRenderQuality | ( | int | quality | ) |
Method to set the render quality in which the swatch will be rendered.
The derived classes should make sure that the larger the number is set, the better quality is applied.
[in] | quality | The quality to render the swatch |
int renderQuality | ( | ) | const |
Returns the quality in which the swatch will be rendered.
|
static |
The method cancels the swatch which is being rendered in parallel, and push the swatch render item back to the render queue after.
The render plugins should make sure that MSwatchRenderBase::cancelParallelRendering() is implemented acoordingly.
|
static |
Enable/disable swatch rendering.
[in] | enable | Flag indicating if swatch rendering should be enabled or disabled. |
|
protected |
Method to update the swatch image when the parallel rendering is finished.
If swatch is rendered parallel, this method must be called after parallel rendering finished.