class MDrawTraversal

Jump to documentation

A scene drawing traverser (OpenMayaUI) (OpenMayaUI.py)

public members:

enum
Item status enum
kActiveItem
Check if item is active
kTemplateItem
Check if item is templated
MDrawTraversal ()
virtual ~MDrawTraversal ()
virtual MStatus traverse ()
virtual bool filterNode ( const MDagPath &traversalItem )
MStatus setFrustum ( const MDagPath & cameraPath, unsigned int portWidth, unsigned int portHeight )
MStatus setOrthoFrustum (double left, double right, double bottom, double top, double nearpt, double farpt, const MMatrix & worldXform)
MStatus setPerspFrustum (double fovX, double aspectXY, double nearDist, double farDist, const MMatrix & worldXform)
MStatus setFrustum (double left, double right, double bottom, double top, double nearpt, double farpt, const MMatrix & worldXform)
MStatus setFrustum (const MPoint & nearBottomLeft, const MPoint & nearBottomRight, const MPoint & nearTopLeft, const MPoint & nearTopRight, const MPoint & farBottomLeft, const MPoint & farBottomRight, const MPoint & farTopLeft, const MPoint & farTopRight, const MMatrix &worldXform)
bool frustumValid () const
void setLeafLevelCulling ( bool cullAtLeafLevel )
bool leafLevelCulling () const
void enableFiltering ( bool val )
bool filteringEnabled () const
unsigned int numberOfItems () const
MStatus itemPath (unsigned int itemNumber, MDagPath &path) const
bool itemHasStatus (unsigned int itemNumber, unsigned int test) const

Documentation

Scene draw traversal class.

Description

MDrawTraversal is a utility class for interactive drawing. The purpose of the class is to traverse through the current scene dag and provide a means of accessing a list of visible objects with respect to a given frustum specification, and application "visibility" criteria.

The additional "visibility" criteria include:

Note that as the traversal is not dependent on a 3d modeling viewport. There are thus no checks for per viewport visibility properties such as per viewport dag object type overrides, and "isolate select".

Additionally, render layer visibility checks are not performed, as these pertain to software rendering.

After traversal the list will contain leaf level nodes (shapes), which have passed the "visibility" criteria.

For the actual frustum culling, there is a choice of two culling algorithms:

Note that hierarchical culling may force evaluation of geometry on dag objects which are not visible.

The default is thus to perform leaf level culling only.

Frustum culling is performed against the bounding boxes of dag objects encountered.

API writers can derive from this class and change the filterNode() virtual method to perform custom filtering of objects during traversal. That is they will be excluded from the output list. By default this class does no additional filtering.

Functions

MDrawTraversal:: MDrawTraversal ()

Description

Default constructor. Sets leaf level culling to be true by default, and filtering to be disabled.

Arguments

  • None

Return Value

  • None

MDrawTraversal:: ~MDrawTraversal ()

Description

Default destructor.

Arguments

  • None.

Return Value

  • None.

bool MDrawTraversal:: filterNode ( const MDagPath &traversalItem )

Description

Method to allow filtering during traversal. The traversalItem can be examined, and if it is not match the desired criteria, it will not be added to the output traversal list.

A return value of "false" will result in filtering out this item. A return value of "true" will result in regular filtering to occuring.

API writers can derive from MDrawTraversal, and implement their own filterNode() method to perform custom filtering as desired.

Arguments

  • traversalItem : path to item to test.

Return Value

  • Will always return false for MDrawTraversal class.

MStatus MDrawTraversal:: setFrustum ( const MDagPath & cameraPath, unsigned int portWidth, unsigned int portHeight )

Description

Set the frustum to cull with. The frustum is based on the attributes of the camera argument provided.

Note that traversal always requries that a valid frustum to be set. There is no default frustum provided.

Arguments

  • cameraPath : path to a valid scene camera.
  • portWidth : width of the viewport to cull against.
  • portHeight : height of the viewport to cull against.

Return Value

  • MStatus::kSuccess if successfully set.

MStatus MDrawTraversal:: setOrthoFrustum (double left, double right, double bottom, double top, double nearpt, double farpt, const MMatrix & worldXform)

Description

Set up an orthographic view frustum to cull with. The frustum is symmetric about the vertical and horizontal.

Note that traversal always requries that a valid frustum to be set. There is no default frustum provided.

Arguments

  • left : Left side of frustum (local space).
  • right : Right side of frustum (local space).
  • bottom : Bottom of frustum (local space).
  • top : Top of frustum (local space).
  • nearpt : Front / near point of frustum (local space).
  • farpt : Back / far point of frustum (local space).
  • worldXform : transformation from local to world space.

Return Value

  • MStatus::kSuccess if successfully set.

MStatus MDrawTraversal:: setPerspFrustum (double fovX, double aspectXY, double nearDist, double farDist, const MMatrix & worldXform)

Description

Set up an perspective view frustum to cull with. The frustum is symmetric about the vertical and horizontal.

