- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions

# MPxConstraint Class Reference
OpenMayaAnim - API module for animation | Proxy classes

Search for all occurrences

## Detailed 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:

  geometrySurfaceConstraint.cpp, and geometrySurfaceConstraint.h.

`#include <MPxConstraint.h>`

Inheritance diagram for MPxConstraint:
[legend]

List of all members.

## Public Types
enum | UpVectorType { kScene = 0, kObject, kObjectRotation, kVector, kLast }
| The type of up vector. More...
## Public Member Functions
| MPxConstraint ()
| Constructor.
virtual | ~MPxConstraint ()
| Destructor.
virtual const MObject | weightAttribute () const
| Returns the weight attribute for the constraint.
virtual const MObject | targetAttribute () const
| Returns the target attribute for the constraint.
virtual const MObject | constraintRotateOrderAttribute () const
| Returns the rotate order attribute for the constraint.
## Static Public Member Functions
static const char * | className ()
| Returns the name of this class.
## Static Public Attributes
static MObject | enableRestPosition
| Node attribute: enableRestPosition/erp - boolean.
static MObject | lockOutput
| Node attribute: lockOutput/lo - boolean.
## Protected Member Functions
virtual const MObject | passiveOutputAttribute () const
| Returns the passive output attribute for the constraint.
virtual void | getOutputAttributes (MObjectArray &attributeArray)
| Returns output attributes for the constraint.
MStatus | closestPoint (const MObject &dataGeometryObject, const MPoint &toThisPoint, MPoint &theClosestPoint) const
| Returns the closest point on this surface to the given point.
MStatus | closestNormal (const MObject &dataGeometryObject, const MPoint &toThisPoint, MVector &theNormal) const
| Returns the closest normal on this surface to the given point.
MStatus | closestTangent (const MObject &dataGeometryObject, const MPoint &toThisPoint, MVector &theTangent) const
| Returns the closest tangent on this surface to the given point.
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.
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.
MPoint | worldConstraintPoint (const MMatrix &parentInverseMatrix, const MVector &translate, const MVector &rotatePivot, const MVector &rotatePivotTranslate, MStatus *ResultStatus=NULL) const
| Returns the world constraint point.

## Member Enumeration Documentation

enum UpVectorType

Search for all occurrences

The type of up vector.

Enumerator:

  kScene | Scene up vector. Search for all occurrences
  kObject | Object up vector. Search for all occurrences
  kObjectRotation | Object rotation up vector. Search for all occurrences
  kVector | Specified vector. Search for all occurrences
  kLast | Last value, used for counting. Search for all occurrences

## Constructor & Destructor Documentation

MPxConstraint | ( |  | ) |

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]`

Search for all occurrences

Returns the weight attribute for the constraint.

Default implementation returns MObject::kNullObj.

Examples:
  geometrySurfaceConstraint.h.

const MObject targetAttribute | ( |  | ) | const`[virtual]`

Search for all occurrences

Returns the target attribute for the constraint.

Default implementation returns MObject::kNullObj.

Examples:
  geometrySurfaceConstraint.h.

const MObject constraintRotateOrderAttribute | ( |  | ) | const`[virtual]`

Search for all occurrences

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]`

Search for all occurrences

Returns the name of this class.

Returns:
  The name of this class.

Reimplemented from MPxNode.

const MObject passiveOutputAttribute | ( |  | ) | const`[protected, virtual]`

Search for all occurrences

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 | ) | `[protected, virtual]`

Search for all occurrences

Returns output attributes for the constraint.

Default implementation clears the input attributeArray and returns.

Parameters:

  [out] | attributeArray | Array of output attributes.

Examples:
  geometrySurfaceConstraint.h.

MStatus closestPoint | ( | const MObject & | dataGeometryObject,
|  | const MPoint & | toThisPoint,
|  | MPoint & | theClosestPoint
| ) |  | const`[protected]`

Search for all occurrences

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

Parameters:

  [in] | dataGeometryObject | surface
  [in] | toThisPoint | the point to evaluate from
  [out] | theClosestPoint | the 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]`

Search for all occurrences

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

Parameters:

  [in] | dataGeometryObject | surface
  [in] | toThisPoint | the point to evaluate from
  [out] | theNormal | the 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]`

Search for all occurrences

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

Parameters:

  [in] | dataGeometryObject | surface
  [in] | toThisPoint | the point to evaluate from
  [out] | theTangent | the 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]`

Search for all occurrences

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]`

Search for all occurrences

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]`

Search for all occurrences

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

MObject enableRestPosition`[static]`

Search for all occurrences

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]`

Search for all occurrences

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.

MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint
MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint MPxConstraint