MPxConstraint Class Reference

#include <MPxConstraint.h>

Class Description

Proxy constraint node.

MPxConstraint is the parent class for user defined constraint nodes. Position, orientation or scale of an object can be constrained by other objects. This class works in conjunction with the MPxConstraintCommand class.

+ Examples:
+ Inheritance diagram for MPxConstraint:

Public Types

enum  UpVectorType {
  kScene = 0, kObject, kObjectRotation, kVector,
  kLast
}
 The type of up vector. More...
 
- Public Types inherited from MPxNode
enum  Type {
  kDependNode, kLocatorNode, kDeformerNode, kManipContainer,
  kSurfaceShape, kFieldNode, kEmitterNode, kSpringNode,
  kIkSolverNode, kHardwareShader, kHwShaderNode, kTransformNode,
  kObjectSet, kFluidEmitterNode, kImagePlaneNode, kParticleAttributeMapperNode,
  kCameraSetNode, kConstraintNode, kManipulatorNode, kMotionPathNode,
  kClientDeviceNode, kThreadedDeviceNode, kAssembly, kSkinCluster,
  kGeometryFilter, kBlendShape, kLast
}
 Defines the type of node. More...
 
enum  SchedulingType {
  kParallel, kSerial, kGloballySerial, kUntrusted ,
  kDefaultScheduling = kSerial, kSerialize = kSerial, kGloballySerialize = kGloballySerial
}
 Defines the degree of parallelism of a node. More...
 

Public Member Functions

 MPxConstraint ()
 Constructor. More...
 
virtual ~MPxConstraint ()
 Destructor.
 
virtual const MObject weightAttribute () const
 Returns the weight attribute for the constraint. More...
 
virtual const MObject targetAttribute () const
 Returns the target attribute for the constraint. More...
 
virtual const MObject constraintRotateOrderAttribute () const
 Returns the rotate order attribute for the constraint. More...
 
- Public Member Functions inherited from MPxNode
 MPxNode ()
 Constructor. More...
 
virtual ~MPxNode ()
 Destructor.
 
virtual void postConstructor ()
 Post constructor. More...
 
virtual MStatus compute (const MPlug &, MDataBlock &)
 This method should be overridden in user defined nodes. More...
 
virtual bool getInternalValue (const MPlug &, MDataHandle &)
 This method is overridden by nodes that store attribute data in some internal format. More...
 
virtual bool setInternalValue (const MPlug &, const MDataHandle &)
 This method is overridden by nodes that store attribute data in some internal format. More...
 
virtual int internalArrayCount (const MPlug &) const
 This method is overridden by nodes that have internal array attributes which are not stored in Maya's datablock. More...
 
virtual void copyInternalData (MPxNode *)
 This method is overridden by nodes that store attribute data in some internal format. More...
 
virtual MStatus legalConnection (const MPlug &, const MPlug &, bool asSrc, bool &isLegal) const
 This method allows you to check for legal connections being made to attributes of this node. More...
 
virtual MStatus legalDisconnection (const MPlug &, const MPlug &, bool asSrc, bool &isLegal) const
 This method allows you to check for legal disconnections being made to attributes of this node. More...
 
virtual MStatus setDependentsDirty (const MPlug &plug, MPlugArray &plugArray)
 This method can be overridden in user defined nodes to specify which plugs should be set dirty based upon an input plug {plugBeingDirtied} which Maya is marking dirty. More...
 
virtual MStatus preEvaluation (const MDGContext &context, const MEvaluationNode &evaluationNode)
 Prepare a node's internal state for threaded evaluation. More...
 
virtual MStatus postEvaluation (const MDGContext &context, const MEvaluationNode &evaluationNode, PostEvaluationType evalType)
 Clean up node's internal state after threaded evaluation. More...
 
virtual SchedulingType schedulingType () const
 When overridden this method controls the degree of parallelism supported by the node during threaded evaluation. More...
 