Note that traversal always requries that a valid frustum to be set. There is no default frustum provided.

Arguments

  • fovX : Field of view in X.
  • aspectXY : aspect ratio X / Y.
  • nearDist : distance to near plane.
  • farDist : distance to far plane.
  • worldXform : transformation from local to world space.

Return Value

  • MStatus::kSuccess if successfully set.

MStatus MDrawTraversal:: setFrustum (double left, double right, double bottom, double top, double nearpt, double farpt, const MMatrix & worldXform)

Description

Set up a frustum to cull with. The frustum can be asymmetric is distance about the vertial and horizontal.

Note that traversal always requries that a valid frustum to be set. There is no default frustum provided.

Arguments

  • left : Left side of frustum (local space).
  • right : Right side of frustum (local space).
  • bottom : Bottom of frustum (local space).
  • top : Top of frustum (local space).
  • nearpt : Front / near point of frustum (local space).
  • farpt : Back / far point of frustum (local space).
  • worldXform : transformation from local to world space.

Return Value

  • MStatus::kSuccess if successfully set.

MStatus MDrawTraversal:: setFrustum (const MPoint & nearBottomLeft, const MPoint & nearBottomRight, const MPoint & nearTopLeft, const MPoint & nearTopRight, const MPoint & farBottomLeft, const MPoint & farBottomRight, const MPoint & farTopLeft, const MPoint & farTopRight, const MMatrix &worldXform)

Description

Set up a frustum to cull with by specifying the 8 corner points. Asymmetric frustum's can be set up using this method.

Note that traversal always requries that a valid frustum to be set. There is no default frustum provided.

Arguments

  • nearBottomLeft : Near bottom left corner of frustum (local space).
  • nearBottomRight : Near bottom Right corner of frustum (local space).
  • nearTopLeft : Near top left corner of frustum (local space).
  • nearTopRight : Near top right corner of frustum (local space).
  • farBottomLeft : Far bottom left corner of frustum (local space).
  • farBottomRight : Far bottom right corner of frustum (local space).
  • farTopLeft : Far top left corner of frustum (local space).
  • farTopRight : Far top right corner of frustum (local space).
  • worldXform : transformation from local to world space.

Return Value

  • MStatus::kSuccess if successfully set.

bool MDrawTraversal:: frustumValid () const

Description

Returns whether the current frustum set is valid or not. If it is not valid a call to the traverse() function will result in returning failure.

Arguments

  • None.

Return Value

  • true if frustum is valid.

void MDrawTraversal:: setLeafLevelCulling ( bool cullAtLeafLevel )

Description

Set whether to cull at the leaf levels, or perform hierarchical culling.

This value should be set before traversing using the traverse() function.

If a value is not explicitly set, the default is to perform culling at the leaf levels only.

Arguments

  • cullAtLeafLevel : flag to indicate culling preference.

Return Value

  • MStatus::kSuccess if successfully set.

bool MDrawTraversal:: leafLevelCulling () const

Description

Returns whether the current cull algorithm will cull at the leaf levels, or perform hierarchical culling. The default value is leaf level culling.

Arguments

  • None.

Return Value

  • true if peforming leaf level culling.

void MDrawTraversal:: enableFiltering ( bool val )

Description

Sets whether to use enable usage of the filterNode() method to perform custom filtering. By default this is set to false.

Filtering must be enabled for filterNode() to be called during traversal.

Arguments

  • val : value for enabling.

Return Value

  • None.

bool MDrawTraversal:: filteringEnabled () const

Description

Tells whether custom filtering has been enabled. That is, to use the filterNode() method during traversal.

By default this is set to false.

Filtering must be enabled for filterNode() to be called during traversal.

Arguments

  • None.

Return Value

  • true if filtering is enabled.

MStatus MDrawTraversal:: traverse ()

Description

Perform traversal of the current scene from the root of the dag hierarchy. A valid frustum must be set before calling this method.

If the traversal was succesfull a list of traversal items will have been evaluated.

Arguments

  • None.

Return Value

  • MStatus::kSuccess if successful traversal.

unsigned int MDrawTraversal:: numberOfItems () const

Description

Return the number of items found after traversal.

Arguments

  • None

Return Value

  • Number of items.

MStatus MDrawTraversal:: itemPath (unsigned int itemNumber, MDagPath &path) const

Description

Get the path for a given item in the list of found items after traversal.

Arguments

  • itemNumber : which item to return.
  • path : path of item (returned).

Return Value

  • MStatus::kSuccess if could find an item to return.

bool MDrawTraversal:: itemHasStatus (unsigned int itemNumber, unsigned int test) const

Description

Test the display status for a given item in the list of found items after traversal.

Arguments

  • itemNumber : which item to return.
  • test : the display status to check the item against.

Return Value

  • true, if item status matches the display status to test against.

This class has no child classes.


Autodesk® Maya® 8.0 © 1997-2006 Autodesk, Inc. All rights reserved. doc++ Copyright