C++ API Reference
|
Create and manipulate curve attributes. More...
#include <MCurveAttribute.h>
Public Member Functions | |
MCurveAttribute () | |
Creates an empty Curve Attribute class. More... | |
MCurveAttribute (const MCurveAttribute &other) | |
Copy constructor operator. More... | |
MCurveAttribute (const MPlug &obj, MStatus *ReturnStatus=NULL) | |
Creates a new Curve Attribute class. More... | |
MCurveAttribute (const MObject &node, const MObject &attr, MStatus *ReturnStatus=NULL) | |
Creates a new Curve Attribute class. More... | |
MCurveAttribute & | operator= (const MCurveAttribute &other) |
Assignment operator. More... | |
~MCurveAttribute () | |
Destructor. | |
unsigned int | getNumEntries (MStatus *returnStatus=NULL) |
Gets the number of entries in the curve attribute. More... | |
void | getEntries (MIntArray &indexes, MFloatArray &positions, MFloatArray &values, MStatus *returnStatus=NULL) |
Gets all the entries in a curve attribute. More... | |
void | addEntries (MFloatArray &positions, MFloatArray &values, MStatus *returnStatus=NULL) |
Adds entries into a curve attribute. More... | |
void | deleteEntries (MIntArray &indexes, MStatus *returnStatus=NULL) |
Deletes entries in the curve attribute. More... | |
void | setValueAtIndex (float value, unsigned int index, MStatus *returnStatus=NULL) |
Sets the value of a given entry. More... | |
void | setPositionAtIndex (float position, unsigned int index, MStatus *returnStatus=NULL) |
Sets the position of a given entry. More... | |
void | getValuesAtPositions (const MFloatArray &positions, MFloatArray &values, MStatus *returnStatus=NULL) |
Gets the values (y-axis) at the given positions (x-axis) More... | |
void | getValueAtPosition (float position, float &value, MStatus *returnStatus=NULL) |
Gets the value (y-axis) at the given position (x-axis) x If this curve is empty, then this method will return a failure. More... | |
void | sampleValueCurve (unsigned int numberOfSamples, MFloatArray &values, MStatus *returnStatus=NULL) |
Perform a linear sampling of this curve ramp and return the results. More... | |
bool | hasIndex (unsigned int index, MStatus *ReturnStatus=NULL) const |
Returns true if this curve attribute has an entry defined with a given index. More... | |
MStatus | sort (bool ascending=true) |
Sort the curve attribute entries by position in ascending or descending order, other arrays are sorted accordingly. More... | |
MStatus | pack () |
Change the indices numbering by re-ordering them from 0. More... | |
MStatus | setCurve (const MFloatArray &values, const MFloatArray &positions) |
Sets this curve attribute with entries defined from a set of float, position value arrays. More... | |
Static Public Member Functions | |
static MObject | createCurveAttr (const MString &attrLongName, const MString &attrShortName, MStatus *ReturnStatus=NULL) |
This function creates the curve attribute. More... | |
static MObject | createCurve (const MString &attrLongName, const MString &attrShortName, const MObject &node, const MFloatArray &values, const MFloatArray &positions, MStatus *ReturnStatus=NULL) |
Creates a new curve attribute initialized with entries defined from a set of float, position value arrays. More... | |
static const char * | className () |
Returns the name of this class. More... | |
Create and manipulate curve attributes.
A curve attribute consists of a set of entries describing a 3rd degree NURBS curve which is used to map an input value onto an output value. Each entry consists of an input position ranging from 0 to 1, an output value that position maps onto. The (position, value) pairs form a control vertex for the NURBS curve.
The preferred way of creating a curve attribute is to use the createCurve or createCurveAttr methods. Once created, curve widgets can be created for those attributes using the falloffCurve or falloffCurveAttr MEL commands.
A curve must always have at least four control vertices since it is a third degree NURBS curve.
OPENMAYA_MAJOR_NAMESPACE_OPEN MCurveAttribute | ( | ) |
Creates an empty Curve Attribute class.
Initializes it as a null Object.
MCurveAttribute | ( | const MCurveAttribute & | other | ) |
Copy constructor operator.
Duplicates the given curve attribute.
[in] | other | Curve attribute to be copied |
MCurveAttribute | ( | const MPlug & | obj, |
MStatus * | ReturnStatus = NULL |
||
) |
Creates a new Curve Attribute class.
If the plug is not of a Curve, then the constructor will return a failure.
[in] | obj | Plug of a curve |
[out] | ReturnStatus | return status |
MCurveAttribute | ( | const MObject & | node, |
const MObject & | attr, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Creates a new Curve Attribute class.
If the node does not have that attribute then the constructor will return a failure. If the attribute is not of a curve the constructor will also fail.
[in] | node | Node that contains a ramp attribute |
[in] | attr | The curve attribute |
[out] | ReturnStatus | return status |
MCurveAttribute & operator= | ( | const MCurveAttribute & | other | ) |
Assignment operator.
Copies one curve attribute to another.
[in] | other | Curve attribute to be copied |
unsigned int getNumEntries | ( | MStatus * | ReturnStatus = NULL | ) |
Gets the number of entries in the curve attribute.
[out] | ReturnStatus | return status |
void getEntries | ( | MIntArray & | indices, |
MFloatArray & | positions, | ||
MFloatArray & | values, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Gets all the entries in a curve attribute.
[out] | indices | unique values that specify each entry in the curve |
[out] | positions | the positions of each entry (can range from 0 to 1) |
[out] | values | the values of the entries at each position (can range from 0 to 1) |
[out] | ReturnStatus | Status code. |
void addEntries | ( | MFloatArray & | positions, |
MFloatArray & | values, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Adds entries into a curve attribute.
[in] | positions | the positions of the new entries (can range from 0 to 1) |
[in] | values | the values of the new entry at each position |
[out] | ReturnStatus | Status code. |
Deletes entries in the curve attribute.
If any one of the indices is incorrect, then this function will not delete any of the entries.
A curve attribute must always have at least one entry. Any attempt to delete the last remaining entry will fail.
[in] | indices | the entries that need to be deleted |
[out] | ReturnStatus | Status code. |
void setValueAtIndex | ( | float | value, |
unsigned int | index, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Sets the value of a given entry.
If there is no entry at the given index, then this method will return a failure.
[in] | value | the new value for the entry |
[in] | index | index of entry to change |
[out] | ReturnStatus | return status |
void setPositionAtIndex | ( | float | position, |
unsigned int | index, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Sets the position of a given entry.
If there is no entry at the given index, then this method will return a failure.
[in] | position | the new position for the entry |
[in] | index | index of entry to change |
[out] | ReturnStatus | return status |
void getValuesAtPositions | ( | const MFloatArray & | positions, |
MFloatArray & | values, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Gets the values (y-axis) at the given positions (x-axis)
If this curve is empty, then this method will return a failure. If any position is out of range, either the start or end value will be returned at the corresponding index in the value array.
[in] | positions | the desired x-axis positions |
[in] | values | the y-axis values at the positions |
[out] | ReturnStatus | Status code |
void getValueAtPosition | ( | float | position, |
float & | value, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Gets the value (y-axis) at the given position (x-axis) x If this curve is empty, then this method will return a failure.
If the position is out of range, either the start or end value will be returned.
[in] | position | the desired position (x-axis) |
[in] | value | the y-axis value at the position |
[out] | ReturnStatus | Status code |
void sampleValueCurve | ( | unsigned int | numberOfSamples, |
MFloatArray & | values, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Perform a linear sampling of this curve ramp and return the results.
If this curve is empty, then this method will return a failure. If the number of samples is less than two this method will return a failure.
[in] | numberOfSamples | The number of times to sample the ramp |
[out] | values | The returned ramp samples |
[out] | ReturnStatus | Status code |
bool hasIndex | ( | unsigned int | index, |
MStatus * | ReturnStatus = NULL |
||
) | const |
Returns true if this curve attribute has an entry defined with a given index.
[in] | index | Index to query. |
[out] | ReturnStatus | Status code |
MStatus sort | ( | bool | ascending = true | ) |
Sort the curve attribute entries by position in ascending or descending order, other arrays are sorted accordingly.
Indices are also compressed during the operation.
[in] | ascending | Option for sorting in ascending (default) or descending order. |
MStatus pack | ( | ) |
Change the indices numbering by re-ordering them from 0.
MStatus setCurve | ( | const MFloatArray & | values, |
const MFloatArray & | positions | ||
) |
Sets this curve attribute with entries defined from a set of float, position value arrays.
Existing entries are deleted before the new ones are added.
[in] | values | Array of float value. |
[in] | positions | Array of desired positions. |
|
static |
This function creates the curve attribute.
[in] | attrLongName | Long name of the curve attribute |
[in] | attrShortName | Short name of the curve attribute |
[out] | ReturnStatus | Return status |
|
static |
Creates a new curve attribute initialized with entries defined from a set of float, position value arrays.
[in] | attrLongName | Long name of the new curve attribute |
[in] | attrShortName | Short name of the new curve attribute |
[in] | node | The node to which the new attribute will be added |
[in] | values | Array of float value. |
[in] | positions | Array of desired positions. |
[out] | ReturnStatus | Status code |
|
static |
Returns the name of this class.