Python API 2.0 Reference
OpenMayaRender.MPxSubSceneOverride Class Reference
+ Inheritance diagram for OpenMayaRender.MPxSubSceneOverride:

Public Member Functions

def __init__ ()
 
def addInstanceTransform ()
 
def addUIDrawables ()
 
def areUIDrawablesDirty ()
 
def furtherUpdateRequired ()
 
def getInstancedSelectionPath ()
 
def getSelectionPath ()
 
def hasUIDrawables ()
 
def removeAllInstances ()
 
def removeExtraInstanceData ()
 
def removeInstance ()
 
def requiresUpdate ()
 
def setAllowTransparentInstances ()
 
def setExtraInstanceData ()
 
def setGeometryForRenderItem ()
 
def setInstanceTransformArray ()
 
def supportedDrawAPIs ()
 
def update ()
 
def updateInstanceTransform ()
 
def updateSelectionGranularity ()
 

Static Public Member Functions

def __new__ ()
 
def pointSnappingActive ()
 

Detailed Description

Base class for Viewport 2.0 drawing of DAG nodes which represent sub-scenes.

Constructor & Destructor Documentation

def OpenMayaRender.MPxSubSceneOverride.__init__ ( )
Initialize self.  See help(type(self)) for accurate signature.

Member Function Documentation

def OpenMayaRender.MPxSubSceneOverride.__new__ ( )
static
Create and return a new object.  See help(type) for accurate signature.
def OpenMayaRender.MPxSubSceneOverride.addInstanceTransform ( )
addInstanceTransform(renderItem, transform) -> int

Returns The instance ID for the new instance. This ID can be used to change the matrix or remove it. A return value of 0 indicates an error (render item does not support instancing or invalid state). 0 is never a valid instance ID.

Add an additional instance for a render item.  Will convert the MRenderItem to instanced rendering if not already done. The render item should already have it's other properties set (including shader and geometry).  A render item converted to instanced rendering will ignore its typical matrix from setMatrix().

* renderItem (MRenderItem) - The render item to add a new instance to.
* transform (MMatrix) - The transformation matrix of the new instance.
def OpenMayaRender.MPxSubSceneOverride.addUIDrawables ( )
addUIDrawables(drawManager, frameContext) -> int

Provides access to a MUIDrawManager, which can be used to queue upoperations to draw simple UI shapes like lines, circles, text, etc.If you override this method you must also override hasUIDrawables()to return true, otherwise this method will not be called.If you are not going to override this function, please don't make 'hasUIDrawables()' return trueor there may be some wasted performance overhead.By default the drawables will persist until either the DAG object associated with the overrideis destroyed or the override is deregistered.If you don't want them to be redrawn on each refresh,override areUIDrawablesDirty() to return false.That will cause the drawables to be destroyedon next refresh and this method called again to replace them.

drawManager The UI draw manager, it can be used to draw some simple geometry including text
frameContext Frame level context information
def OpenMayaRender.MPxSubSceneOverride.areUIDrawablesDirty ( )
areUIDrawablesDirty() -> bool

Determines whether addUIDrawables() should be called on the next refresh.

Return  True if addUIDrawables() should be called on the next refresh, false if not.The default is true.

If you've overridden addUIDrawables() then at the start of each refresh Maya willdestroy the drawables added in the previous refresh and call addUIDrawables() again.If you override this method to return false then Maya will preserve the UI drawablesfrom the previous refresh until either the DAG object associated with the override isdestroyed, or the override is deregistered.
def OpenMayaRender.MPxSubSceneOverride.furtherUpdateRequired ( )
furtherUpdateRequired(frameContext) -> bool

Returns True if further update is required. The default value return is False.

This method is called by Maya following update() to allow the override to indicate whether further processing is required.

If so, then requiresUpdate() and update() will be called again at a later time. In general this will occur when no active processing is occuring (when "idle").

It is the responsibility of the plug-in to ensure that this method does not continuously request further updates as it may block the execution of other idle time events.

* frameContext (MFrameContext) - Context information for the current frame.
def OpenMayaRender.MPxSubSceneOverride.getInstancedSelectionPath ( )
getInstancedSelectionPath(renderItem, intersection, dagPath) -> bool

Returns True if a dag path was found for the instantiable render item.

This method is called by Maya following selection to allow specifying the selection path for a single instantiable render item. It is identical to getSelectionPath() but includes MIntersection information to properly distinguish between instances when the viewport is in GPU acceleration mode.

In GPU acceleration mode, the renderItem will be the one of the master instance and the value of intersection.instanceID() will match the value returned by addInstanceTransform(). In regular non GPU accelerated mode, the renderItem will be the one directly associated with the instance. If intersection.instanceID() is equal to -1, then the geometry was not GPU accelerated.

* renderItem (MRenderItem) - Render item found inside the selection frustum, or master item in GPU accelerated mode.
* intersection (MIntersection) - Extra information to help find out how the render item got selected.
* dagPath [OUT] (MDagPath) - the MDagPath associated with the provided render item.
def OpenMayaRender.MPxSubSceneOverride.getSelectionPath ( )
getSelectionPath(renderItem, dagPath) -> bool

Returns True if a dag path was found for the render item.

This method is called by Maya following selection to allow specifying the selection path for a single render item. It will be called once for each MRenderItem submitted in MPxSubSceneOverride.update() that intersects the selection frustum. If none of the MRenderItem intersects, then this callback will remain silent.

When selection filtering is active, or in case of single click selection it is possible that the item will not be in the final selection list.

The default implementation will return the first path to the associated DAG object. Specialization is required to provide support for multiple instances of the DAG object.

Note: If your SubScene override plugin supports instancing, then you should overload getInstancedSelectionPath() instead to get all the necessary information to be able to return a proper path.

* renderItem (MRenderItem) - Render item found inside the selection frustum.
* dagPath [OUT] (MDagPath) - the MDagPath associated with the provided render item.
def OpenMayaRender.MPxSubSceneOverride.hasUIDrawables ( )
hasUIDrawables() -> bool

Return Whether addUIDrawables() will be called or not.

In order for any override for the addUIDrawables() method to be calledthis method must also be overridden to return true.This method should not be overridden if addUIDrawables() has not alsobeen overridden as there may be associated wasted overhead.
def OpenMayaRender.MPxSubSceneOverride.pointSnappingActive ( )
static
pointSnappingActive() -> bool

Returns True if selection has been launched to find snap points.
To participate, you need to have at least one render item with point geometry
and MSelectionMask.kSelectPointsForGravity set in MRenderItem.selectableMask().
- The granularity must be set to MSelectionContext.kComponent in updateSelectionGranularity()
- A component converter is not necessary in this scenario.
- getSelectionPath() will not be called. All points present in the render item will be
considered suitable locations for snapping.
def OpenMayaRender.MPxSubSceneOverride.removeAllInstances ( )
removeAllInstances(renderItem) -> self

Remove all instances for a render item. This render item will remain set up for instancing and will render nothing until new instances are added.

* renderItem (MRenderItem) - The render item to operate on.
def OpenMayaRender.MPxSubSceneOverride.removeExtraInstanceData ( )
removeExtraInstanceData(renderItem, parameterName) -> self

Remove an entire extra instance data stream from the instanced render item.

* renderItem (MRenderItem) - The render item to operate on.
* parameterName (string) - The name of the parameter associated with the extra instance data stream.
def OpenMayaRender.MPxSubSceneOverride.removeInstance ( )
removeInstance(renderItem, instanceId) -> self

Remove one instance of a render item.

* renderItem (MRenderItem) - The render item to operate on.
* instanceId (int) - The instance ID of the instance to remove. This must be a value returned by addInstanceTransform.
def OpenMayaRender.MPxSubSceneOverride.requiresUpdate ( )
requiresUpdate(container, frameContext) -> bool

On each frame Maya will give each instantiated MPxSubSceneOverride object a chance to update its set of render items. Before beginning the update process for a specific override, Maya will first call this method to give the override a chance to indicate whether or not an update is necessary. If this method returns False, MPxSubSceneOverride.update() will not be called.

The set of render items for this override must not be modified in this method.

* container (MSubSceneContainer) - The container for this override
* frameContext (MFrameContext) - Context information for the current frame

Returns True if Maya should trigger the update process for this override
def OpenMayaRender.MPxSubSceneOverride.setAllowTransparentInstances ( )
setAllowTransparentInstances(renderItem, transform) -> int

Instancing is disabled automatically by default when the shader is transparent.This achieves the best appearance because Maya can sort individual instances.

In some cases, performance is more important than appearance.e.g.particlesThis method allows to override the default behavior.

renderItem The render item to operate on.
allow Whether to allow instancing with transparent shader.
def OpenMayaRender.MPxSubSceneOverride.setExtraInstanceData ( )
setExtraInstanceData(renderItem, parameterName, data, instanceId=None) -> self

Adds an extra stream of instanced data to an instanced render item. Once a render item has been instanced, additional per-instance data may be bound to a parameter on the shader for that item. Supported shader parameter types for instanced data include: float, float2, float3 and float4. Once a stream of instanced data is specified for a shader parameter, the original value of that parameter will be ignored in favor of the per-instance data specified in this method.

If the render item has not been set up for instancing or if an invalid parameter was specified this method will fail. The size of the data array must be x*numberOfInstances where x is the size of the channel (1-4). If the size is wrong, the method will fail.

More than one stream of extra instance data may be specified for an instanced render item. The number of streams will be limited by the number of texture co-ordinate channels available from the underlying graphics system (and note that the instanced matrix occupies four streams). If too many streams are used then a red error shader will be displayed instead of the expected shader.

