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

Public Member Functions

def __init__ ()
 
def allowIsolateSelectCopy ()
 
def associateWithIndexBuffer ()
 
def availableShaderParameters ()
 
def boundingBox ()
 
def castsShadows ()
 
def component ()
 
def customData ()
 
def depthPriority ()
 
def drawMode ()
 
def enable ()
 
def excludedFromPostEffects ()
 
def geometry ()
 
def getCustomData ()
 
def getDefaultMaterialHandling ()
 
def getShader ()
 
def getShaderParameters ()
 
def isCompatibleWithMayaInstancer ()
 
def isConsolidated ()
 
def isEnabled ()
 
def isIsolateSelectCopy ()
 
def isShaderFromNode ()
 
def name ()
 
def objectTypeExclusionFlag ()
 
def primitive ()
 
def primitiveAndStride ()
 
def receivesShadows ()
 
def requiredVertexBuffers ()
 
def selectionMask ()
 
def setAllowIsolateSelectCopy ()
 
def setBoundingBox ()
 
def setCastsShadows ()
 
def setCompatibleWithMayaInstancer ()
 
def setCustomData ()
 
def setDefaultMaterialHandling ()
 
def setDepthPriority ()
 
def setDrawMode ()
 
def setExcludedFromPostEffects ()
 
def setMatrix ()
 
def setObjectTypeExclusionFlag ()
 
def setPrimitive ()
 
def setReceivesShadows ()
 
def setSelectionMask ()
 
def setShader ()
 
def setShaderFromNode ()
 
def setTreatAsTransparent ()
 
def setWantConsolidation ()
 
def setWantSubSceneConsolidation ()
 
def shadingComponent ()
 
def sourceDagPath ()
 
def sourceIndexMapping ()
 
def type ()
 
def wantConsolidation ()
 
def wantSubSceneConsolidation ()
 

Static Public Member Functions

def __new__ ()
 
def create ()
 
def destroy ()
 

Static Public Attributes

int DecorationItem = 2
 
int DrawOnlyWhenDefaultMaterialActive = 1
 
int IgnoreDefaultMaterialMode = 0
 
int InternalItem = 3
 
int InternalMaterialItem = 4
 
int InternalTexturedMaterialItem = 5
 
int InternalUnsupportedMaterialItem = 6
 
int MaterialSceneItem = 0
 
int NonMaterialSceneItem = 1
 
int OverrideNonMaterialItem = 7
 
int SkipWhenDefaultMaterialActive = 2
 
int sActiveLineDepthPriority = 9
 
int sActivePointDepthPriority = 17
 
int sActiveWireDepthPriority = 5
 
int sDormantFilledDepthPriority = 0
 
int sDormantPointDepthPriority = 14
 
int sDormantWireDepthPriority = 2
 
int sHiliteWireDepthPriority = 4
 
int sSelectionDepthPriority = 21
 

Detailed Description

A single renderable entity.

Constructor & Destructor Documentation

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

Member Function Documentation

def OpenMayaRender.MRenderItem.__new__ ( )
static
Create and return a new object.  See help(type) for accurate signature.
def OpenMayaRender.MRenderItem.allowIsolateSelectCopy ( )
allowIsolateSelectCopy() -> bool

Returns whether or not the render item allows its copies to be created forthe drawing of isolate selected components.

See setAllowIsolateSelectCopy() for more information.
def OpenMayaRender.MRenderItem.associateWithIndexBuffer ( )
associateWithIndexBuffer(MIndexBuffer) -> bool

Use to indicate that a particular index buffer should be used with this render item.
This method must be called from MPxGeometryOverride in order to link index buffers generated in
the MGeometry class with specific render items.
Without an index buffer, a render item cannot draw.
def OpenMayaRender.MRenderItem.availableShaderParameters ( )
availableShaderParameters() -> list of string

Returns the list of available shader parameters.
This is useful for OverrideNonMaterialItem to retrieve default parameters.
def OpenMayaRender.MRenderItem.boundingBox ( )
boundingBox(space=kObject) -> MBoundingBox

Returns the bounding box for the geometry data of the render item.
Returns None if the render item is unbounded or does not have a valid associated geometry.

* space (Space) - The requested space of the bounding box.
def OpenMayaRender.MRenderItem.castsShadows ( )
castsShadows() -> bool

Get the castsShadows state of the render item.
def OpenMayaRender.MRenderItem.component ( )
component() -> MObject

Get the optional component for the render item if the render item representsthe drawing of a component as a result of per - face shader assignment, componentselection highlighting etc.

If the render item doesn't represent the drawing of a component, then a nullMObject will be returned. Use the isNull() method of the MObject to check.
def OpenMayaRender.MRenderItem.create ( )
static
create(name, type, primitive) -> MRenderItem
create(item) -> MRenderItem

Static MRenderItem creation utility.

Create new render item:
* name (string) - The name of the render item (should be non-empty).
* type (int) - The type of the render item.
* primitive (int) - The primitive type of the render item.

See MRenderItem.type() for a list of valid render item types.
Internal types are not allowed and will result no item being created.
See MGeometry.primitiveString() for a list of valid primitive types.

Create new render item and copy all parameters from the incoming MRenderItem:
* item (MRenderItem) - The item to copy.
def OpenMayaRender.MRenderItem.customData ( )
customData() -> MUserData

Retrieve custom data from the render item, returns None if no such data has ever been set on the render item.

    DEPRECATED in 2022, use getCustomData instead.
def OpenMayaRender.MRenderItem.depthPriority ( )
depthPriority() -> int

Get the depth priority of the render item.
The higher the depth priority the closer it will be drawn to the camera.
def OpenMayaRender.MRenderItem.destroy ( )
static
destroy(item) -> None

Static MRenderItem destruction utility.
Destroys the internal data structures associated with this MRenderItem.
Any attempt to use the MRenderItem after this will result in an exception.
def OpenMayaRender.MRenderItem.drawMode ( )
drawMode() -> int

Get the draw mode for the render item.
See MGeometry.drawModeString() for a list of valid draw modes.
def OpenMayaRender.MRenderItem.enable ( )
enable(bool) -> self

Enable or disable the render item for rendering.
def OpenMayaRender.MRenderItem.excludedFromPostEffects ( )
excludedFromPostEffects() -> bool

Get whether this item is excluded from post-effects like SSAO and depth-of-field.
def OpenMayaRender.MRenderItem.geometry ( )
geometry() -> MGeometry

Access full geometry data for the render item.
Returns None if geometry has not been generated yet.
def OpenMayaRender.MRenderItem.getCustomData ( )
getCustomData() -> MUserData

Retrieve custom data from the render item, returns None if no such data has ever been set on the render item.
def OpenMayaRender.MRenderItem.getDefaultMaterialHandling ( )
getDefaultMaterialHandling() -> MRenderItem.DefaultMaterialFiltering

Returns whether or not this render item will draw when default material mode is active.
def OpenMayaRender.MRenderItem.getShader ( )
getShader() -> MShaderInstance

Get the shader used by this render item.
The return value may be None if no shader is set on the render item.
def OpenMayaRender.MRenderItem.getShaderParameters ( )
getShaderParameters(name) -> bool / int / float / tuple of floats

Get the value of a shader parameter.
This is useful for OverrideNonMaterialItem to retrieve default parameters.
Use availableShaderParameters() to get the list of available parameters.
def OpenMayaRender.MRenderItem.isCompatibleWithMayaInstancer ( )
isCompatibleWithMayaInstancer() -> bool

Returns whether or not this render item can be used as an instance object with Maya Instancer node.
def OpenMayaRender.MRenderItem.isConsolidated ( )
isConsolidated() -> bool

Get the consolidated state of the render item.
def OpenMayaRender.MRenderItem.isEnabled ( )
isEnabled() -> bool

Get the enable state of the render item.
def OpenMayaRender.MRenderItem.isIsolateSelectCopy ( )
isIsolateSelectCopy() -> bool

Returns whether or not the render item is a copy created to represent thedrawing of an isolate selected component.

See setAllowIsolateSelectCopy() for more information.
def OpenMayaRender.MRenderItem.isShaderFromNode ( )
isShaderFromNode() -> bool

Return True if the shader instance was set by evaluating the shading network of
a surface shader node (either standard or custom) in the scene via setShaderFromNode().
def OpenMayaRender.MRenderItem.name ( )
name() -> string

Get the name of the render item.
def OpenMayaRender.MRenderItem.objectTypeExclusionFlag ( )
objectTypeExclusionFlag() -> long

Query the bit flag which is used in display filtering based on object types.
See setObjectTypeExclusionFlag() for details.
def OpenMayaRender.MRenderItem.primitive ( )
primitive() -> int

Get the primitive type drawn by the render item.
See MGeometry.primitiveString() for a list of valid primitive types.
def OpenMayaRender.MRenderItem.primitiveAndStride ( )
primitiveAndStride() -> [int, int]

Get the primitive type drawn by the render item, as well as its stride.
See MGeometry.primitiveString() for a list of valid primitive types.
def OpenMayaRender.MRenderItem.receivesShadows ( )
receivesShadows() -> bool

Get the receivesShadows state of the render item.
def OpenMayaRender.MRenderItem.requiredVertexBuffers ( )
requiredVertexBuffers() -> MVertexBufferDescriptorList

Get a list of vertex buffer descriptors that describe the buffers required to draw the given render item.
These are determined by the shader that will be used to draw the render item and so this method will return
a non-empty list as long as there is a shader assigned to the render item.
def OpenMayaRender.MRenderItem.selectionMask ( )
selectionMask() -> MSelectionMask

Get the render item selection mask.
def OpenMayaRender.MRenderItem.setAllowIsolateSelectCopy ( )
setAllowIsolateSelectCopy(bool) -> self

When a 3D model view activates Isolate Select for components, Viewport 2.0will create and maintain necessary render items to represent the drawingof the isolate selected components specifically for that view. These renderitems are copies of their original items and thus have the same propertiesincluding name, type, primitive type, draw mode etc., but their shadingcomponents are filtered from the view selected set of that view.

By default, a custom render item doesn't allow its copies to be created forthe drawing of isolate selected components; plug-ins should call the methodto allow this. When this is allowed and multiple views have view selectedsets, the render item can have multiple copies and each copy represents thedrawing in only one view.

Viewport 2.0 is responsible to update these copies for any changes appliedto the original item and the view selected set. It is the duty of the plug-into retrieve the isolate selected components by calling the shadingComponent()method and populate the geometric buffers appropriately.

The lifetime of the copies is managed by Viewport 2.0, thus it is not safefor plug-ins to cache their pointers.
def OpenMayaRender.MRenderItem.setBoundingBox ( )
setBoundingBox(bounds) -> self

Sets the bounding box for the render item.


* bounds (MBoundingBox) - The new bounding box.
def OpenMayaRender.MRenderItem.setCastsShadows ( )
setCastsShadows(bool) -> self

Set the castsShadows state of the render item.
def OpenMayaRender.MRenderItem.setCompatibleWithMayaInstancer ( )
setCompatibleWithMayaInstancer(bool) -> self

Set whether or not this render item can be used as an instance object with Maya Instancer node.
def OpenMayaRender.MRenderItem.setCustomData ( )
setCustomData(MUserData) -> self

Associate custom user data with this render item.
If deleteAfterUse() is true on the data, then the data object will automatically be deleted when the render item is deleted.
Otherwise, the lifetime of the user data object is the responsibility of the caller.
def OpenMayaRender.MRenderItem.setDefaultMaterialHandling ( )
setDefaultMaterialHandling(MRenderItem.DefaultMaterialFiltering) -> self

Set whether or not this object should be drawn when default material mode is active.
Set this to DrawOnlyWhenDefaultMaterialActive on render items dedicated to rendering a default material and set it to SkipWhenDefaultMaterialActive on regular shader items that should not draw in that mode.
If a render item is to be drawn regardless of the mode, leave it at IgnoreDefaultMaterialMode.
def OpenMayaRender.MRenderItem.setDepthPriority ( )
setDepthPriority(int) -> self

Set the depth priority of the render item.
The higher the depth priority the closer it will be drawn to the camera.
def OpenMayaRender.MRenderItem.setDrawMode ( )
setDrawMode(int) -> self

Set the draw mode for the render item.
If the draw mode is all, the render item will be drawn regardless of the viewport draw mode.
Otherwise the render item will only be drawn when the viewport is set to draw objects in the specified mode.
See MGeometry.drawModeString() for a list of valid draw modes.
def OpenMayaRender.MRenderItem.setExcludedFromPostEffects ( )
setExcludedFromPostEffects(bool) -> self