virtual MStatus connectionMade (const MPlug &, const MPlug &, bool asSrc)
 This method gets called when connections are made to attributes of this node. More...
 
virtual MStatus connectionBroken (const MPlug &, const MPlug &, bool asSrc)
 This method gets called when connections are broken with attributes of this node. More...
 
virtual MStatus dependsOn (const MPlug &, const MPlug &, bool &depends) const
 This method may be overridden by the user defined node. More...
 
virtual bool isPassiveOutput (const MPlug &) const
 This method may be overridden by the user defined node if it wants to provide output attributes which do not prevent value modifications to the destination attribute. More...
 
virtual MStatus shouldSave (const MPlug &, bool &isSaving)
 This method may be overridden by the user defined node. More...
 
virtual MPlug passThroughToOne (const MPlug &) const
 This method may be overridden by nodes that have a one-to-one relationship between an input attribute and a corresponding output attribute. More...
 
virtual bool passThroughToMany (const MPlug &, MPlugArray &) const
 This method is overridden by nodes that want to control the traversal behavior of some Maya search algorithms which traverse the history/future of shape nodes looking for directly related nodes. More...
 
virtual Type type () const
 Returns the type of node that this is. More...
 
virtual bool isAbstractClass () const
 Override this class to return true if this node is an abstract node. More...
 
virtual MStringArray getFilesToArchive (bool shortName=false, bool unresolvedName=false, bool markCouldBeImageSequence=false) const
 Use this method to return all external files used by this node. More...
 
virtual void getExternalContent (MExternalContentInfoTable &table) const
 Returns the external content (files) that this node depends on. More...
 
bool addExternalContentForFileAttr (MExternalContentInfoTable &, const MObject &attr) const
 Adds content info to the specified table from a file path attribute. More...
 
bool setExternalContentForFileAttr (const MObject &attr, const MExternalContentLocationTable &)
 Sets content info in the specified attribute from the table. More...
 
virtual void setExternalContent (const MExternalContentLocationTable &)
 Changes the location of external content in batch. More...
 
virtual MTypeId typeId () const
 Returns the TYPEID of this node. More...
 
virtual MString typeName () const
 Returns the type name of this node. More...
 
virtual MString name () const
 Returns the name of this particular instance of this class. More...
 
virtual MObject thisMObject () const
 Returns the MObject associated with this user defined node. More...
 
virtual MStatus setExistWithoutInConnections (bool flag)
 This method specifies whether or not the node can exist without input connections. More...
 
virtual bool existWithoutInConnections (MStatus *ReturnStatus=NULL) const
 Determines whether or not this node can exist without input connections. More...
 
virtual MStatus setExistWithoutOutConnections (bool flag)
 This method specifies whether or not the node can exist without output connections. More...
 
virtual bool existWithoutOutConnections (MStatus *ReturnStatus=NULL) const
 Determines whether or not this node can exist without output connections. More...
 
MDataBlock _forceCache (const MDGContext &)
 This method is obsolete. More...
 
virtual bool getInternalValueInContext (const MPlug &, MDataHandle &, MDGContext &)
 This method is obsolete. More...
 
virtual bool setInternalValueInContext (const MPlug &, const MDataHandle &, MDGContext &)
 This method is obsolete. More...
 
virtual int internalArrayCount (const MPlug &, const MDGContext &) const
 This method is obsolete. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 
- Static Public Member Functions inherited from MPxNode
static MStatus addAttribute (const MObject &attr)
 This method adds a new attribute to a user defined node type during the type's initialization. More...
 
static MStatus inheritAttributesFrom (const MString &parentClassName)
 This method allows a class of plugin node to inherit all of the attributes of a second class of plugin node. More...
 
static MStatus attributeAffects (const MObject &whenChanges, const MObject &isAffected)
 This method specifies that a particular input attribute affects a specific output attribute. More...
 
static const char * className ()
 Returns the name of this class. More...
 

Static Public Attributes

static MObject enableRestPosition
 Node attribute: enableRestPosition/erp - boolean. More...
 
static MObject lockOutput
 Node attribute: lockOutput/lo - boolean. More...
 
- Static Public Attributes inherited from MPxNode
static MObject message
 message attribute
 
static MObject isHistoricallyInteresting
 is historically interesting attribute
 
static MObject caching
 caching attribute
 
static MObject state
 state attribute
 
static MObject frozen
 frozen attribute
 

Protected Member Functions

virtual const MObject passiveOutputAttribute () const
 Returns the passive output attribute for the constraint. More...
 
virtual void getOutputAttributes (MObjectArray &attributeArray)
 Returns output attributes for the constraint. More...
 
MStatus closestPoint (const MObject &dataGeometryObject, const MPoint &toThisPoint, MPoint &theClosestPoint) const
 Returns the closest point on this surface to the given point. More...
 
MStatus closestNormal (const MObject &dataGeometryObject, const MPoint &toThisPoint, MVector &theNormal) const
 Returns the closest normal on this surface to the given point. More...
 
MStatus closestTangent (const MObject &dataGeometryObject, const MPoint &toThisPoint, MVector &theTangent) const
 Returns the closest tangent on this surface to the given point. More...
 
MEulerRotation computeAim (const MMatrix &parentInverseMatrix, const MVector &targetVector, const MVector &aimVector, const MVector &upVector, const MVector &wupVector, MEulerRotation::RotationOrder order=MEulerRotation::kXYZ, const MQuaternion &jointOrient=MQuaternion::identity, MStatus *ResultStatus=NULL) const
 Returns the rotation which aligns the aimVector in local space with the targetVector in local space while keeping the upVector in local space and the wUpVector world space aligned as closely as possible. More...
 
MVector worldUpVector (MPxConstraint::UpVectorType upType, const MVector &upVector, const MMatrix &upMatrix, const MPoint &constrPoint, MStatus *ResultStatus=NULL) const
 Returns the world up vector based on the requested up type. More...
 
MPoint worldConstraintPoint (const MMatrix &parentInverseMatrix, const MVector &translate, const MVector &rotatePivot, const MVector &rotatePivotTranslate, MStatus *ResultStatus=NULL) const
 Returns the world constraint point. More...
 
- Protected Member Functions inherited from MPxNode
virtual MDataBlock forceCache ()
 USE _forceCache() IN SCRIPT. More...
 
virtual void setMPSafe (bool flag)
 USE _setMPSafe() IN SCRIPT. More...
 
virtual MStatus setDoNotWrite (bool flag)
 USE _setDoNotWrite() IN SCRIPT. More...
 
virtual bool doNotWrite (MStatus *ReturnStatus=NULL) const
 USE _doNotWrite() IN SCRIPT. More...
 
virtual MDataBlock forceCache (const MDGContext &)
 This method is obsolete. More...
 

Member Enumeration Documentation

The type of up vector.

Enumerator
kScene 

Scene up vector.

kObject 

Object up vector.

kObjectRotation 

Object rotation up vector.

kVector 

Specified vector.

kLast 

Last value, used for counting.

Constructor & Destructor Documentation

Constructor.

The constructor should never call any methods from MPxConstraint or make any calls that require the existence of the MObject associated with the user defined node. The postConstructor method should be used to do any initialization of this kind.

Member Function Documentation

const MObject weightAttribute ( ) const
virtual

Returns the weight attribute for the constraint.

Default implementation returns MObject::kNullObj.

+ Examples:
const MObject targetAttribute ( ) const
virtual

Returns the target attribute for the constraint.

Default implementation returns MObject::kNullObj.

+ Examples:
const MObject constraintRotateOrderAttribute ( ) const
virtual

Returns the rotate order attribute for the constraint.

Default implementation returns MObject::kNullObj.

If is only necessary to override this method if the constraint will control rotation.

const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.
const MObject passiveOutputAttribute ( ) const
protectedvirtual

Returns the passive output attribute for the constraint.

Default implementation returns MObject::kNullObj.

