API Guide > Shapes > 

Shapes in Maya

 
 
 

Shapes in Maya are selectable DAG objects that display in 3D views. Meshes, NURBS surfaces and curves, and locators are just some examples of shapes. Shapes are also dependency graph (DG) nodes that have attributes which can be connected to other nodes.

Shapes can be thought of as a container for geometry. The role of this container is to present the geometry for interactive display and manipulation.

Shapes which are formed and manipulated by the position of control vertices (or CVs) are called control point shapes. The control points are attributes on the shape which are usually arrays of points. Control points become interactive, i.e. they can be selected and manipulated, by associating the control point attributes with a component.

Components are objects (MObject’s) which contain two pieces of information, the type of component and the index values or range. For example, a mesh vertex component. This component represents the vertex (or "pnts") attribute of a mesh shape, where vtx[0] represents vertex 0 of the mesh and vtx[0:7] represents the first eight vertices of the mesh.

Shapes which define a surface such as NURBS surfaces and meshes support hardware display of materials and hardware lighting in interactive views as well as the hardware render buffer.

User-defined shapes

The purpose of a user-defined shape and all the classes associated with shapes is to "wrap" an arbitrary geometry type that you defined as a DAG node (and a DG node), or as data passed through the DG.

The class MPxSurfaceShape lets you write shapes using the Maya API. Writing a shape node is similar to writing a dependency node, in fact, the base class for user defined shapes (MPxSurfaceShape) derives from MPxNode.

The major difference between MPxSurfaceShape and MPxNode is the addition of component handling, drawing, and selection functions. The overridable functions have been split into two classes, the DG node functionality is in MPxSurfaceShape and the drawing and select functions are in MPxSurfaceShapeUI.

User-defined shapes are best suited for control point based shapes such as polygonal meshes or spline-based objects. This does not mean that you cannot write other kinds of shapes, it just means that MPxSurfaceShape is already set up to handle control point based shapes.

Shapes are registered using the MFnPlugin::registersShape function. This function is similar to registerNode but contains an additional argument specifying the creator function for the MPxSurfaceShapeUI class. Unregistering shapes is done using MFnPlugin::deregisterNode in the same way that MPxNode classes are unregistered.