class MPxDeformerNode

Jump to documentation

: public MPxNode Base class for user defined Deformers (OpenMayaAnim) (OpenMayaMPx.py)

Inheritance:

MPxDeformerNode < MPxNode

public members:

MPxDeformerNode ()
virtual ~MPxDeformerNode ()
virtual MPxNode::Type type () const
virtual MStatus deform ( MDataBlock & block, MItGeometry & iter, const MMatrix & mat, unsigned int multiIndex)
virtual MObject & accessoryAttribute () const
virtual MStatus accessoryNodeSetup ( MDagModifier & cmd)
float weightValue ( MDataBlock & mblock, unsigned int multiIndex, unsigned int wtIndex)
void setUseExistingConnectionWhenSetEditing (bool state)
virtual void setModifiedCallback ( MSelectionList & list, bool listAdded )
static MObject input
input attribute, multi
static MObject inputGeom
input geometry attribute
static MObject groupId
input group id attribute
static MObject outputGeom
geometry output attribute
static MObject weightList
weight list attribute, multi
static MObject weights
weight attribute, multi
static MObject envelope
envelope attribute

Inherited from MPxNode:

public members:

enum Type
kDependNode
kLocatorNode
kDeformerNode
kManipContainer
kSurfaceShape
kFieldNode
kEmitterNode
kSpringNode
kIkSolverNode
kHardwareShader
Custom shader derived from MPxHardwareShader
kHwShaderNode
Custom shader derived from MPxHwShaderNode
kTransformNode
kObjectSet
kFluidEmitterNode
kImagePlaneNode
kParticleAttributeMapperNode
kConstraintNode
kLast
virtual void postConstructor ()
virtual MStatus compute ( const MPlug & plug, MDataBlock & dataBlock )
virtual bool getInternalValueInContext ( const MPlug & plug, MDataHandle & dataHandle, MDGContext & ctx)
virtual bool setInternalValueInContext ( const MPlug & plug, const MDataHandle & dataHandle, MDGContext & ctx)
virtual bool getInternalValue ( const MPlug & plug, MDataHandle & dataHandle)
virtual bool setInternalValue ( const MPlug & plug, const MDataHandle & dataHandle)
virtual int internalArrayCount ( const MPlug & plug, const MDGContext & ctx) const
virtual void copyInternalData ( MPxNode * )
virtual MStatus legalConnection ( const MPlug & plug, const MPlug & otherPlug, bool asSrc, bool& isLegal ) const
virtual MStatus legalDisconnection ( const MPlug & plug, const MPlug & otherPlug, bool asSrc, bool& isLegal ) const
virtual MStatus setDependentsDirty ( const MPlug & plug, MPlugArray & plugArray)
virtual MStatus connectionMade ( const MPlug & plug, const MPlug & otherPlug, bool asSrc )
virtual MStatus connectionBroken ( const MPlug & plug, const MPlug & otherPlug, bool asSrc )
virtual bool isPassiveOutput ( const MPlug & plug ) const
virtual MStatus shouldSave ( const MPlug & plug, bool& isSaving )
virtual MPlug passThroughToOne ( const MPlug & plug ) const
virtual bool passThroughToMany ( const MPlug & plug, MPlugArray & plugArray ) const
MTypeId typeId () const
MString typeName () const
MString name () const
virtual Type type () const
virtual bool isAbstractClass () const
MObject thisMObject () const
static MStatus addAttribute ( const MObject & attr )
static MStatus inheritAttributesFrom ( const MString & parentClassName )
static MStatus attributeAffects ( const MObject & whenChanges, const MObject & isAffected )
MStatus setExistWithoutInConnections ( bool flag )
bool existWithoutInConnections ( MStatus * ReturnStatus = NULL ) const
MStatus setExistWithoutOutConnections ( bool flag )
bool existWithoutOutConnections ( MStatus * ReturnStatus = NULL ) const
static MObject message
static MObject isHistoricallyInteresting
static MObject caching
static MObject state

protected members:

MDataBlock forceCache ( MDGContext & ctx= MDGContext::fsNormal )
void setMPSafe ( bool flag )
MStatus setDoNotWrite ( bool flag )
bool doNotWrite ( MStatus *ReturnStatus = NULL ) const

Documentation

Create user defined Deformers.
Description

MPxDeformerNode allows the creation of user-defined deformers. A deformer is a node which takes any number of input geometries, deforms them, and places the output into the output geometry attribute.

If you write a deformer by deriving from MPxDeformerNode, your deformer will derive the benefit of Maya's internal deformer functionality, namely:

Deformers are full dependency nodes and can have attributes and a deform() method. In general, to derive the full benefit of the Maya deformer base class, it is suggested that you do not write your own compute() method. Instead, write the deform() method, which is called by the MPxDeformerNode's compute() method. However, there are some exceptions when you would instead write your own compute(), namely:

