Share

Selection

When an object is selected in Maya, a selection ray is generated based on the orientation of the camera and the mouse position. Selection happens in two steps—first, all of the object bounding boxes are tested for ray intersection, then the select functions are called for all objects whose bounding boxes were hit.

The selection of custom shapes can be done using class deriving from MPxGeometryOverride, MPxSubSceneOverride, or MPxDrawOverride class in Viewport 2.0. See the apiMeshGeometryOverride class and apiMeshSubSceneOverride class in the apiMeshShape example plug-in for an example of shape and component selection.

Selection are handled by the following interfaces in Viewport 2.0 :

  • MSelectionContext: Information about the state of selection including selection level.

  • MIntersection: Hit intersection information

  • MSelectionInfo: Used with MPxGeometryOverride::refineSelectionPath()

  • MPxComponentConverter : utility to handle MIntersections and convert index buffers to MFnComponents.

    Registered / deregistered on MDrawRegistry using registerComponentConverter() / deregisterComponentConverter()

  • For MRenderItem:

    A "selection" mode (DrawMode) allows indication of whether a render item should be used for selection.

    There is the ability to set a selection mask (MSelectionMask) to indicate the selection type.

  • MPxSurfaceShape: has been extended with the ability to return a selection mask (MSelectionMask) to indicate that component selection is supported in Viewport 2.0.

See more details in the section: Porting Selection from Viewport 1 to 2.

Was this information helpful?