Passive output attributes do not prevent value modifications to the destination attribute when connected.

void getOutputAttributes ( MObjectArray attributeArray)
protectedvirtual

Returns output attributes for the constraint.

Default implementation clears the input attributeArray and returns.

Parameters
[out]attributeArrayArray of output attributes.
+ Examples:
MStatus closestPoint ( const MObject dataGeometryObject,
const MPoint toThisPoint,
MPoint theClosestPoint 
) const
protected

Returns the closest point on this surface to the given point.

Parameters
[in]dataGeometryObjectsurface
[in]toThisPointthe point to evaluate from
[out]theClosestPointthe calculated closest point
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kInvalidParameter dataGeometryObject is invalid.
  • MS::kFailure An object error has occurred.
MStatus closestNormal ( const MObject dataGeometryObject,
const MPoint toThisPoint,
MVector theNormal 
) const
protected

Returns the closest normal on this surface to the given point.

Parameters
[in]dataGeometryObjectsurface
[in]toThisPointthe point to evaluate from
[out]theNormalthe calculated closest normal
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kInvalidParameter dataGeometryObject is invalid.
  • MS::kFailure An object error has occurred.
MStatus closestTangent ( const MObject dataGeometryObject,
const MPoint toThisPoint,
MVector theTangent 
) const
protected

Returns the closest tangent on this surface to the given point.

Parameters
[in]dataGeometryObjectsurface
[in]toThisPointthe point to evaluate from
[out]theTangentthe calculated closest tangent
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kInvalidParameter dataGeometryObject is invalid.
  • MS::kFailure An object error has occurred.
MEulerRotation computeAim ( const MMatrix parentInverseMatrix,
const MVector targetVector,
const MVector aimVector,
const MVector upVector,
const MVector wUpVector,
MEulerRotation::RotationOrder  order = MEulerRotation::kXYZ,
const MQuaternion jointOrient = MQuaternion::identity,
MStatus ResultStatus = NULL 
) const
protected

Returns the rotation which aligns the aimVector in local space with the targetVector in local space while keeping the upVector in local space and the wUpVector world space aligned as closely as possible.

Parameters
[in]parentInverseMatrix
[in]targetVector
[in]aimVector
[in]upVector
[in]wUpVector
[in]order
[in]jointOrient
[out]ResultStatus
Returns
Aim rotation.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MVector worldUpVector ( MPxConstraint::UpVectorType  upType,
const MVector upVector,
const MMatrix upMatrix,
const MPoint constrPoint,
MStatus ResultStatus = NULL 
) const
protected

Returns the world up vector based on the requested up type.

Parameters
[in]upType
[in]upVector
[in]upMatrix
[in]constrPoint
[out]ResultStatus
Returns
World up vector.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.
MPoint worldConstraintPoint ( const MMatrix parentInverseMatrix,
const MVector translate,
const MVector rotatePivot,
const MVector rotatePivotTranslate,
MStatus ResultStatus = NULL 
) const
protected

Returns the world constraint point.

Parameters
[in]parentInverseMatrix
[in]translate
[in]rotatePivot
[in]rotatePivotTranslate
[out]ResultStatus
Returns
World constraint point.
Status Codes:
  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

Member Data Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MObject enableRestPosition
static

Node attribute: enableRestPosition/erp - boolean.

This attribute defines the constraint behavior when all weights are at zero.

If true, the constraint goes to the restTranslate position when all weights are zero. If false, the constraint output is not computed when all weights are zero.

MObject lockOutput
static

Node attribute: lockOutput/lo - boolean.

When enabled, the constrained object cannot be moved away from its constrained location, and a pairBlend will not be inserted if the user tries to keyframe the constrained attributes.

This allows for the pre-5.0 behavior of constraints. When disabled, the constrained object can be moved away from the constraint and a pairBlend will be inserted if the object is keyframed and the animation blending preference specifies that blending is enabled.


The documentation for this class was generated from the following files:
  • MPxConstraint.h
  • MPxConstraint.cpp