* renderItem (MRenderItem) - The render item to operate on.
* parameterName (string) - The name of the parameter on the shader to fill with the instanced data.
* data (MFloatArray) - The instanced data stream.
* instanceId (int) - The instance ID of the instance to set the data for.
def OpenMayaRender.MPxSubSceneOverride.setGeometryForRenderItem ( )
setGeometryForRenderItem(renderItem, vertexBuffers, indexBuffer=None, objectBox=None) -> self

Call this method to provide the geometry for a render item. Although the render item will add a reference to each buffer, ultimate ownership of the geometric data remains with the caller. This method may only be called on render items which have been generated by this override and it may only be called during update(). Buffers may be shared among multiple render items. This method will replace any geometry currently associated with the render item with the newly provided geometry.

The bounding box parameter to this method is optional. If None, Maya will attempt to calculate the box automatically. Note that this may require a read-back of vertex data from the graphics card which can be a very slow operation. It is better to supply a correct bounding box whenever possible.

It is the responsibility of the caller to ensure that the buffers provided fulfill the geometry requirements of the shader for the render item. If the requirements are not met, the render item will not draw. If there is no shader assigned to the render item, this method will fail.

When a geometry is completely defined by its vertex buffers, like when drawing all points in a MGeometry.kPoints render item, it is possible to provide an empty MIndexBuffer or None for the indexBuffer parameter. The geometry will then be drawn using a non-indexed draw call like glDrawArrays() or ID3D11DeviceContext::Draw().

* renderItem (MRenderItem) - The render item to provide geometry for.
* vertexBuffers (MVertexBufferArray) - The vertex buffers for the geometry.
* indexBuffer (MIndexBuffer) - The index buffer for the geometry, may be None.
* objectBox (MBoundingBox) - Object-space bounding box, may be None.
def OpenMayaRender.MPxSubSceneOverride.setInstanceTransformArray ( )
setInstanceTransformArray(renderItem, matrixArray) -> self

Sets the entire instance array for a render item.  Will convert the MRenderItem to instanced rendering if not already done.  Any pre-existing instances will be removed. The render item should already have it's other properties set (including shader and geometry). A render item converted to instanced rendering will ignore its typical matrix from setMatrix().
This function is provided as a simpler alternative to addInstanceTransform() for when the ability to update or remove individual instances is not required. However additional instances may still be added via addInstanceTransform() and those may be individually updated or removed.

* renderItem (MRenderItem) - The render item to set the instance matrix array for.
* matrixArray (MMatrixArray) - The transformation matrix array for all the instances.
def OpenMayaRender.MPxSubSceneOverride.supportedDrawAPIs ( )
supportedDrawAPIs() -> DrawAPI

Returns the draw API supported by this override.
def OpenMayaRender.MPxSubSceneOverride.update ( )
update(container, frameContext) -> self

This method is called by Maya on each frame as long as the implementation of MPxSubSceneOverride.requiresUpdate() returns True. In this method, the MSubSceneContainer should be populated with the render items that are required to draw the associated DAG object. The render items will remain in the container until they are explicitly removed or the associated object is deleted. Render items in the container may also be modified at this time. 

All render items in the container upon completion of this method will be processed for drawing. Any such items which pass all filtering tests for the active viewport will draw. At a minimum, render items must be enabled, have a valid shader and valid geometry in order to draw in Viewport 2.0. 

It is the responsibility of this method to call MRenderer.setLightsAndShadowsDirty() to trigger recomputation of any shadow maps in the scene (if required). 

* container (MSubSceneContainer) - The container for this override
* frameContext (MFrameContext) - Context information for the current frame
def OpenMayaRender.MPxSubSceneOverride.updateInstanceTransform ( )
updateInstanceTransform(renderItem, instanceId, transform) -> self

Update the instance transform matrix for one instance of a render item.

* renderItem (MRenderItem) - The render item to operate on.
* instanceId (int) - The instance ID of the instance to update. This must be a value returned by addInstanceTransform.
* transform (MMatrix) - The new transformation matrix for the instance.
def OpenMayaRender.MPxSubSceneOverride.updateSelectionGranularity ( )
updateSelectionGranularity(path, selectionContext) -> self

This method is called during the pre-filtering phase of the viewport 2.0 selection and is used to allow derived classes to modify the selection context of the given DAG object.

This is useful to specify the selection level, which defines what can be selected on the object :
  MSelectionContext.kNone        Nothing can be selected
  MSelectionContext.kObject      Object can be selected as a whole
  MSelectionContext.kComponent   Parts of the object - such as vertex, edge or face - are selectable
This is used to discard objects that are not selectable given the current selection mode (see MGlobal.selectionMode()).

Implementation of this method here is empty, and default selection level is set to kObject.

 path (MDagPath) - The path to the instance to update the selection context for
 selectionContext [OUT] (MSelectionContext) - The selection context