C++ API Reference
|
Class to allow access to hardware draw context information. More...
#include <MDrawContext.h>
Public Member Functions | |
MMatrix | getMatrix (MFrameContext::MatrixType mtype, MStatus *ReturnStatus=NULL) const override |
Get a matrix value of a certain type. More... | |
MDoubleArray | getTuple (MFrameContext::TupleType ttype, MStatus *ReturnStatus=NULL) const override |
Get a tuple (vector, position, or single) value of a certain type. More... | |
MStatus | getViewportDimensions (int &originX, int &originY, int &width, int &height) const override |
Get the viewport dimensions. More... | |
MUint64 | getFrameStamp () const |
Returns the current frame stamp. More... | |
MBoundingBox | getSceneBox (MStatus *ReturnStatus=NULL) const |
Get a bounding box of the scene in world space. More... | |
MBoundingBox | getFrustumBox (MStatus *ReturnStatus) const |
Get the bounding box of the current view frustum in world space. More... | |
MStatus | getRenderTargetSize (int &width, int &height) const |
Get the size of the render target (output buffer) being rendered into. More... | |
MStatus | getDepthRange (float &nearVal, float &farVal) const |
Get the depth range which specifies the mapping of depth values from normalized device coordinates to window coordinates. More... | |
bool | viewDirectionAlongNegZ (MStatus *ReturnStatus) const |
Return whether the view direction is pointing down the -Z axis. More... | |
unsigned int | numberOfActiveLights (LightFilter lightFilter=kFilteredToLightLimit, MStatus *ReturnStatus=NULL) const |
Return the number of available lights to render the scene. More... | |
MStatus | getLightInformation (unsigned int lightNumber, MFloatPointArray &positions, MFloatVector &direction, float &intensity, MColor &color, bool &hasDirection, bool &hasPosition, LightFilter lightFilter=kFilteredToLightLimit) const |
Return common lighting information for a given active light. More... | |
MLightParameterInformation * | getLightParameterInformation (unsigned int lightNumber, LightFilter lightFilter=kFilteredToLightLimit) const |
Return parameter information for a given active light. More... | |
MHWRender::MStateManager * | getStateManager () const |
Access the GPU state manager for the current draw context. More... | |
const MHWRender::MPassContext & | getPassContext () const |
Access the current pass context. More... | |
const MRenderTarget * | copyCurrentColorRenderTarget (const MString &name) const |
Get a copy of the current color render target. More... | |
const MRenderTarget * | copyCurrentDepthRenderTarget (const MString &name) const |
Get a copy of the current depth render target. More... | |
MTexture * | copyCurrentColorRenderTargetToTexture () const |
Get a copy of the current color render target as a texture. More... | |
MTexture * | copyCurrentDepthRenderTargetToTexture () const |
Get a copy of the current depth render target as a texture. More... | |
const MTexture * | getInternalTexture (InternalTexture internalTexture) const |
Returns the internal texture as specified. More... | |
bool | isMultiDraw () const |
Returns true if the context is rendering in MultiDraw mode. More... | |
unsigned int | numberOfActiveLights (MStatus *ReturnStatus) const |
This method is obsolete. More... | |
Public Member Functions inherited from MFrameContext | |
virtual float | getGlobalLineWidth () const |
Get global line width. More... | |
MDagPath | getCurrentCameraPath (MStatus *ReturnStatus=NULL) const |
Get the path to the camera being used to render the current frame. More... | |
const MRenderTarget * | getCurrentColorRenderTarget () const |
Get current color render target. More... | |
const MRenderTarget * | getCurrentDepthRenderTarget () const |
Get current depth render target. More... | |
unsigned int | getDisplayStyle () const |
Get the current display style as a bit field. More... | |
LightingMode | getLightingMode () const |
Get the current light mode. More... | |
unsigned int | getLightLimit () const |
Get the current light limit. More... | |
EnvironmentParams | getEnvironmentParameters () const |
Get parameters for currently used environment. More... | |
bool | getPostEffectEnabled (PostEffectType postEffectType) const |
Returns if a given post effect is currently enabled. More... | |
HwFogParams | getHwFogParameters () const |
Get all the hardware fog parameters. More... | |
TransparencyAlgorithm | getTransparencyAlgorithm () const |
Get the current transparency algoritm. More... | |
RenderingDestination | renderingDestination (MString &destinationName) const |
Return value indicates the destination that the renderer is drawing to. More... | |
MUint64 | objectTypeExclusions () const |
Get the object type exclusions as a bitfield. More... | |
void | classificationExclusions (MStringArray &classification) const |
Get a list of drawdb strings for object which are excluded from display. More... | |
void | getBackgroundParameters (MFrameContext::BackgroundParams ¶ms) const |
Get parameters related to how the background is cleared. More... | |
void | getDOFParameters (MFrameContext::DOFParams ¶ms) const |
Get the parameters generated by Maya for the circle-of-confusion depth shader used for a pass used when computing depth of field. More... | |
void | getRenderOverrideInformation (RenderOverrideInformation &info) const |
Get information about any render override. More... | |
const MSelectionInfo * | getSelectionInfo () const |
Get the selection state information if the method is called in selection pass; nullptr will be returned otherwise. More... | |
void | worldToViewport (const MPoint &inPoint, double &xPos, double &yPos) const |
Convert coordinate in world space to coordinate in viewport. More... | |
void | viewportToWorld (double xPos, double yPos, MPoint &worldNearPt, MPoint &worldFarPt) const |
Convert coordinate in viewport to near cliping plane coordinate in world space. More... | |
Static Public Member Functions | |
static const char * | className () |
Returns the name of this class. More... | |
Static Public Member Functions inherited from MFrameContext | |
static MFrameContext::MatrixType | semanticToMatrixType (const MString &value, MStatus *ReturnStatus=NULL) |
It is assumed that these flags match between MFrameContext and TexcludeObjectDisplay, but that is not enforced elsewhere. More... | |
static MFrameContext::TupleType | semanticToTupleType (const MString &value, MStatus *ReturnStatus=NULL) |
Given a semantic name return the corresponding tuple enumeration that can be used to retrieve a value via the getTuple() method. More... | |
static bool | inUserInteraction () |
Returns true during any interactive refresh, as when user is interacting with the scene in any way including camera changes, object or component TRS changes, etc. More... | |
static bool | userChangingViewContext () |
Returns true during any interactive refresh, as when user is changing the view using view context tools such as tumble, dolly or track. More... | |
static WireOnShadedMode | wireOnShadedMode () |
Returns the global user display preference which indicates how wireframe should be drawn on top of objects while in shaded mode. More... | |
static bool | shadeTemplates () |
Returns the display preference indicating whether templated objects should be drawn shaded. More... | |
static const char * | className () |
Returns the name of this class. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from MFrameContext | |
static constexpr MUint64 | kExcludeNone = MUint64(0) |
Bit flags specifying types of objects excluded from displaying in the viewport. More... | |
static constexpr MUint64 | kExcludeNurbsCurves = MUint64(1) << (0) |
Exclude NURBS curves. | |
static constexpr MUint64 | kExcludeNurbsSurfaces = MUint64(1) << (1) |
Exclude NURBS surface. | |
static constexpr MUint64 | kExcludeMeshes = MUint64(1) << (2) |
Exclude polygonal meshes. | |
static constexpr MUint64 | kExcludePlanes = MUint64(1) << (3) |
Exclude planes. | |
static constexpr MUint64 | kExcludeLights = MUint64(1) << (4) |
Exclude lights. | |
static constexpr MUint64 | kExcludeCameras = MUint64(1) << (5) |
Exclude camera. | |
static constexpr MUint64 | kExcludeJoints = MUint64(1) << (6) |
Exclude joints. | |
static constexpr MUint64 | kExcludeIkHandles = MUint64(1) << (7) |
Exclude IK handles. | |
static constexpr MUint64 | kExcludeDeformers = MUint64(1) << (8) |
Exclude all deformations. | |
static constexpr MUint64 | kExcludeDynamics = MUint64(1) << (9) |
Exclude all dynamics objects (emiiters, cloth) | |
static constexpr MUint64 | kExcludeParticleInstancers = MUint64(1) << (10) |
Exclude all Particle Instancers. | |
static constexpr MUint64 | kExcludeLocators = MUint64(1) << (11) |
Exclude locators. | |
static constexpr MUint64 | kExcludeDimensions = MUint64(1) << (12) |
Exclude all measurement objects. | |
static constexpr MUint64 | kExcludeSelectHandles = MUint64(1) << (13) |
Exclude selection handles. | |
static constexpr MUint64 | kExcludePivots = MUint64(1) << (14) |
Exclude pivots. | |
static constexpr MUint64 | kExcludeTextures = MUint64(1) << (15) |
Exclude texure placement objects. | |
static constexpr MUint64 | kExcludeGrid = MUint64(1) << (16) |
Exclude grid drawing. | |
static constexpr MUint64 | kExcludeCVs = MUint64(1) << (17) |
Exclude NURBS control vertices. | |
static constexpr MUint64 | kExcludeHulls = MUint64(1) << (18) |
Exclude NURBS hulls. | |
static constexpr MUint64 | kExcludeStrokes = MUint64(1) << (19) |
Exclude PaintFX strokes. | |
static constexpr MUint64 | kExcludeSubdivSurfaces = MUint64(1) << (20) |
Exclude subdivision surfaces. | |
static constexpr MUint64 | kExcludeFluids = MUint64(1) << (21) |
Exclude fluid objects. | |
static constexpr MUint64 | kExcludeFollicles = MUint64(1) << (22) |
Exclude hair follicles. | |
static constexpr MUint64 | kExcludeHairSystems = MUint64(1) << (23) |
Exclude hair system. | |
static constexpr MUint64 | kExcludeImagePlane = MUint64(1) << (24) |
Exclude image planes. | |
static constexpr MUint64 | kExcludeNCloths = MUint64(1) << (25) |
Exclude N-cloth objects. | |
static constexpr MUint64 | kExcludeNRigids = MUint64(1) << (26) |
Exclude rigid-body objects. | |
static constexpr MUint64 | kExcludeDynamicConstraints = MUint64(1) << (27) |
Exclude rigid-body constraints. | |
static constexpr MUint64 | kExcludeManipulators = MUint64(1) << (28) |
Exclude manipulators. | |
static constexpr MUint64 | kExcludeNParticles = MUint64(1) << (29) |
Exclude N-particle objects. | |
static constexpr MUint64 | kExcludeMotionTrails = MUint64(1) << (30) |
Exclude motion trails. | |
static constexpr MUint64 | kExcludeHoldOuts = MUint64(1) << (31) |
Exclude Hold-Outs. | |
static constexpr MUint64 | kExcludePluginShapes = MUint64(1) << (32) |
Exclude plug-in shapes. | |
static constexpr MUint64 | kExcludeHUD = MUint64(1) << (33) |
Exclude HUD. | |
static constexpr MUint64 | kExcludeClipGhosts = MUint64(1) << (34) |
Exclude animation clip ghosts. | |
static constexpr MUint64 | kExcludeGreasePencils = MUint64(1) << (35) |
Exclude grease-pencil draw. | |
static constexpr MUint64 | kExcludeControllers = MUint64(1) << (36) |
Exclude Controllers. | |
static constexpr MUint64 | kExcludeAll = ~MUint64(0) |
Exclude all listed object types. | |
Class to allow access to hardware draw context information.
MDrawContext provides access to current hardware draw context information. It is read-only and cannot be instantiated by the plugin writer.
The information provided includes various transformation matrices, camera information, and render target information such as output buffer size. It is also possible to access and alter GPU state through this class.
There are a few main advantages for using this class:
1. The data is computed and cached as required. This can avoid work for the plugin writer to extract this information themselves. 2. The plugin writer should not need to directly access the device to extract this information. Any data extraction from the device has a performance penalty which can be avoided. 3. The information is device aware, meaning that it will return the correct results based on the current active device. For example it will return the appropriate values for DirectX versus an OpenGL device.
MDrawContext is derived from MFrameContext and provides its own implementation for all virtual methods. The values returned from these methods may differ slightly between MFrameContext and MDrawContext as MFrameContext retrieves the values from Maya and MDrawContext retrieves the values from the GPU device state.
Some information will vary from one draw to the next draw such as the object-to-world matrix which will change as different objects are being drawn.
enum LightFilter |
Options on which lights to return information for from light query methods.
enum InternalTexture |
Options on which internal texture to get.
|
overridevirtual |
Get a matrix value of a certain type.
[in] | mtype | Type of matrix to return |
[out] | ReturnStatus | Return status |
Reimplemented from MFrameContext.
|
overridevirtual |
Get a tuple (vector, position, or single) value of a certain type.
[in] | ttype | Type of information to return |
[out] | ReturnStatus | Return status |
Reimplemented from MFrameContext.
|
overridevirtual |
Get the viewport dimensions.
The origin is the upper left corner of the viewport.
[out] | originX | X coordinate of the viewport origin |
[out] | originY | Y coordinate of the viewport origin |
[out] | width | Width of the viewport |
[out] | height | Height of the viewport |
Reimplemented from MFrameContext.
MUint64 getFrameStamp | ( | ) | const |
Returns the current frame stamp.
MBoundingBox getSceneBox | ( | MStatus * | ReturnStatus = NULL | ) | const |
Get a bounding box of the scene in world space.
[out] | ReturnStatus | return status |
MBoundingBox getFrustumBox | ( | MStatus * | ReturnStatus | ) | const |
Get the bounding box of the current view frustum in world space.
[out] | ReturnStatus | return status |
MStatus getRenderTargetSize | ( | int & | width, |
int & | height | ||
) | const |
Get the size of the render target (output buffer) being rendered into.
The dimensions of the target are in pixels.
[out] | width | Width of the render target |
[out] | height | Height of the render target |
MStatus getDepthRange | ( | float & | nearVal, |
float & | farVal | ||
) | const |
Get the depth range which specifies the mapping of depth values from normalized device coordinates to window coordinates.
The depth range values are normally 0.0 and 1.0.
[out] | nearVal | Specifies the near clipping plane |
[out] | farVal | Specifies the far clipping plane |
bool viewDirectionAlongNegZ | ( | MStatus * | ReturnStatus | ) | const |
Return whether the view direction is pointing down the -Z axis.
Different devices will have difference conventions. For OpenGL the conventions is -Z. For DirectX the convention is +Z.
[out] | ReturnStatus | return status |
unsigned int numberOfActiveLights | ( | LightFilter | lightFilter = kFilteredToLightLimit , |
MStatus * | ReturnStatus = NULL |
||
) | const |
Return the number of available lights to render the scene.
This method takes into consideration the VP2.0 lighting mode options, whether lights are visible, and whether the light is a member of the default light set (illuminates by default).
When the light mode is set to use all lights, if the lightFilter argument is set to be 'kFilteredIgnoreLightLimit', then the light limit value in the VP2.0 settings will be ignored. Otherwise the value returned is clamped to the light limit.
[in] | lightFilter | Only consider lights which pass this filter option. The default value is kFilteredToLightLimit. |
[out] | ReturnStatus | return status |
MStatus getLightInformation | ( | unsigned int | lightNumber, |
MFloatPointArray & | positions, | ||
MFloatVector & | direction, | ||
float & | intensity, | ||
MColor & | color, | ||
bool & | hasDirection, | ||
bool & | hasPosition, | ||
LightFilter | lightFilter = kFilteredToLightLimit |
||
) | const |
Return common lighting information for a given active light.
Note that any ambient lighting information is returned as the last light.
[in] | lightNumber | Light index number starting from 0 to the number of lights returned from numberOfActiveLights() minus one. Index 0 indicates the first light. There is no correspondance to fixed-function OpenGL light indices. |
[out] | positions | The world space positions on a light. If a light is purely directional or represents ambient lighting then the position value has no meaning and the return value will be an empty array. In all other cases except for area lights a single position entry will be returned. Multiple positions are returned to represent different sample points on area lights. |
[out] | direction | The world space direction of the light. If a light is purely positional or represents ambient lighting then the direction value has no meaning and will be set to a value of (0,0,0,1). |
[out] | intensity | The intensity of the light. |
[out] | color | The color value of the light. |
[out] | hasDirection | This will indicate if the light has any directional properties. |
[out] | hasPosition | This will indicate if the light has any positional properties. |
[in] | lightFilter | Only consider lights which pass this filter option. The default value is kFilteredToLightLimit. |
MLightParameterInformation * getLightParameterInformation | ( | unsigned int | lightNumber, |
LightFilter | lightFilter = kFilteredToLightLimit |
||
) | const |
Return parameter information for a given active light.
[in] | lightNumber | Light index number starting from 0 to the number of lights returned from numberOfActiveLights() minus one. Index 0 indicates the first light. There is no correspondance to fixed-function OpenGL light indices. |
[in] | lightFilter | Only consider lights which pass this filter option. The default value is kFilteredToLightLimit. |
MHWRender::MStateManager * getStateManager | ( | ) | const |
Access the GPU state manager for the current draw context.
const MHWRender::MPassContext & getPassContext | ( | ) | const |
Access the current pass context.
const MRenderTarget * copyCurrentColorRenderTarget | ( | const MString & | name | ) | const |
Get a copy of the current color render target.
When the object is no longer needed, MRenderTargetManager::releaseRenderTarget() should be called to notify the target manager that the caller is done with the render target.
[in] | name | Unique name for copy. A non-empty string must be provided otherwise the method will fail. |
const MRenderTarget * copyCurrentDepthRenderTarget | ( | const MString & | name | ) | const |
Get a copy of the current depth render target.
When the object is no longer needed, MRenderTargetManager::releaseRenderTarget() should be called to notify the target manager that the caller is done with the render target.
[in] | name | Unique name for copy. A non-empty string must be provided otherwise the method will fail. |
MTexture * copyCurrentColorRenderTargetToTexture | ( | ) | const |
Get a copy of the current color render target as a texture.
When the texture is no longer needed, MTextureManager::releaseTexture() should be called.
MTexture * copyCurrentDepthRenderTargetToTexture | ( | ) | const |
Get a copy of the current depth render target as a texture.
When the texture is no longer needed, MTextureManager::releaseTexture() should be called.
const MTexture * getInternalTexture | ( | InternalTexture | internalTexture | ) | const |
Returns the internal texture as specified.
The internal texture is owned by MDrawContext and only valid during the lifetime of the MDrawContext object.
[in] | internalTexture | Specifies which internal texture to get. |
bool isMultiDraw | ( | ) | const |
Returns true if the context is rendering in MultiDraw mode.
|
static |
Returns the name of this class.
unsigned int numberOfActiveLights | ( | MStatus * | ReturnStatus | ) | const |
This method is obsolete.
[as of Maya 2019]
[out] | ReturnStatus | return status |