In the case where you cannot simply override the deform() method, the following example code shows one possible compute() method implementation. This compute() example creates an iterator for the deformer set corresponding to the output geometry being computed. Note that this sample compute() implementation does not do any deformation, and does not implement handling of the nodeState attribute. If you do choose to override compute() in your node, there is no reason to implement the deform() method, since it will not be called by the base class.

MStatus
exampleDeformer::compute(const MPlug& plug, MDataBlock& dataBlock)
{
    MStatus status = MS::kUnknownParameter;
 	if (plug.attribute() == outputGeom) {
		// get the input corresponding to this output
		//
		unsigned int index = plug.logicalIndex();
		MObject thisNode = this->thisMObject();
		MPlug inPlug(thisNode,input);
		inPlug.selectAncestorLogicalIndex(index,input);
		MDataHandle hInput = dataBlock.inputValue(inPlug);

		// get the input geometry and input groupId
		//
		MDataHandle hGeom = hInput.child(inputGeom);
		MDataHandle hGroup = hInput.child(groupId);
		unsigned int groupId = hGroup.asLong();
		MDataHandle hOutput = dataBlock.outputValue(plug);
		hOutput.copy(hGeom);

		// do the deformation
		//
		MItGeometry iter(hOutput,groupId,false);
		for ( ; !iter.isDone(); iter.next()) {
			MPoint pt = iter.position();

			//
            // insert deformation code here
			//
			
			iter.setPosition(pt);
		}
		status = MS::kSuccess;
	}
	return status;
}

For most deformers, implementing compute() is unnecessary. To create a deformer, derive from this class and override the deform() method as demonstrated in the "offsetNode.cpp" example plug-in. The other methods of the parent class MPxNode may also be overridden to perform standard dependency node capabilities.

When implementing the compute method for a deformer, another consideration is that the input geometry attribute is not cached. This means that all of the inputs will evaluate each time MDataBlock::inputArrayValue is called on "inputGeom". If you only want a single inputGeometry, you can prevent unneeded evaluations by avoiding calls to MDataBlock.inputArrayValue. For example, use the technique shown in the above example or use MDataBlock::outputArrayValue.

Functions

MPxDeformerNode:: MPxDeformerNode ()
Constructor

Class constructor.

MPxDeformerNode:: ~MPxDeformerNode ()
Destructor

Class destructor.

MPxNode::Type MPxDeformerNode:: type () const

Description

This method returns the type of the node. This method should not be overridden by the user. It will return MPxNode::kDeformerNode.

Return Value

  • the type of node

MStatus MPxDeformerNode:: deform ( MDataBlock & block, MItGeometry & iterator, const MMatrix & matrix, unsigned int multiIndex)

Description

This method performs the deformation algorithm. A status code of MS::kSuccess should be returned unless there was a problem during the deformation, such as insufficient memory or required input data is missing or invalid.

NOTE: the geometry iterator passed to this method is in local space and not world space. To convert points to world space use the matrix that is suppied.

Arguments

  • block the node's datablock.
  • iterator an iterator for the current geometry being deformed.
  • matrix the geometry's world space transformation matrix.
  • multiIndex the index corresponding to the requested output geometry.

Return Value

  • status code

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MObject & MPxDeformerNode:: accessoryAttribute () const

Description

This method returns an MObject for the attribute to which an accessory shape is connected. If the accessory shape is deleted, the deformer node will automatically be deleted.

If your node has no associated shape, there is no need to override this method.

Return Value

  • the accessory attribute

MStatus MPxDeformerNode:: accessoryNodeSetup ( MDagModifier & cmd)

Description

This method is called by the "deformer -type" command when your node is specified.

This method can be used to create and attach accessory nodes if your plugin node requires them. To do so, override this method, and provide the creation and attachment commands to the MDagModifier that is passed as input to the method.

If your node has no associated nodes, there is no need to override this method.

Arguments

  • cmd the dag modifier to which the method will add commands

Return Value

  • status code

float MPxDeformerNode:: weightValue ( MDataBlock & block, unsigned int multiIndex, unsigned int wtIndex)

Description

This method returns the weightValue stored in the datablock for the given geometry's lattice point/CV/vertex.

Arguments

  • block the datablock for the node
  • multiIndex the index corresponding to the geometry
  • wtIndex the index corresponding to the component

Return Value

  • weight

void MPxDeformerNode:: setUseExistingConnectionWhenSetEditing (bool state)

Description

This method allows the plugin node to request special treatment during set editing. It controls the connection behavior if all of a geometry's points are removed from the deformer set, and then points are subsequently added back in to the set again. By default, Maya will reconnect the deformer to the shape using a new input/output index. If this method is called in the custom deformer's postConstructor method and the state is set to true, the deformer will attempt to use the original input/output index when reconnecting to the shape.

Arguments

  • state whether or not to use the existing connection

void MPxDeformerNode:: setModifiedCallback ( MSelectionList & list, bool listAdded)

Description

This callback method can be overriden and is called whenever the set this deformer is operating on is modified. It passes in a selection list of items that are either being added/removed.

Arguments

  • list list of items added/removed
  • list whether the list is being added or removed to the set.

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright