OpenMayaRender.MRenderItem Class Reference

OpenMayaRender.MRenderItem Class Reference
+ Related help topics:

Class Description

A single renderable entity.
+ Inheritance diagram for OpenMayaRender.MRenderItem:

Public Member Functions

__init__ ()
 
associateWithIndexBuffer ()
 
availableShaderParameters ()
 
boundingBox ()
 
castsShadows ()
 
component ()
 
customData ()
 
depthPriority ()
 
drawMode ()
 
enable ()
 
excludedFromPostEffects ()
 
geometry ()
 
getShader ()
 
getShaderParameters ()
 
isCompatibleWithMayaInstancer ()
 
isConsolidated ()
 
isEnabled ()
 
isShaderFromNode ()
 
name ()
 
primitive ()
 
primitiveAndStride ()
 
receivesShadows ()
 
requiredVertexBuffers ()
 
selectionMask ()
 
setCastsShadows ()
 
setCompatibleWithMayaInstancer ()
 
setCustomData ()
 
setDepthPriority ()
 
setDrawMode ()
 
setExcludedFromPostEffects ()
 
setMatrix ()
 
setReceivesShadows ()
 
setSelectionMask ()
 
setShader ()
 
setShaderFromNode ()
 
setTreatAsTransparent ()
 
sourceDagPath ()
 
sourceIndexMapping ()
 
type ()
 

Static Public Member Functions

create ()
 
destroy ()
 

Static Public Attributes

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

Constructor & Destructor Documentation

OpenMayaRender.MRenderItem.__init__ ( )
x.__init__(...) initializes x; see help(type(x)) for signature

Member Function Documentation

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.
OpenMayaRender.MRenderItem.availableShaderParameters ( )
availableShaderParameters() -> list of string

Returns the list of available shader parameters.
This is useful for OverrideNonMaterialItem to retrieve default parameters.
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.
OpenMayaRender.MRenderItem.castsShadows ( )
castsShadows() -> bool

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

Get the optional component for the render item.
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.
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.
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.
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.
OpenMayaRender.MRenderItem.drawMode ( )
drawMode() -> int

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

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

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

Access full geometry data for the render item.
Returns None if geometry has not been generated yet.
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.
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.
OpenMayaRender.MRenderItem.isCompatibleWithMayaInstancer ( )
isCompatibleWithMayaInstancer() -> bool

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

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

Get the enable state of the render item.
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().
OpenMayaRender.MRenderItem.name ( )
name() -> string

Get the name of the render item.
OpenMayaRender.MRenderItem.primitive ( )
primitive() -> int

Get the primitive type drawn by the render item.
See MGeometry.primitiveString() for a list of valid primitive types.
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.
OpenMayaRender.MRenderItem.receivesShadows ( )
receivesShadows() -> bool

Get the receivesShadows state of the render item.
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.
OpenMayaRender.MRenderItem.selectionMask ( )
selectionMask() -> MSelectionMask

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

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

Set whether or not this render item can be used as an instance object with Maya Instancer node.
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.
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.
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.
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.
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
OpenMayaRender.MRenderItem.setReceivesShadows ( )
setReceivesShadows(bool) -> self

Set the receivesShadows state of the render item.
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).
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.
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.
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.
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.
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.
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