Set whether this item should be excluded from post-effects like SSAO and depth-of-field.
Render items default to being excluded from post-effects.
def OpenMayaRender.MRenderItem.setMatrix ( )
setMatrix(MMatrix) -> bool

Override the object to world transformation matrix to use when drawing this render item.
If unset, the render item will draw using the transformation matrix of the associated Maya DAG node.
Pass None to this method to remove the override
def OpenMayaRender.MRenderItem.setObjectTypeExclusionFlag ( )
setObjectTypeExclusionFlag(long) -> self

Set a bit flag for use in display filtering based on object types. The
valid bit flags are defined in MFrameContext with names starting with
"kExclude", except the following ones:

 - MFrameContext.kExcludeGrid
 - MFrameContext.kExcludeHoldOuts
 - MFrameContext.kExcludePluginShapes
 - MFrameContext.kExcludeHUD
 - MFrameContext.kExcludeAll

When a render item is assigned with a bit flag that has been excluded by
the current view, the render item will be excluded from display. The
default value is MFrameContext.kExcludeNone, meaning the info is not to be
considered when determining whether the render item should be excluded.

This method only affects items explicitly created by the plug-in.

 * val (long) - A "kExclude" bit flag defined in MFrameContext
def OpenMayaRender.MRenderItem.setPrimitive ( )
setPrimitive(int, int) -> self

Set the primitive type of the render item. If it is kPatch, stride will be required to specify the number of control points per patch and the valid values are [1, 32]; otherwise stride won't be used.

If this item is consolidated, invoking this method may cause this item to be reconsolidated.

This method only affects items explicitly created by the plug-in.
def OpenMayaRender.MRenderItem.setReceivesShadows ( )
setReceivesShadows(bool) -> self

Set the receivesShadows state of the render item.
def OpenMayaRender.MRenderItem.setSelectionMask ( )
setSelectionMask(mask) -> selfsetSelectionMask(type) -> self

Set the render item selection mask.

* mask (MSelectionMask) - The selection mask.
* type (int) - The selection type (see MSelectionMask.addMask() for a list of values).
def OpenMayaRender.MRenderItem.setShader ( )
setShader(shader, customStreamName=None) -> bool

Set shader to use when drawing this render item.
If no shader is ever set the render item will not draw.
The render item makes a copy of the instance so it is safe to delete the instance after
assignment without affecting any render items the instance was assigned to.

* shader (MShaderInstance) - The shader to use when drawing this item.
* customStreamName (string) - If specified, shader will generate geometry requirements with the given name.
def OpenMayaRender.MRenderItem.setShaderFromNode ( )
setShaderFromNode(shaderNode, shapePath, linkLostCb=None, linkLostUserData=None, nonTextured=False) -> self

Set shader to use when drawing this render item. If no shader is ever set this render item will not draw. This method sets the shader instance to a render item by evaluating the shading network of a surface shader node (either standard or custom) in the scene.

This method only affects items explicitly created by the plug-in.

If the surface shader node is None or supported by neither Maya nor the plug-in, this method will clear the shader assignment on the render item, which will thus not be drawn.

The shape path is used as the object context for shading network evaluation to ensure that the shader instance fits its requirements. If the shape path is invalid (e.g. an empty path), a shader instance to fit basic requirements is created but will not include any geometry-dependent requirements.

The linkLostCb will be invoked whenever the link to the surface shader node is lost. The link can be lost in a number of ways, e.g. shader nodes are deleted or shading network connections are modified. However, the linkLostCb won't be invoked for a change to shading group level connection; if needed, it is the DG node's responsibility to monitor any changes to shading group level connection by MPxNode::connectionMade and MPxNode::connectionBroken.

There is no guarantee that the surface shader node is still valid after the link is lost. The linkLostCb should check the validity and assign the render item with a shader instance appropriately.

After the shader instance is set, its parameter values can be automatically updated by Viewport 2.0 whenever the related shading attributes changed, therefore access to the shader instance is not provided in order to avoid unexpected behavior.

 * shaderNode (MObject) - The surface shader node.
 * shapePath (MDagPath) - The DAG path of a shape to be used as the object context for shading network evaluation.
 * linkLostCb (callable) - Function to be invoked whenever the link to the surface shader node is lost.
 * linkLostUserData (MUserData) - User supplied data to be passed into the link lost callback.
 * nonTextured (bool) - Whether or not a non-textured effect instance is needed. The default value is false.
