Class to allow access to hardware draw context information.
MDrawContext provides access to current hardware draw context information when drawing is performed in either MPxShaderOverride or MPxDrawOverride.
MDrawContext 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 calss.
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.
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.
#include <MDrawContext.h>
Public Types |
|
enum |
MatrixType { kWorldMtx, kWorldTransposeMtx, kWorldInverseMtx, kWorldTranspInverseMtx, kViewMtx, kViewTransposeMtx, kViewInverseMtx, kViewTranspInverseMtx, kProjectionMtx, kProjectionTranposeMtx, kProjectionInverseMtx, kProjectionTranspInverseMtx, kViewProjMtx, kViewProjTranposeMtx, kViewProjInverseMtx, kViewProjTranspInverseMtx, kWorldViewMtx, kWorldViewTransposeMtx, kWorldViewInverseMtx, kWorldViewTranspInverseMtx, kWorldViewProjMtx, kWorldViewProjTransposeMtx, kWorldViewProjInverseMtx, kWorldViewProjTranspInverseMtx } |
Matrices that can be accessed. More... |
|
enum | TupleType { kViewPosition, kViewDirection, kViewUp, kViewRight } |
Vectors or positions that can be accessed. More... |
|
enum | DisplayStyle { kGouraudShaded = 0x1, kWireFrame = 0x2 } |
Display style. More... |
|
Public Member Functions |
|
MFloatMatrix | getMatrix (MDrawContext::MatrixType mtype, MStatus *ReturnStatus=NULL) const |
Get a matrix value of a certain type.
|
|
MFloatArray | getTuple (MDrawContext::TupleType ttype, MStatus *ReturnStatus=NULL) const |
Get a tuple (vector or position) value of a
certain type. |
|
MBoundingBox | getSceneBox (MStatus *ReturnStatus=NULL) const |
Get a bounding box of the scene in world
space. |
|
MStatus | getViewportDimensions (int &originX, int &originY, int &width, int &height) const |
Get the viewport dimensions. |
|
MStatus | getRenderTargetSize (int &width, int &height) const |
Get the size of the render target (output
buffer) being rendered into. |
|
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. |
|
bool | viewDirectionAlongNegZ (MStatus *ReturnStatus) const |
Return whether the view direction is
pointing down the -Z axis. |
|
unsigned int | numberOfActiveLights (MStatus *ReturnStatus=NULL) const |
Return the number of active lights being
used to render the scene. |
|
MStatus | getLightInformation (unsigned int lightNumber, MFloatPoint &position, MFloatVector &direction, float &intensity, MColor &color, bool &hasDirection, bool &hasPosition) const |
Return common lighting information for a
given active light. |
|
int | getDisplayStyle () const |
Get the current display style as a bit field
(see DisplayStyle enum). |
|
MHWRender::MStateManager * | getStateManager () const |
Access the GPU state manager for the current
draw context. |
|
Static Public Member Functions |
|
static const char * | className () |
Returns the name of this class. |
enum MatrixType |
Matrices that can be accessed.
enum TupleType |
Vectors or positions that can be accessed.
enum DisplayStyle |
Display style.
MFloatMatrix getMatrix | ( | MDrawContext::MatrixType | mtype, |
MStatus * | ReturnStatus =
NULL |
||
) | const |
Get a matrix value of a certain type.
[in] | mtype | Type of matrix to return. Refer to enumerations for allowable values. |
[out] | ReturnStatus | return status |
MFloatArray getTuple | ( | MDrawContext::TupleType | ttype, |
MStatus * | ReturnStatus =
NULL |
||
) | const |
Get a tuple (vector or position) value of a certain type.
[in] | ttype | Type of vector or position to return. Refer to enumerations for allowable values. |
[out] | ReturnStatus | return status |
MBoundingBox getSceneBox | ( | MStatus * | ReturnStatus =
NULL |
) | const |
Get a bounding box of the scene in world space.
[out] | ReturnStatus | return status |
MStatus getViewportDimensions | ( | int & | originX, |
int & | originY, | ||
int & | width, | ||
int & | height | ||
) | const |
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 |
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 | ( | MStatus * | ReturnStatus =
NULL |
) | const |
Return the number of active lights being used to render the scene.
[out] | ReturnStatus | return status |
MStatus getLightInformation | ( | unsigned int | lightNumber, |
MFloatPoint & | position, | ||
MFloatVector & | direction, | ||
float & | intensity, | ||
MColor & | color, | ||
bool & | hasDirection, | ||
bool & | hasPosition | ||
) | const |
Return common lighting information for a given active light.
[in] | lightNumber | Light index number starting from 0 to the number of lights returned from numberOfActiveLights() one minus. Index 0 indicates the first light. There is no correspondance to fixed-function OpenGL light indices. |
[out] | position | The world space position of the light. If a light is purely directional then the position value has no meaning and will be set to a value of (0,0,0). |
[out] | direction | The world space direction of the light. If a light is purely positional 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. |
int getDisplayStyle | ( | ) | const |
Get the current display style as a bit field (see DisplayStyle enum).
MHWRender::MStateManager * getStateManager | ( | ) | const |
Access the GPU state manager for the current draw context.
const char * className | ( | ) | [static] |