MPxGeometryOverride Class Reference


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 void  updateDG ()=0
  Perform any work required to translate the geometry data that needs to get information from the dependency graph.
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, 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

void updateDG ( ) [pure virtual]

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.

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

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,
MGeometry data 
) [pure virtual]

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.

Parameters:
[in] requirements The requirements that need to be satisfied
[out] data The container for the geometry data
void cleanUp ( ) [pure virtual]

Called after all other stages are completed.

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

const char * className ( ) [static]

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