def OpenMayaRender.MRenderItem.setTreatAsTransparent ( )
setTreatAsTransparent(bool) -> self

Set whether or not this object should be treated as a transparent item.Set this to true if the object has vertex colors with alpha or other inputsthat make it important to treat this object as if it were transparent.
def OpenMayaRender.MRenderItem.setWantConsolidation ( )
setWantConsolidation(bool) -> self

Set whether or not this render item wants to participate in consolidation.

This method only affects items explicitly created by the plug-in. The value is true by default, unless the item is added to an MSubSceneContainer. When it is true, the geometry of compatible render items will be consolidated into a single render item, to provide better performance.

Render items that are already instanced cannot be consolidated.

For render items added to an MSubSceneContainer, if wantConsolidation is set to true, this will prevent them from being instanced until wantConsolidation is set to false.
def OpenMayaRender.MRenderItem.setWantSubSceneConsolidation ( )
setWantSubSceneConsolidation(bool) -> self

Sets whether or not this render item is eligible for consolidation in sub scene overrides.

Render items that are already instanced cannot be consolidated. Setting a render item to
want sub scene consolidation will prevent the render item from being instanced.
def OpenMayaRender.MRenderItem.shadingComponent ( )
shadingComponent() -> MObject

Get the optional shading component for the render item. It is different fromthe component() method only when a view selected filter is applied.

Therefore, a typical use of this method is to query the isolate selectedcomponent on a render item created by Viewport 2.0 when a 3D model viewactivates Isolate Select for components. See setAllowIsolateSelectCopy()for more information.

If the render item doesn't represent the drawing of a shading component,then a null MObject will be returned. Use the isNull() method of the MObjectto check.
def OpenMayaRender.MRenderItem.sourceDagPath ( )
sourceDagPath() -> MDagPath

Retrieve the MDagPath for the instance of the object that generated this render item.

 If there are many object instances contributing due to consolidation then only one dag path out of all the objects is returned.

The method sourceIndexMapping() should be used if the item is consolidatedto access the corresponding dag paths for the objects making up this item.
def OpenMayaRender.MRenderItem.sourceIndexMapping ( )
sourceIndexMapping() -> MGeometryIndexMapping

Get the geometry index mapping of the objects contained by this consolidated render item.
Multiple geometries can be concatenated to improve rendering performance.
You can access the index mapping of the geometries in order to render them separately.
The index mapping gives you the name, and index start and length of each geometry.
def OpenMayaRender.MRenderItem.type ( )
type() -> int

Get the type of the render item.

  MRenderItem.MaterialSceneItem
     A render item which represents an object in the scene that should interact with the rest of the scene and viewport settings (e.g. a shaded piece of geometry which should be considered in processes like shadow computation, viewport effects, etc.). Inclusion in such processes can also still be controlled through the appropriate methods provided by this class.
  MRenderItem.NonMaterialSceneItem
     A render item which represents an object in the scene that should not interact with the rest of the scene and viewport settings, but that is also not part of the viewport UI (e.g. a curve or a bounding box which should not be hidden when 'Viewport UI' is hidden but which should also not participate in processes like shadow computation, viewport effects, etc.).
  MRenderItem.DecorationItem
     A render item which should be considered to be part of the viewport UI (e.g. selection wireframe, components, etc.).
  MRenderItem.InternalItem
     A render item which was created by Maya for internal purposes (e.g. A render item created as the result of a shader being assigned to a DAG node).
  MRenderItem.InternalMaterialItem
    An internally created MaterialSceneItem for non-textured mode display.
  MRenderItem.InternalTexturedMaterialItem
     An internally created MaterialSceneItem for textured mode display.
  MRenderItem.InternalUnsupportedMaterialItem
     An internally created MaterialSceneItem for showing an unsupported material
def OpenMayaRender.MRenderItem.wantConsolidation ( )
wantConsolidation() -> bool

Return whether or not this render item wants to participate in consolidation.
def OpenMayaRender.MRenderItem.wantSubSceneConsolidation ( )
wantSubSceneConsolidation() -> bool

Returns True if this render item is eligible for consolidation in sub scene overrides.