- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions

# MPxGeometryOverride Class Reference

# OpenMayaRender - API module for rendering | Proxy classes

This reference page is linked to from the following overview topics: Data Classes, Scene Overrides, Framework Classes, Transition Guide, Devkit Samples.

Search for all occurrences

## Detailed Description

Base for user-defined classes to prepare geometry for drawing.

MPxGeometryOverride allows the user to create an override to prepare vertex data that will be used to draw a specific Maya DAG object type with an arbitrary shader (standard Maya or custom) in Viewport 2.0.

This class is designed to be a high level data-translator independent of any specific hardware draw API. Once registered through MDrawRegistry, an instance will be created for each node with a matching classification string. That instance will be used to generate the vertex streams needed by the assigned shaders in order to draw the object. The intent of this class is that it be used to provide data for plugin shape types (MPxSurfaceShape) however it can also be used to override the geometry translation for any Maya geometry type.

If a more low-level interface to the Viewport 2.0 draw loop is needed, look at either MPxDrawOverride or MPxShaderOverride.

Users of this interface must implement several virtual methods which will be called at specific times during the draw-preparation phase.

1) updateDG() : In the updateDG() call, all data needed to compute the indexing and geometry data must be pulled from Maya and cached. It is invalid to query attribute values from Maya nodes in any later stage and doing so may result in instability.

2) updateRenderItems() : For each shader assigned to the instance of the object Maya will assign a render item. A render item is a single atomic renderable entity containing a shader and some geometry. In updateRenderItems(), implementations of this class may enable or disable the automatic shader-based render items and they may add or remove custom user defined render items in order to cause additional things to be drawn. Look at the MRenderItem interface for more details.

3) populateGeometry() : In this method the implementation is expected to fill the MGeometry data structure with the vertex and index buffers required to draw the object as indicated by the data in the geometry requirements instance passed to this method. Failure to fulfill the geometry requirements may result in incorrect drawing or possibly complete failure to draw the object.

4) cleanUp() : Delete any cached data generated in the earlier phases that is no longer needed.

The override is only triggered when the associated DAG object has changed and that object is about to be drawn. So it is not invoked if the user is simply tumbling the scene, or if the object is not within the current view frustum.

Implementations of MPxGeometryOverride must be registered with Maya through MDrawRegistry.

`#include <MPxGeometryOverride.h>`

List of all members.

## Public Member Functions
| MPxGeometryOverride (const MObject &obj)
| Construct an MPxGeometryOverride.
virtual | ~MPxGeometryOverride ()
| Destructor.
virtual MHWRender::DrawAPI | supportedDrawAPIs () const
| Returns the draw API supported by this override.
virtual void | updateDG ()=0
| Perform any work required to translate the geometry data that needs to get information from the dependency graph.
virtual bool | isIndexingDirty (const MRenderItem &item)
| This method is called for each render item on the assocated DAG object whenever the object changes.
virtual bool | isStreamDirty (const MVertexBufferDescriptor &desc)
| This method is called for each geometry stream on the assocated DAG object whenever the object changes.
virtual void | updateRenderItems (const MDagPath &path, MRenderItemList &list)=0
| This method is called for each instance of the associated DAG object whenever the object changes.
virtual void | populateGeometry (const MGeometryRequirements &requirements, MHWRender::MRenderItemList &renderItems, MGeometry &data)=0
| Implementations of this method should produce create and populate vertex and index buffers on the MGeometry instance 'data' in order to fulfill all of the geometry requirements defined by the 'requirements' parameter.
virtual void | cleanUp ()=0
| Called after all other stages are completed.
## Static Public Member Functions
static const char * | className ()
| Returns the name of this class.

## Constructor & Destructor Documentation

MPxGeometryOverride | ( | const MObject & | obj | ) |

Construct an MPxGeometryOverride.

Parameters:

  [in] | obj | The DAG object this override translates

## Member Function Documentation

MHWRender::DrawAPI supportedDrawAPIs | ( |  | ) | const `[virtual]`

Search for all occurrences

Returns the draw API supported by this override.

The returned value may be formed as the bitwise 'or' of MHWRender::DrawAPI elements to indicate that the override supports multiple draw APIs. This method returns 'MHWRender::kOpenGL' by default.

Returns:
  The draw API supported by this override

void updateDG | ( |  | ) | `[pure virtual]`

Search for all occurrences

Perform any work required to translate the geometry data that needs to get information from the dependency graph.

This should be the only place that dependency graph evaluation occurs. Any data retrieved should be cached for later stages.

bool isIndexingDirty | ( | const MRenderItem & | item | ) | `[virtual]`

Search for all occurrences

This method is called for each render item on the assocated DAG object whenever the object changes.

This method is passed a render item. This method should return true if the indexing for the render item has changed since the last frame. Note that returning false from isIndexingDirty may NOT prevent populate geometry from requiring that an index buffer is updated.

Parameters:

  [in] | item | The render item in question

Returns:
  True if the index buffer needs to be updated

bool isStreamDirty | ( | const MVertexBufferDescriptor & | desc | ) | `[virtual]`

Search for all occurrences

This method is called for each geometry stream on the assocated DAG object whenever the object changes.

This method is passed a vertex buffer descriptor representing one stream on the object to be updated. This method should return true if it is safe to reuse the existing buffer rather than filling a new buffer with data. Note that returning false from isStreamDirty may NOT prevent populateGeometry from requiring that a stream be updated.

Parameters:

  [in] | desc | The description of the vertex buffer

Returns:
  True if the vertex buffer needs to be updated

void updateRenderItems | ( | const MDagPath & | path,
|  | MRenderItemList & | list
| ) |  | `[pure virtual]`

Search for all occurrences

This method is called for each instance of the associated DAG object whenever the object changes.

The method is passed the path to the instance and the current list of render items associated with that instance. By default the list will contain one render item for each shader assigned to the instance. Implementations of this method method may add, remove or modify items in the list. Note that removal of items created by Maya for assigned shaders is not allowed and will fail. As an alternative this method can disable those items so that they do not draw.

Parameters:

  [in] | path | The path to the instance to update render items for
  [in,out] | list | The current render item list, items may be modified, added or removed.

void populateGeometry | ( | const MGeometryRequirements & | requirements,
|  | MHWRender::MRenderItemList & | renderItems,
|  | MGeometry & | data
| ) |  | `[pure virtual]`

Search for all occurrences

Implementations of this method should produce create and populate vertex and index buffers on the MGeometry instance 'data' in order to fulfill all of the geometry requirements defined by the 'requirements' parameter.

Failure to do so will result in the object either drawing incorrectly or not drawing at all. See the documentation of MGeometryRequirements and MGeometry for more details on the usage of these classes. The geometry requirements will ask for index buffers on demand. Implementations can force the geometry requirements to update index buffers by calling MHWRender::MRenderer::setGeometryDrawDirty() with topologyChanged setting to true.

Parameters:

  [in] | requirements | The requirements that need to be satisfied.
  [in,out] | renderItems | The list of render items that need to be updated.
  [out] | data | The container for the geometry data

void cleanUp | ( |  | ) | `[pure virtual]`

Search for all occurrences

Called after all other stages are completed.

Clean up any cached data stored from the updateDG() phase.

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  Name of this class.

MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride
MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride MPxGeometryOverride