MRenderUtilities Class Reference
#include <MRenderUtilities.h>
Utilities for Viewport 2.0.
This class is a utility class for rendering in Viewport 2.0
static MDrawContext * acquireSwatchDrawContext (const MRenderTarget *colorTarget=NULL, const MRenderTarget *depthTarget=NULL)
Acquire a draw context fit for rendering a swatch into the provided render targets. More...
static MDrawContext * acquireUVTextureDrawContext (const MRenderTarget *colorTarget=NULL, const MRenderTarget *depthTarget=NULL)
Acquire a draw context fit for rendering a texture for the UV editor into the provided render targets. More...
static void releaseDrawContext (MDrawContext *context, bool releaseTargets=true)
Release a draw context. More...
static void swatchBackgroundColor (float &r, float &g, float &b, float &a)
This method returns the default background color for the hardware rendered swatch. More...
static MStatus blitTargetToImage (const MRenderTarget *target, MImage &image)
Copy the data from a target to an image. More...
static MStatus blitTargetToGL (const MRenderTarget *target, const float region[2][2], bool unfiltered)
Blit the data from a target to current GL context. More...
static MStatus drawSimpleMesh (MDrawContext &context, const MVertexBuffer &vertexBuffer, const MIndexBuffer &indexBuffer, MGeometry::Primitive primitiveType, int start, int count)
Render a simple mesh. More...
static MStatus renderMaterialViewerGeometry (const MString &shape, MObject shaderNode, MImage &image, MaterialViewerCamera cameraMode=kPerspectiveCamera , MaterialViewerLights lightRig=kDefaultLights )
Do an off-screen render replicating the results shown by the Material Viewer window of Hypershade. More...
static const char * className ()
Returns the name of this class. More...
Camera positions supported by the Material Viewer.
Enumerator kPerspectiveCamera
Perspective camera with Material Viewer settings.
kOrthogonalCameraWithMargin
Orthogonal camera with margins as wide as perspective camera for planar swatches.
kOrthogonalCameraCloseUp
Orthogonal camera set up to fully capture a MaterialViewerShape::kPlaneShape for UV editor images.
Light rigs supported by the Material Viewer.
Enumerator kDefaultLights
Material Viewer default light rig.
kSwatchLight
Single directional swatch light.
kAmbientLight
Ambient light scheme.
Acquire a draw context fit for rendering a swatch into the provided render targets.
The caller is responsible for releasing the draw context when it is no longer needed, by calling MRenderUtilities::releaseDrawContext() . If no targets are specified, then the caller will also have to properly setup render targets before drawing. Specifying targets also insures that the proper GL context is made active when using GL devices.
Parameters
[in] colorTarget The color target for swatch drawing. Can be NULL.
[in] depthTarget The depth target for swatch drawing. Can be NULL.
Returns The draw context, NULL on failure.
Acquire a draw context fit for rendering a texture for the UV editor into the provided render targets.
The caller is responsible for releasing the draw context when it is no longer needed, by calling MRenderUtilities::releaseDrawContext() . If no targets are specified, then the caller will also have to properly setup render targets before drawing. Specifying targets also insures that the proper GL context is made active when using GL devices.
Parameters
[in] colorTarget The color target for UV texture drawing. Can be NULL.
[in] depthTarget The depth target for UV texture drawing. Can be NULL.
Returns The draw context, NULL on failure.
void releaseDrawContext
(
MDrawContext *
context ,
bool
releaseTargets = true
)
static
Release a draw context.
If releaseTargets is requested, the device will have NULL targets on function exit.
Parameters
[in] context The draw context to delete
[in] releaseTargets Removes the current draw targets from the device, defaults to true.
void swatchBackgroundColor
(
float &
r ,
float &
g ,
float &
b ,
float &
a
)
static
This method returns the default background color for the hardware rendered swatch.
Parameters
[out] r The value for the red component.
[out] g The value for the green component.
[out] b The value for the blue component.
[out] a The value for the alpha component.
Copy the data from a target to an image.
Only 2D targets and targets with the following formats are supported
kR8G8B8A8_UNORM
kB8G8R8A8
kA8B8G8R8
kR32_FLOAT
kR32G32_FLOAT
kR32G32B32_FLOAT
kR32G32B32A32_FLOAT 8-bits formats only works with byte typed image. Float formats only works with float typed image and same number of channels.
Parameters
[in] target The source target to get the data from.
[in] image The destination image to copy the data to.
Returns Status code
Status Codes:
Blit the data from a target to current GL context.
Only 2D targets and targets with the following formats are supported
kR8G8B8A8_UNORM
kB8G8R8A8
kA8B8G8R8
kR32_FLOAT
kR32G32_FLOAT
kR32G32B32_FLOAT
Parameters
[in] target The source target to get the data from.
[in] region Rectangular region to be rendered.
[in] unfiltered Render with hardware filtering or sharply defined pixels.
Returns Status code
Status Codes:
Render a simple mesh.
Parameters
[in] context The draw context to use for render.
[in] vertexBuffer The vertex buffer for the mesh.
[in] indexBuffer The index buffer for the mesh.
[in] primitiveType The primitive type of the mesh.
[in] start The location of the first index read from the index buffer.
[in] count The number of indices to draw.
Returns
MS::kSuccess Draw operation was successful.
MS::kInvalidParameter Draw operation aborted because context, vertexBuffer or indexBuffer was invalid.
MS::kFailure Draw operation failed.
Do an off-screen render replicating the results shown by the Material Viewer window of Hypershade.
Parameters
[in] shape Shape to render. Valid values include "meshSphere", "meshPlane", "meshShaderball", "meshTeapot", "meshCloth", and "meshHair".
[in] shaderNode The shader node to use on the geometry.
[in] image The image where the result should be stored.
[in] cameraMode The camera to use for rendering. Defaults to MRenderUtilities::kPerspectiveCamera .
[in] lightRig The light rig to use for rendering. Defaults to MRenderUtilities::kDefaultLights .
Returns
MS::kSuccess Render was successful.
MS::kFailure Render failed.
MS::kInvalidParameter An invalid parameter was provided.
MS::kInsufficientMemory The operation failed due to insufficient memory.
const char * className
(
)
static
Returns the name of this class.
Returns The name of this class.
The documentation for this class was generated from the following files:
MRenderUtilities.h
MRenderUtilities.cpp